August 8, 2009

Google Maps vs Virtual Earth

Google Maps vs Virtual Earth...for a new project I need. Which one should I use? Which one has the better API? Which one has better licensing?

August 7, 2009

Forgot Password Trillian Hack

I forgot my password to one of my accounts and was starting to get very frustrated. I use pidgin as my IM client (sorry digsby fans) but I also had a version of trillian still on my machine. I found a nifty Perl script here that allowed me to decrypt my password. It is a bit sad how unsecure it was with trillian.

August 6, 2009

Chrome Bug!

Gotta love when a developer plays with a beta :) Check this bug out that was posted a few days ago.

Here it is in short:

Chrome Version : 3.0.197.0 (22354)
OS + version : Debian AMD64(Using 32-bit libs, inapplicable)
CPU architecture (32-bit / 64-bit): x86_64
window manager : GNOME(gtk)
URLs (if applicable) : All
Behavior in Firefox 3.x (if applicable): X button
Behavior in Chrome for Windows (optional): X button

What steps will reproduce the problem?
1. Look at what the X button is supposed to be
2.
3.

What is the expected result?
an X button

What happens instead?
Some guys head

Please provide any additional information below. Attach a screenshot
and backtrace if possible.
I think it's rather self-explanatory
http://img262.imageshack.us/img262/7919/screenshot9.png

I figure it's best to tell the developers who probably don't test **every**
version.

I suspect it was either a prank or a mistake.

Powershell and Visio

Here is a cool article on automation using visio with powershell. The idea here was to build a topology based off of AD. Very cool.

August 5, 2009

Powershell and VMware Stats

Our production environment is a mixture of VMs and Physical boxes. Perfmon is used to get a good idea on hoe are physical boxes are doing, but it's a different story with VMs. I got a request to read and get stats for CPU and memory per guest across the entire cluster and add that to a sql database.

There is a toolkit available from VMWare which will allow you to work with Perl of Powershell. Powershell was obviously my first choice:
############################################################
#ClusterStats.ps1
#
#This is read as the % CPU used by the guest calculated
#against the effective CPU and % memory used by the
#guest against the effective Memory. Both of these
#values are calculated across the entire cluster.
############################################################

Add-PSsnapin VMware.VimAutomation.Core
Initialize-VIToolkitEnvironment.ps1

$vcserver="vmm01.web.com"
$portvc="443"
$user="prod\jlangley"
$password="MyPassword"

connect-VIServer $vcserver -port $portvc -User $user -Password $password -WarningAction SilentlyContinue

$clusterName = "WEB ESX Cluster 01"
$report = @()

$cluster = Get-Cluster -Name $clusterName | Get-View
$clusterCPU = $cluster.Summary.EffectiveCpu
$clusterMem = $cluster.Summary.EffectiveMemory # In Mb

$from = (get-date).AddDays(-1).Date
$to = $from.AddDays(1).AddMinutes(-1)


Get-Cluster | % {
$clusterName = $_.Name
$_ | Get-VM | % {
# 30/120/1 day
$cpu = $_ | Get-Stat -Stat cpu.usagemhz.average -IntervalMins 120 -Start $from -Finish $to
$mem = $_ | Get-Stat -Stat mem.consumed.average -IntervalMins 120 -Start $from -Finish $to # In Kb


for($i=0; $i -lt $mem.Count; $i++){
$row = "" | select VM, Timestamp, CPUperc, Memperc
$row.VM = $cpu[$i].Entity.Name
$row.Timestamp = $cpu[$i].Timestamp
$row.CPUperc = "{0:N2}" -f ($cpu[$i].Value / $clusterCPU * 100)
$row.Memperc = "{0:N4}" -f ($mem[$i].Value / $clusterMem * 100 / 1Kb)

$conn = New-Object System.Data.SqlClient.SqlConnection
$conn.ConnectionString = "Server=DB200\DW01;Database=PERF_WEB;Integrated Security=False;UID=stats;Password=MyPassword"
$cmd = New-Object System.Data.SqlClient.SqlCommand
$cmd.CommandTimeout = 60

$conn.Open()
$cmd.Connection = $conn

$cmd.CommandText ="INSERT VMClusterCounterData VALUES (@MachineName, @CounterDateTime, @CPUPerCluster, @MemPerCluster)"

$vmParam = $cmd.CreateParameter()
$vmParam.ParameterName = "@MachineName";
$vmParam.Value = $row.VM
$cmd.Parameters.Add($vmParam)

$timestampParam = $cmd.CreateParameter()
$timestampParam.ParameterName = "@CounterDateTime";
$timestampParam.Value = $row.Timestamp
$cmd.Parameters.Add($timestampParam)

$cpuParam = $cmd.CreateParameter()
$cpuParam.ParameterName = "@CPUPerCluster";
$cpuParam.Value = $row.CPUperc
$cmd.Parameters.Add($cpuParam)

$memParam = $cmd.CreateParameter()
$memParam.ParameterName = "MemPerCluster";
$memParam.Value = $row.Memperc
$cmd.Parameters.Add($memParam)

#execute query
$cmd.ExecuteNonQuery()

#close connection
$conn.Close()
}
}
}

disconnect-viserver -confirm:$false

August 4, 2009

Portable Powershell

I just came across this on the powershell blog. I have been waiting for someone to come out with this! Quote from the site:

Portable PowerShell is software that allows you to run PowerShell on machines that don’t have PowerShell installed that you can run from a Machine that doesn’t have PowerShell on it, from a USB stick, on a machine that has a different version of PowerShell, a preinstall environment like BartPE, or WinPE or when booted to a windows 7 recovery DVD.

Go here to learn more.

August 3, 2009

LogParser TSV and C#

Someone asked me how to get TSV format using C#. Here is an example:
COMTSVInputContextClassClass input = LogParserOptions.CreateTSVInputFormat();

input.iCheckpoint = "Test.checkpoint";
input.nSkipLines = 5;
input.headerRow = false;
input.iSeparator = " ";
input.nSep = 3;
input.dtLines = 0;
input.codepage = -1;

return RunScript(scriptName, input);

//You will have to create a List of columns List or some option like this...this is what my RunScript looks like
public MyRecords RunScript(string queryName, object inputFormat)
{
return RunScript(queryName, null, inputFormat);
}

August 2, 2009

Are you a pattern person?

This is more of a question, since I am very curious. We all use patterns daily in our development when needed. However, do you hunt for patterns just to implement them in your project?