Saturday, August 23, 2008
 #
 

So being the greenie that I am, I looked into the Austin Energy rebate program for solar power.  They offer a compelling rebate of $13,500 a year for every solar system you install on your residence.  The cool part is that their fiscal year ends September 31st, so you can apply for the 2008 and 2009 rebates within a 60 day time span and do 2 installs to get both rebates.  I'm working with a vendor called Solar Community.  They're local to Austin and have installed nearly 100 systems so far.  The remaining balance for the install after rebate can be paid for by a 5 year loan who's payments are about equal to the energy savings provided each month by the solar panels.  So it should pay for itself, and after the loan is gone, you're making money.

I will post images as the install occurs.  They should start work on it in the second week of September.

Saturday, August 23, 2008 4:23:18 PM (Central Standard Time, UTC-06:00)
 Saturday, June 28, 2008

This little bit of usefulness in powershell is also available in various guides and books, but I often find that technical documentation is written to be more complete than practical.  I will scan a long document full of reference data to assemble what I need to do which can really be communicated in a simple example.  So here's a few easy ways to check to see if a registry entry exists or to look up a value.  These are really handy for testing and auto configuring machines on your network.

# The Test-Path cmdlet is handy for detecting not only if files exist in the file system, 
# but reg key entries as well
#
# $QuickLog will get a $true or $false
#
$QuickLog=(Test-Path 'HKCU:\Software\JQL - www.jql.co.uk\Quick Log')
 
# This returns an array of all the values at this key
$regObj = get-item 'HKCU:\Software\JQL - www.jql.co.uk\Quick Log'
 
# This is a path for using with set-ItemProperty
$path = 'HKCU:\Software\JQL - www.jql.co.uk\Quick Log'
 
# Notice we use the object here
$keys = $regObj.GetValueNames()
foreach($key in $keys)
{
    # Do what you will with your reg keys
    if($key.Contains("Hints"))
    {
        # Set the execution policy so we can write here
        set-itemproperty -Path $path -Name ExecutionPolicy -Value unrestricted
        
        # This assumes you have a String property
        # Notice that we use the path and not the object here
        set-itemproperty -path $path -name $key -value 0
    }
}
Saturday, June 28, 2008 1:26:11 PM (Central Standard Time, UTC-06:00)
Oh this is hilarious.  I'm playing with Google AdSense on my blog and it being a new generator, it has decided to place ads for black singles based on my last name.  Now that's entertaining.  I'm curious to see if they will hone in on something more appropriate, so bear with my experimentation here.

Saturday, June 28, 2008 12:35:58 PM (Central Standard Time, UTC-06:00)
 Monday, June 16, 2008

I've been looking all over trying to find a smart way to create nested XML in powershell, and after combining a few sources I have come up with something that works pretty well.  Now I don't recommend actually doing it this way unless you have to.  This is a fairly laborious process that I'm undertaking only because my particular situation requires that I do not use compiled code.  A C# object model using the Linq XML serializer is far easier, consistent, and less prone to bugs than this.  However sometime you just have to write a hack.

