lastname = "DE' CA-R LO III"
'separate lastname by spaces into an array
a = split(lastname," ")
new_lastname = a(0)
for i = 0 to ubound(a) -1 ' add each chunk of the last name to the final string
'the last piece of the last name is not added if it is less than 4 characters (such as III, II, I, etc)
if i + 1 = ubound(a) and len(a(i+1)) > 3 then
new_lastname = new_lastname + a(i+1)
elseif i + 1< ubound(a) then
new_lastname = new_lastname + a(i+1)
end if
next
new_lastname = Replace(new_lastname,"-","") 'take out hyphens
new_lastname = Replace(new_lastname,"'","") 'take out punctuations
wscript.echo new_lastname
Thursday, September 3, 2009
Cut out unwanted pieces of a lastname with vbscript
Monday, August 31, 2009
Linux mail basics
# Start interactive mail
mail
# Print current message
p
# Delete current message
d
#Exit mail program
q
# Print current message
p
# Delete current message
d
#Exit mail program
q
Friday, August 28, 2009
Leopard user template
sudo mv /System/Library/User\ Template/English.lproj /System/Library/User\ Template/English.lproj.old
This will give you copy of the original called "English.lproj.old" in the same folder. Then you may copy your new template file by executing:
sudo cp -R /Users/new-user-short-name /System/Library/User\ Template/English.lproj
If you prefer to remove (delete) the original try the command without the /* at the end: sudo rm -r /System/Library/User\ Template/English.lproj
This will give you copy of the original called "English.lproj.old" in the same folder. Then you may copy your new template file by executing:
sudo cp -R /Users/new-user-short-name /System/Library/User\ Template/English.lproj
If you prefer to remove (delete) the original try the command without the /* at the end: sudo rm -r /System/Library/User\ Template/English.lproj
Get mac address from xml and generate computer names for each mac
Parsing xml is pretty easy using grep. The benefit of sed/grep is that they are right there -- if you have cygwin, Linux or Mac.
Here is an example format:
This will parse the xml file formatted like above and generate a computer name for each mac address. A good application of sed/grep/bash. If you are installing a lot of new computers and need to associate new names with mac addresses, this is a good start.
Here is an example format:
<macs>
<string>00-00-00-00-00-01</string>
<string>00-00-00-00-00-02</string>
</macs>
This will parse the xml file formatted like above and generate a computer name for each mac address. A good application of sed/grep/bash. If you are installing a lot of new computers and need to associate new names with mac addresses, this is a good start.
grep All\ Computers.plist | sed -e 's/<\/*string>//g' | while read line; do ((i++)); echo "pc-$i $line"; done > macs.txt
Friday, August 21, 2009
Set the default printer from the registry
rem Using reg.exe you can set the default printer
@echo off
rem Here we are doing a split of the hostname on the hypen, so room1-01, becomes room1
for /F "tokens=1 delims=-" %%a in ('hostname') do set name=%%a
if %name% == room1 ( reg add "hkcu\software\microsoft\windows nt\currentversion\windows" /t REG_SZ /d "ROOM1PRINTER,winspool,NE04:" /v "Device" /f
)
@echo off
rem Here we are doing a split of the hostname on the hypen, so room1-01, becomes room1
for /F "tokens=1 delims=-" %%a in ('hostname') do set name=%%a
if %name% == room1 ( reg add "hkcu\software\microsoft\windows nt\currentversion\windows" /t REG_SZ /d "ROOM1PRINTER,winspool,NE04:" /v "Device" /f
)
Thursday, August 20, 2009
Installing a folder tree of fonts on XP
rem XP doesn't let you select a folder to install fonts from; it will not recurse to find fonts within a folder unless they are all under one folder
rem This command will go through all folders in the current directory and copy the files to all_fonts
rem The /y for copy will force an overwrite if a duplicate file shows up
for /F "tokens=1 delims=," %a in ('dir /s /b') do copy /y "%a" all_fonts
rem This command will go through all folders in the current directory and copy the files to all_fonts
rem The /y for copy will force an overwrite if a duplicate file shows up
for /F "tokens=1 delims=," %a in ('dir /s /b') do copy /y "%a" all_fonts
Tuesday, August 4, 2009
mysql -- attaching to a host
#This is a way checking your connection to a mysql db server
mysql --user=username -h hostname -p
mysql --user=username -h hostname -p
Subscribe to:
Posts (Atom)