Everything about my daily life as a programmer/Electrical Engineer!

Where are the label's in the world.

This is much less a post of something cool I've done and much more a post about where are all the labels.  Google gave us labels for things like gmail and google docs right?  Sharepoint capitalized on the idea an added their own online labeling.  Vista lets you label a few types of files.  When will someone write a general purpose labeling system that can be used by all the cool new desktop search engines out there?


I'm waiting...........

Upward Bound Robots : A success


A while back I posted about building a cheap robot for a high school summer camp.  Well the camp is over and I think it was pretty successful.  I was able to build 9 robots for under $30 a piece.  Each robot used an Atmel Butterfly and cheap remote control car.  I will have more ongoing information about how these cars work and how to make your own, but for now enjoy the circle of bots :)



Where are the digital engineering notebooks?

I am a strong proponent of making everything in my life digital.  I own a tablet PC and spend most of my time working on engineering projects on the computer.  One thing that always drives me nuts is printing out stuff just to go into a engineering notebook.  First I'm waisting paper, second its not the write medium for an entire source code system.  Where are digital engineering notebooks? 

I propose that someone starts a company that is basically a limited access subversion repository ran by lawyers and IT specialist.  Client can use Tortoise SVN or the like to synch their directory changes to the server.  Someone can even have rules in place that require digital signatures before commits can happen.  If a patent dispute ever happens the company can show the directory in its state as of a certain disputed date.

What this gives you:

  • A way to backup your files
  • A clean medium for digital files like source code
  • Worry free notebook maintenance

The company could make a good deal of money charging for space and charging a lot of money for engineering audits. 


Well just a thought!

C# Code to cleanup Startmenu

I image my machine once a semester to clear off all the garbage I installed over the term. (I use partimage in case anyone cares).  Anyway I always have unsused shortcuts left in my startmenu since that lives on my d:\ drive which is where my data and profile are.  I wrote the code below to nuke bad shortcuts and empty shortcut directories.  It doesn't get all the uninstall files and readme links but its good enough!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using IWshRuntimeLibrary;

namespace ConsoleApplication12
class Program
static void Main(string[] args)
string path = @"D:\Michael\Start Menu\";

WshShell shell = new WshShell();
string[] files = Directory.GetFiles(path, "*.lnk", SearchOption.AllDirectories);
List<string> directories = new List<string>();
foreach (string file in files)
IWshShortcut link = shell.CreateShortcut(file) as IWshShortcut;
if (!System.IO.File.Exists(link.TargetPath))
Console.Write("Broken Shortcut");
System.IO.File.Copy(file, Path.Combine("C:\\oldshortcuts", Path.GetFileName(file)), true);
catch { Console.WriteLine("Error copying file and deleting file. Press any key to continue"); Console.ReadLine(); }
//now delete the old shortcuts
foreach (string dir in directories)
if (!Directory.Exists(dir)) { continue; }//we already deleted this!
DirectoryInfo info = new DirectoryInfo(dir);
if (info.GetFiles("*", SearchOption.AllDirectories).Length == 0)
Console.Write("Deleting directory");
catch { Console.WriteLine("Error Removing Directory. Press any key to continue"); Console.ReadLine(); }


Debugging in IronPythonStudio with PythonEngine

I was charged by the company I work for to add a code editor to our IronPython Application scripting engine. Originally the code editor was supposed to just be a friendly IDE.. but I wanted break points too. PythonStudio seemed like a good choice since it ships as a standalone application and can do Python breakpoints via our friend "the red dot" for break points.

Here is how it all goes together. First I created a class library in PythonStudio. I set a break point in PythonStudio so that my source looks like this.

The next thing I did was build a simple PythonEngine host in C#.

static void Main(string[] args)
EngineOptions eo = new EngineOptions();
eo.ClrDebuggingEnabled = true; //this is important! this turns on debugging!
PythonEngine pe = new PythonEngine(eo);
//create the class def from our code base
pe.ExecuteFile(@"D:\Michael\My Documents\IronPython Studio\ClassLibrary1\ClassLibrary1\Class.py");
Console.WriteLine("Please attach Python Studio if you want breakpoints :)");

You can see that I execute the python file from the directory that iron python studio placed its file. If you run this file in or out of debugging nothing happens. Why? Visual Studio doesn’t know about the breakpoints in your iron python studio project yet.

The final piece is attaching PythonStudio to the c# application where the python engine lives. To do this run the application without debugging.

Then in PythonStudio Attach PythonStudio to your c# application.

As you can see my project was called ConsoleApplication9.exe [Don’t we all love the visual studio generated project names]

Hit Enter in the command window once you have attached PythonStudio and watch your break point get hit!

Hit F5 and this will be your final output.

As you can see *most* of the work is done for you. All that is needed is delicate wiring of pieces and parts. Finally a way for us all to embed scripting that is more powerful than VBA and has a better editor than VBA.

IronPython Parser AST walker

I just thought I would post an example of an IronPython 1.1 parser for AST. You can override tons of methods on the ASTWalker class to get the job done.

Parser p=Parser.FromString(new IronPython.Runtime.SystemState(),new CompilerContext(),"a=5+10");
Statement e=p.ParseSingleStatement();
e.Walk(new ExpressionWalker());

public class ExpressionWalker : IronPython.Compiler.Ast.AstWalker
public override void PostWalk(NameExpression node)