Hits:

Blog Archive

Monday, May 14, 2012

Walk DOM and report ID's and Parents

function walkReport() {
$("body").find("*").andSelf().each(function() {
    var parent = $(this).parent().attr("id");
    console.log(this.nodeName+" "+this.id+" and my parent is "+parent);   
});
}

Sunday, May 6, 2012

One Wire On Fire 1-Wire Automation Management Tool

This is a project I'm designing and coding. Far from done as of this post, but I hope to have it reasonably functional by July 2012.

Python: Error Handling

import traceback
def formatExceptionInfo(maxTBlevel=5):
         cla, exc, trbk = sys.exc_info()
         excName = cla.__name__
         try:
             excArgs = exc.__dict__["args"]
         except KeyError:
             excArgs = ""
         excTb = traceback.format_tb(trbk, maxTBlevel)
         return (excName, excArgs, excTb)

try:
         x = x + 1
except:
         print formatExceptionInfo()

Thursday, May 3, 2012

Python: Kill Self

import os
def properExit():
 os.system('kill %d' % os.getpid())

Wednesday, May 2, 2012

my .vimrc

syntax off
set number
set columns=120
set ruler

Friday, April 13, 2012

Basic ssh login script

#!/usr/bin/env bash
ip="127.0.0.1";
u="joe";
p="2222"
webport="8080";
while true;
do
echo "http://$ip:$webport":
echo "ssh -p $p $u@$ip";
read -p "press enter";
ssh -p $p $u@$ip;
done

Tuesday, March 20, 2012

Create an associative array in PHP

Some of you may dislike the distraction of a full set of working code with core lesson of associative arrays buried in it. Their are plenty of minimalist examples on the web, and when I wanted an example they were too minimalist. Core code for reference is in this color scheme.

deviceNickNames.txt
10.AF2551010800|no nickname
22.20F21A000000|no nickname
22.650E1B000000|no nickname
29.A29F09000000|no nickname
$deviceNickNamesTxt = "deviceNickNames.txt";
 if (file_exists($deviceNickNamesTxt)) {  
     $lines=explode("\n", file_get_contents($deviceNickNamesTxt)); 
       foreach($lines as $line) { 
                                 $items=explode("|",$line);
                          if(isset($items[1])) { $devicesB[$items[0]]= $items[1]; } 
                    }
                                     }

print "\n<form name=\"setupForm\" action=\"\" method=\"GET\">\n<table>\n<tr><th>Device Hardcoded Name</th><th>Human Friendly Name</th></tr>\n";
foreach($devicesB as $name => $value) {
print "\n<tr>";
print "\n<td valign=\"center\" align=\"center\">".$name."</td>";
print "\n<td valign=\"center\" align=\"center\">\n";
inputText($name."_NAME", $value, "");
submit("");
print "</td>\n</tr>\n";
    }
print "\n</table>\n</form>\n"
Device Hardcoded NameHuman Friendly Name
10.AF2551010800
22.20F21A000000
22.650E1B000000
29.A29F09000000