# Create the results file
$output = $args[0] + "\results.xml"
$outxml = New-Object "System.Xml.XmlDocument"
$outxml.LoadXml("<?xml version=`"1.0`" encoding=`"utf-8`"?><Results xmlns:xsi=`"http://www.w3.org/2001/XMLSchema-instance`" xmlns:xsd=`"http://www.w3.org/2001/XMLSchema`"></Results>")
 
# Tests
$elem = $outxml.CreateElement("Tests")
$outxml.get_ChildNodes().Item(1).AppendChild($elem)
 
# Test
$elem = $outxml.CreateElement("Test")
$elem.SetAttribute("xsi:type","MemoryTest")
$outxml.SelectSingleNode("Results/Tests").AppendChild($elem)
 
# Name
$elem = $outxml.CreateElement("Name")
$elem.PSBase.InnerText = "Video"
$nsMgr = New-Object System.Xml.XmlNamespaceManager($outxml.get_NameTable())
$nsMgr.AddNamespace("type", "MemoryTest")
$outxml.SelectSingleNode("Results/Tests/Test", $nsMgr).AppendChild($elem)

 

Notice the use of the XmlNamespaceManager.  This allows you to have multiple Test nodes within Tests each with a different type.  This makes sure you can add elements to the right trees. 

Again, this is the grunt work of XML serialization that lots of programmers end up doing, but really shouldn't have to.  Go use the Linq serializer.

Monday, June 16, 2008 10:01:53 PM (Central Standard Time, UTC-06:00)
 Friday, May 23, 2008
This is a nice and short talk on the emergence of open source information, not just software, and how it is reshaping economies.  Even though everyone is pretty well used to the internet, at least in rich industrial nations, we are still in the very early stages of its development.  It's only been commercially available for 15 years.  There are some great ideas in this talk about where it might go and how it may impact industry.

Friday, May 23, 2008 1:14:05 AM (Central Standard Time, UTC-06:00)
 Wednesday, May 21, 2008

I just found this great new blog for efficient and power concious living.  Check it out.

http://www.metaefficient.com/

Wednesday, May 21, 2008 12:11:02 PM (Central Standard Time, UTC-06:00)
 Wednesday, May 14, 2008

So I've recently had the task of fetching some information out of system.nfo files to translate cryptic IDs numbers into human readable friendly names.  This is the thing that XML is supposed to excel at right?  Well you would think that task would be simple enough, and as it turns out it is.  However searching for this solution online proved to be difficult, so I'm going to retell my experience here in hopes that it might help anyone else with this problem out.

I started with what I thought was a nice elegant powershell script that would query the XML like a SQL DB and return my value.  Seems simple enough right?

$friendlyName = $sysinfo.MsInfo.Category.Category.Category.Data.DeviceName | where {$sysinfo.MsInfo.Category.Category.Category.Data.Device_ID -eq $global:deviceName}

 

This would work with normal XML where your content is inside the XML tags.  However the system.nfo file uses CDATA objects and many nests of categories so you have to go one step further.  Since I don't know which Category sub-tree my offending device or data might be in, I ended up grabbing all of the data objects that met my criteria and doing a breadth first search.  Sounds ugly compared to the one liner up there, but it actually works and don't take that long.  The following code is in powershell.  The key here is that handy get_innertext() method.  Your standard .Value or .Text won't cut it with CDATA.

# Open the associated .nfo file
$sysinfo_file = $global:computer_name + ".nfo"
$sysinfo_path = $global:computer_name + "\" + $sysinfo_file
[xml]$sysinfo = get-content $sysinfo_path
 
$nodeList1 = @($sysinfo.GetElementsByTagName("Device_Name"))
$nodeList2 = @($sysinfo.GetElementsByTagName("Device_ID"))
$nodeList3 = @($sysinfo.GetElementsByTagName("Manufacturer"))
 
$i = 0
foreach($node in $nodeList2)
{
    $deviceID = $nodeList2[$i].get_innertext()
    if($deviceID -eq $global:device_name)
    {
        $friendlyName = $nodeList1[$i].get_innertext()
        $deviceManuf = $nodeList3[$i].get_innertext()
    }
    $i++
}

The purpose of this handy little script is to look up a cryptic device ID and return a friendly manufacturers name.

Wednesday, May 14, 2008 11:20:06 AM (Central Standard Time, UTC-06:00)
 Thursday, April 17, 2008
Last night I actually sat down and watched part of the Democratic debate.  I was hoping for some engaging discussion about how to differentiate Hillary from Obama.  Instead it was a tabloid hash out.  The Washington Post was dead on with their assessment.  Instead of probing the candidates about how they would handle large issues that affect the future of the country like health care, the budget, Iraq, the falling dollar, immigration, and legislative gridlock, ABC decided to pander to the Enquirer crowd.  Most of what I could stand to watch was arguing over sound bites, who said what about whom, who was electable, and which friend of yours said something nasty about the other side.  All of it useless and mostly irrelevant to how each potential leader would handle the future of this country.

However, there is a ray of hope, at least spoken about by some.  Tim Robbins' speech at the National Association of Broadcasters meeting in Las Vegas this month offers a compelling vision, which is at the heart of why networks run debates like a high school lunch room instead of a forum for deciding the future of the American nation.  The speech was considered highly controversial.  After listening to it, the fact that it was considered controversial is at the root of the problem.

So instead of complaining, create, make something good for others to be inspired by.  The above is certainly my share of complaint, and Tim's speech is in my opinion something to be inspired by.

Thursday, April 17, 2008 8:40:36 AM (Central Standard Time, UTC-06:00)
 Saturday, April 12, 2008

Got this off the Drudge Report this morning.  It's more writing on the wall, but it sets the context very well for what is coming.  There's no need to fight it, so we'd better get used to embracing China as the world's next super power.  Let's just hope it's a peaceful transition.  Their rise is affecting manufacturing job markets the most right now.  Software and IT services still hold an edge in experience because kids getting out of Chinese universities just haven't shipped software yet.  This will change though.  Right now most companies have a hard time getting the value out of overseas development houses that cost less.  I suspect the US and Silicon Valley have maybe 15 to 20 years before anyone working in those markets can be easily outsourced to very reliable, highly experienced developers in China or India.  So save up now, and start looking for property in less expensive regions where your VISA is valid, and the money you save now will go further, as income pressure for American IT workers will force real wages lower.

Saturday, April 12, 2008 12:18:23 PM (Central Standard Time, UTC-06:00)