Archive for March, 2010

Shorter emails are better.. apparently

Rounds Timefieldhere to the nearest 5 minutes..

trunc(timefieldhere,'dd') + round(to_char(timefieldhere,'sssss') / 300) / 288)

Trying to use sed in some stuff and i never want to have to write this kinda crap again so..

grep '^D' Filename  | sed -e 's/\(^.\{43\}\)0\(.*\)/\1M\2/g'

That looks for any line in “Filename” that starts with D… then if the 44th character is 0, replace it with an M.

grep "^D" Filename | sed -e 's/.*/&XX/' 

That looks for anything in Filename and adds “XX” to the end of the line..
Another Useful link

For work i had to come up with a way to remap printers since our current print server is on the way out.. I was pondering at home about the best way to do this with minimal work for the service desk or for me, and this is what i came up with.. Easy way to map any old printers to new ones.. Just have to update the findnewPrinter function with the old vs new printers..

'Script to map and remove printers from old print server to new one
'Needs an entry in findNewPrinter function for each mapping
Set objNetwork = CreateObject("Wscript.Network") 
strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Function findNewPrinter(Printername)
                select case PrinterName
                case "\\OldPrintServer\OldPrinterQueue"
                                findNewPrinter = "\\newprintserver\newprintqueue"
                case else
                                wscript.echo  "Printer: " & Printername & " not found"
                                findNewPrinter = ""
                end select
end function
Set colPrinters = objWMIService.ExecQuery _
    ("Select * From Win32_Printer Where Local = FALSE")
For Each objPrinter in colPrinters
                wscript.echo "Printer: " & objprinter.Name & " Default: " & objprinter.default
                strNewPrinter = findNewPrinter(
                if not (strNewPrinter = "") then
                                objNetwork.AddWindowsPRinterConnection strNewPrinter
                                if (objPrinter.default) then
                                                objNetwork.SetDefaultPrinter strNewPrinter
                                end if
                                objNetwork.RemovePrinterConnection, true, true
               end if