Archive for the ‘Programming’ Category

Autonumber using Stored Procedure in SQL Server

Friday, January 16th, 2009

Today I want to share an SQL Server 2005 stored procedure to make autonumber. This stored procedure provide two numbering templates.

autonumber template #1: ..
autonumber template #2: <1DIGIT-YEAR><1DIGIT-MONTH>.

sqlserver-autonumber

(more…)

Compare Folder Script

Wednesday, December 31st, 2008

Today I created a script to compare the contents of two folder including its subfolders. It’s a simple solution if you don’t want to buy folder comparator software, but the script will not compare the content of the file, it only compares the file size and last modified date.

compare-script

Click read more to see the script
(more…)

Rename Multiple File with Regex Script

Wednesday, December 24th, 2008

Since Windows rename command doesn’t support regular expression, so today I made a VB Script to batch rename multiple files using regex method.

rename-script

What is Regular Expression?
Basically, a regular expression is a pattern describing a certain amount of text. Their name comes from the mathematical theory on which they are based. But we will not dig into that. Since most people including myself are lazy to type, you will usually find the name abbreviated to regex or regexp. I prefer regex, because it is easy to pronounce the plural “regexes”.

Click read more to see the script
(more…)

Read/Write ID3Tag from MP3 with VB Script

Monday, December 22nd, 2008

I’ve found the way to read/write ID3Tag from MP3 files with VB Script.

read-id3tag-vbscript

Requirement
In order to run the script, you must first download the CDDBControl.dll library file. You can download it here.

Note: it also support WMA format

Click read more to see details.
(more…)

Sliding Image in JavaScript

Sunday, December 21st, 2008

I’ve created a javascript code to show sliding image on the web (youtube-like video preview).

sliding-image-demo

Requirement
To use the script you need an HTML and Javascript Editor, I’m using Adobe Dreamweaver. You may need 6 jpg image files (to try an example below), and ofcourse a web browser.

Click read more for see the script.
(more…)

Multiple Virtual Servers on IIS (Windows XP Pro)

Friday, December 19th, 2008

Microsoft Windows XP Pro has built in Web Server called Internet Information Service (IIS). In order to use the feature, make sure your IIS service already activated:

  • Right click on My Computer, choose Manage
  • Expand tree Services and Applications
  • If you see Internet Information Services item, then your IIS service is already installed

IIS Installation
To install IIS Service, follow these instructions to activate it:

  • Go to Control Panel > Add or Remove Programs
  • Open Add/Remove Windows Components, tick on Internet Information Services (IIS)
  • Click Next button until it finished

multiple-virtual-server

Create a Virtual Server
Check on the Web Sites folder in IIS management console, you may see only “Default Web Site”. If you are a web developer, sometime you need to have another separate web servers. Of course you can also mount a virtual directory to the server, but it will never have root path.

(more…)

Create Socket Connection in PHP

Friday, December 5th, 2008

PHP server provide a method in which it can establish socket connection to communicate with other server. Many software applications including web server, instant messaging, and peer to peer file sharing systems rely on sockets. In other words, you can possibly create any web based application, ie. instant messaging client purely in PHP.

Open Connection
The basic function to open a socket connection is fsockopen(). You can establish a connection in just one line of PHP code, pretty simple uh?

//this method will open a connection and store a file handler to $fp variable,
//you can use fgets/fputs on it then later,
//if something goes wrong, you can check $errno and $errdesc variable
$fp=fsockopen("www.host.com",80,$errno,$errdesc);

After we established a connection, let’s close it by using fclose() method.

$fp=fsockopen("www.host.com",80,$errno,$errdesc);
fclose($fp);

Sending a Request
Now I will show you how to send a data (request) to a server and then check the response returned by the server. Once we open a socket, you can send any data to it, and wait for the response.

(more…)

Capture Webcam Video from Java Application

Sunday, November 30th, 2008

Java provide a framework API which enables audio, video and other time-based media to be added to applications and applets built on Java technology. We can use The Java Media Framework API (JMF) to capture video/images from a webcam device.

Above picture explains how JMF works, first we initialize capture device, and then create a datasource object, bind it to player object, and display it to user on JFrame window (the TV). Now I will demonstrate you how to implement it.

Requirements

Click read more to see the code!

(more…)

Grabbing Data from Web using VBScript/VBA

Tuesday, November 25th, 2008

You can grab data from web URL, here is 2 methods we can use.

1. Using IE Instance
The first method using IE instance
pros:

  • No need to install
  • You can see the progress by uncomment set visible line

cons:

  • IE doesnt have method to let you wait until finish, so you must check in a loop
  • IE takes more memory than other methods
Function IEGetRequest(URL)
  'Create IE Instance
  Dim IeInstance

  Set IeInstance = CreateObject("InternetExplorer.Application")

  'Uncomment the next line to see IE window
  'IeInstance.Visible = True

  IeInstance.Navigate URL

  Do While IeInstance.Busy
    Wait 1, "Waiting " & URL
  Loop

  'Get the response
  On Error Resume Next
  IEGetRequest = IeInstance.Document.Body.innerHTML
  IeInstance.Quit
End Function

Sub Wait(sec, msg)
  On Error Resume Next
  Dim Shell
  If IsEmpty(Shell) Then
    Set Shell = CreateObject("WScript.Shell")
  End If
  Shell.Popup msg, sec, "", 64
End Sub

' Test the function
MsgBox IEGetRequest("http://www.yahoo.com/")

(more…)

How to Migrate Access Database to SQL Server 2005

Monday, November 24th, 2008

I found a solution to import Access Data to SQL Server easily using SQL Server Migration Assistant (SSMA) for Access. This is a free tool from Microsoft that comes with three versions (Access, Oracle, and Sybase).

(more…)