public void swap(int[] a, int i, int j) {
int tmp=a[i];a[i]=a[j];a[j]=tmp;
}
public int partition(int[] a, int low, int high) {
int pivot, p_pos, tmp, i, j;
p_pos = low;
pivot = a[p_pos];
for (i=low+1;i<=high;i++) {
if (a[i] < pivot) {
p_pos++;
swap(a, p_pos, i);
}
}
swap(a, low, p_pos);
return p_pos;
}
public void quicksort(int[] a, int low, int high) {
int pivot;
if (low < high) {
pivot = partition(a, low, high);
quicksort(a, low, pivot-1);
quicksort(a, pivot+1, high);
}
}
Binary Search Algorithm implemented in VBScript. Copy this script and use it for a multi-dimensional array.
Function BinarySearch(searchItem, startPos, endPos, TheArray, column_to_be_searched)
Dim midPoint
If startPos = endPos Then
If searchItem = TheArray(startPos, column_to_be_searched) Then
BinarySearch = startPos
Else
BinarySearch = -1 '-(startPos) Where it would have been...
End If
ElseIf startPos > endPos Then
BinarySearch = -1 '-(startPos)
Else
midPoint = CLng(startPos + ((endPos - startPos) / 2))
If searchItem = TheArray(midPoint, column_to_be_searched) Then
BinarySearch = midPoint
Else
If searchItem < TheArray(midPoint, column_to_be_searched) Then
BinarySearch = BinarySearch(searchItem, startPos, midPoint - 1, TheArray, column_to_be_searched)
Else
BinarySearch = BinarySearch(searchItem, midPoint + 1, endPos, TheArray, column_to_be_searched)
End If
End If
End If
End Function 'BinarySearch
If you want to upload certain files on your website frequently, this script can help you.
1. Create a folder "c:\upload\"
2. Copy file1.htm, file2.htm etc to "c:\upload\"
3. Copy this script and paste into notepad
4. Make Necessary Changes
Specify username and password in Line 9
Specify remote folder name in Line 11
Change www.charora.com to your domain name in Line 24
5. SaveAs "upload.bat"
6. Run upload.bat
@echo off
rem Author: Sushma Charora
rem Date: 8/30/2006 11:30 AM PST
rem This script FTP over files to
rem the web-site automatically.
rem If you have any question contact me at
rem first we build a response file containing the FTP commands
ECHO verbose off > c:\upload\ftp.in
ECHO user usernamepassword >> c:\upload\ftp.in
ECHO bin >> c:\upload\ftp.in
ECHO cd /remotefolder >> c:\upload\ftp.in
ECHO put c:\upload\file1.htm >> c:\upload\ftp.in
ECHO put c:\upload\file2.htm >> c:\upload\ftp.in
ECHO put c:\upload\file3.htm >> c:\upload\ftp.in
ECHO put c:\upload\file4.htm >> c:\upload\ftp.in
ECHO put c:\upload\file5.htm >> c:\upload\ftp.in
ECHO put c:\upload\file6.htm >> c:\upload\ftp.in
ECHO put c:\upload\file7.htm >> c:\upload\ftp.in
ECHO quit >> c:\upload\ftp.in
rem ok, now we have created the file we want to be executed by ftp
rem start ftp
rem -n means suppress autologin
rem -s:c:\upload\ftp.in means take commands from that file
ftp -n -s:c:\upload\ftp.in www.charora.com
del c:\upload\ftp.in
rem Done!
GOTO QUIT
:QUIT
Echo that's it!
Script to generate list of all registered extensions on your machine into an excel file. Please email me at
, if you have any question about the script.
Dim Create
Dim FSO ' FileSystemObject
Dim TS ' TextStreamObject
Create = True
WriteToFile = "C:\Temp\Ext.xls"
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.FileExists(WriteToFile) Then
FSO.DeleteFile WriteToFile, true
End If
Set TS = FSO.CreateTextFile(WriteToFile, Create)
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
strKeyPath = ""
oReg.EnumKey HKEY_CLASSES_ROOT, strKeyPath, arrSubKeys
TS.Write "Extension" & char(9) & "Value Name 1" & char(9) & "Date Type 1" & char(9) & "Date Value 1" & char(9) & "Value Name 2" & char(9) & "Date Type 2" & char(9) & "Date Value 2" & char(9) & "Value Name 3" & char(9) & "Date Type 3" & char(9) & "Date Value 3" & char(9) & "Value Name 4" & char(9) & "Date Type 4" & char(9) & "Date Value 4" & char(9) & "Value Name 5" & char(9) & "Date Type 5" & char(9) & "Date Value 5" & char(9) & "Value Name 6" & char(9) & "Date Type 6" & char(9) & "Date Value 6" & char(13) & char(10)
For Each subkey In arrSubKeys
if left(subkey, 1) = "." then
TS.Write subkey
oReg.EnumValues HKEY_CLASSES_ROOT, subkey, arrValueNames, arrValueTypes
if IsArray(arrValueNames) then
For i=0 To UBound(arrValueNames)
TS.Write char(9) & arrValueNames(i)
Select Case arrValueTypes(i)
Case REG_SZ
TS.Write char(9) & "String"
oReg.GetStringValue HKEY_CLASSES_ROOT, subkey, arrValueNames(i), strValue
TS.Write char(9) & strValue
Case REG_EXPAND_SZ
TS.Write char(9) & "Expanded String"
oReg.GetExpandedStringValue HKEY_CLASSES_ROOT, subkey, arrValueNames(i), strValue
TS.Write char(9) & strValue
Case REG_BINARY
TS.Write char(9) & "Binary"
oReg.GetBinaryValue HKEY_CLASSES_ROOT, subkey, arrValueNames(i), strValue
TS.Write char(9) & strValue
Case REG_DWORD
TS.Write char(9) & "DWORD"
oReg.GetDWORDValue HKEY_CLASSES_ROOT, subkey, arrValueNames(i), strValue
TS.Write char(9) & strValue
Case REG_MULTI_SZ
TS.Write char(9) & "Multi String"
oReg.GetMultiStringValue HKEY_CLASSES_ROOT, subkey, arrValueNames(i), strValue
TS.Write char(9) & strValue
End Select
Next
else
TS.Write char(9) & arrValueNames
Select Case arrValueTypes
Case REG_SZ
TS.Write char(9) & "String"
oReg.GetStringValue HKEY_CLASSES_ROOT, subkey, arrValueNames, strValue
TS.Write char(9) & strValue
Case REG_EXPAND_SZ
TS.Write char(9) & "Expanded String"
oReg.GetExpandedStringValue HKEY_CLASSES_ROOT, subkey, arrValueNames, strValue
TS.Write char(9) & strValue
Case REG_BINARY
TS.Write char(9) & "Binary"
oReg.GetBinaryValue HKEY_CLASSES_ROOT, subkey, arrValueNames, strValue
TS.Write char(9) & strValue
Case REG_DWORD
TS.Write char(9) & "DWORD"
oReg.GetDWORDValue HKEY_CLASSES_ROOT, subkey, arrValueNames, strValue
TS.Write char(9) & strValue
Case REG_MULTI_SZ
TS.Write char(9) & "Multi String"
oReg.GetMultiStringValue HKEY_CLASSES_ROOT, subkey, arrValueNames, strValue
TS.Write char(9) & strValue
End Select
end if
TS.Write char(13)
end if
next
TS.Close
Set FSO = Nothing
Set TS = Nothing
"Keep away from people who try to belittle your ambitions. Small people always do that, but the really great make you feel that you, too, can become great."
- Mark Twain