Follow Me On...

Maker's vs. Manager's Schedule

Nice article which articulates the reason why meeting’s are so painful for developers.


Workaround for post-commit.bat failing to svnsync due to ssl certificate. 


My company has it’s svn server on a windows box which makes things like 30x more of a pain.  We use svnsync to synchronize a local repo with a repo one. 

Adding a post-commit.bat to call svnsync failed because it would hang waiting for user input to accept the SSL Certificate.

Error validating server certificate for '': 
- The certificate is not issued by a trusted authority.
Use the fingerprint to validate the certificate manually!
Certificate information:
- Hostname:
- Valid: from Tue, 09 Dec 2008 01:49:41 GMT until Sun, 09 Jan 2011 01:49:41 GMT
- Issuer: Equifax Secure Inc., US
- Fingerprint: b1:4e:2d:b8:7f:27:96:ba:21:ef:46:fc:12:43:b5:4c:83:3b:dd:b9
(R)eject, accept (t)emporarily or accept (p)ermanently? svnsync: PROPFIND request failed on '/somefolder'
svnsync: PROPFIND of '/somefolder': Server certificate verification failed: issuer is not trusted

When svnsync was being run from post-commit it was being run as some system user which hasn’t already accepted the certificate to have it in it’s certificate store.  I began looking into how I would add it when I realized that I had a scheduled task for which I could specify the user to run as.  So, the simple solution is… create a scheduled task which invokes svnsync. 

Then add to your post-commit.bat

@echo Running from postcommit hook! >> C:\sync_serverupdatessvn.log 2>&1
call SCHTASKS /Run /TN >> C:\sync_serverupdatessvn.log 2>&1

Just replace <YOURTASKNAME> with the name you gave to your scheduled task you created.  You’ll also probably want to update the logfile name and path.




Creating a VisualForce email template which invokes an Apex Class.

Recently, I created my first “VisualForce” email template.  I found that lots of the documentation for VisualForce for when you were creating “Pages” and not “Email Templates.”

See my solution outlined here for a basic tutorial on how to create a visualforce template which needs to access Apex controllers and Apex classes to perform basic math operations etc.


Using RegEx to comment out log statements cleanly.

I needed to optimize my code space usage on a recent embedded project. I wanted to estimate how much space was being used by my various print statements. In my project I have debug, info, warn, error level print statements.  I used the regex below to find each of the statements and  was able to find all statements, comment them out, and rebuild my project to see
how much space each log level used.

Find: (^\s*)((info)\S*\(.*)
Replace: $1;//CSOPT_$3 $2
File Types: *.c <—- important otherwise you could update header files or .txt files.

    infoln(“some info statement”);    —- BECOMES —->
    ;//CSOPT_info infoln(“some info statement”);

To use this regex you replace the “info” text with the command prefix you want to replace. It also will find things like infoln.  You may be wondering why the replace expression looks so complicated…

  • For one, you do not need to edit each replace statement for each find.
  • It maintains whitespace properly.
  • The reason for the ; in replace is to prevent issues where you had a if statements without brackets… the next statement isn’t what you meant for it to be.

To reenable your statements all you have to do is search for “//CSOPT_info ” (to replace one log type ata time) or “//CSOPT_\S+\s” (to replace all at once) and leave the replace box blank.

One issue you may encounter is if you have print statements which extend on to multiple lines… these you will either need to combine into one line or handle specially. Since these always create a compile error it’s not a big deal.



Inductor Core Type Tradeoffs

I found the following summary of the design tradeoffs imposed by inductor core type useful.  I hope this helps someone else try to figure out whether they want a ferrite core or a toroid core.

“Renco: ferrite stick core inductors; benefits are typically lowest
cost and can withstand ripple and transient peak currents
above the rated value. These inductors have an external
magnetic field, which may generate EMI.

Pulse Engineering: powdered iron toroid core inductors;
these also can withstand higher than rated currents and, being
toroid inductors, will have low EMI.

Coilcraft: ferrite drum core inductors; these are the smallest
physical size inductors and are available only as surface
mount components. These inductors also generate EMI but
less than stick inductors.”

Source: (see Inductor Section)


Eclipse RegEx Syntax & Capture Groups

Capture groups can be used to do the following:

Search Text: Blake Robertson
Find RegEx: (.*) (.*)
Replace RegEx: $2 $1
will change the text to: Robertson Blake
The $1 in the Replace RegEx matches to the first (.*) in the find expression and the $2 matches the second (.*)

More practical example… in my code i had a bunch of log statements like debug(“hello world\r\n”);  I was running low on program space in my PIC microprocessor and decided to replace them all with something like debugln(“hello world”); which saves us a whopping two bytes. 

If you want to replace a portion of line of code and you want to keep the actual print statement (the hello world part) you have to use a capture group.

Here’s the first regular expression i came up with:

FIND: debug\(\"(.*)\\r\\n"\);
REPLACE: debugln\(\"$1\"\);

This works and illustrates that whatever was originally in the (.*) will be inserted into the replacement string where the $1 is.

Here is the final FIND, REPLACE combo i came up with which would also work with a string which has additional printf style arguments and optional whitespace in various parts of the expression such as:
debug( “sum = %u\r\n”, x ) ;

FIND: debug\(\s*\"(.*)\\r\\n\"(.*)\)\s*;
REPLACE: debugln\(\"$1\"$2\);

Note: my replace expression eliminates any of the white space that was matched in the FIND expression. 



C# User Control Properties

Below are a few examples of how to define public properties that will show up in the Property Editor for a user control when selected in the Designer View. Basically, you define a setter and getter and then add the Category, Description, and DefaultValue tags.

        /// <summary>
        /// Gets or sets progress indicator text label.
        /// </summary>
        [DescriptionAttribute("Defines the label text that appears under the control.")]
        [DefaultValue(typeof(string), "Please Wait...")]
        public string LabelText
            get { return label1.Text; }
            set { label1.Text = value; }

The example below overrides the default Text Property.

        /// <summary>
        /// Gets or sets progress indicator text label.
        /// </summary>
        [DescriptionAttribute("Defines the label text that appears under the control.")]
        [DefaultValue(typeof(string), "Please Wait...")]
        public override string Text
            get { return label1.Text; }
            set { label1.Text = value; }

An example for defining a color property.

        /// <summary>
        /// Gets or sets the BackColor of this control.
        /// </summary>
        [DescriptionAttribute("Sets the background color")]
        [DefaultValue(typeof(System.Drawing.Color), "Transparent")]
        public override System.Drawing.Color BackColor
            get { return this.BackColor; }
            set { this.BackColor = value; }

Other Notes:

  • I experimented with specifiying a custom category such as “MyAppearance” and when i did so the properties didn’t show up.
  • You have to do rebuild your solution in order to make the new user control properties show up.

Java Packaging / Deployment Tools I Recently Came Across

These tools essentially take a jar and output a exe.  One of the things i hated about Java was if i created a simple utility which consisted of a single class (or jar) i still had to create a bat file which invoked the jre.  The end result being two files cluttering up my util bin folder on my computer.  These utilities take care of that and do a lot more like finding  appropriate jre and providing error messages to inform the user what they need to do.

  • jsmooth simple to use.
  • launch4j has a lot more features.

    Both are open source.

Another tool i came across but haven’t downloaded or tried yet is
IzPack  C which is a cross platform Installer written in Java.


VBS Script Code for File Versions

I had written build scripts for various products and the end result is typically some archive file (zip,msi,iso). My build scripts would create a file such as but i wanted something todo

That’s what the script below does.

' Author: Blake Robertson (10-21-06)
' This script gets the file version of a particular file.  
' It then renames (or copies) the file with a versioned suffix.
' Example: say test.EXE had a version of and based on that you wanted
' to rename to testPackage-v2.1.95.0"
' To do so, then set:
'    versionedFilePath = "test.exe"
'    nonversionedFilename = ""
' REQUIREMENTS: the original filename cannot have more then one '.' in it.' 
Dim versionedFilePath, nonversionedFilename, seperator

versionedFilePath = "c:\path\to\exe"
nonversionedFilename = "c:\path\to\nonversioned\"
seperator = "-v"

Dim verStr, versionedFileName, filenameArr
Set FS = CreateObject("Scripting.FileSystemObject")
verStr = FS.GetFileVersion( versionedFilePath )

' Seperates filename from file extention
filenameArr = Split( nonversionedFilename, "." )

versionedFileName = filenameArr(0) & seperator & verStr & "." & filenameArr(1)

' Renames the Original File, if copy is desired then uncomment 2nd line and comment first
'FS.MoveFile nonVersionedFileName, versionedFileName
FS.CopyFile nonVersionedFileName, versionedFileName

If your project doesn’t create versioned executable files but you can obtain information from registry key or from a file, then replace the verStr = FS.GetFileVersion(…) line above with one of the snippets below:

Read Version Info in from a registry key:

verStr = WshShell.RegRead("HKLM\SOFTWARE\Your Company\Your Product\Version")

Snippet to read version info from a text file.

Set FS = CreateObject(“Scripting.FileSystemObject”)
verStr = FS.OpenTextFile(“version.txt”).ReadAll

Tip for SVN Users

If you are using SVN or some file versioning system, you can get version info by calling the update command twice. The second time redirect the output to a txt file. The second consecutive call to update will not update any files so the output should be just an informative version note.
svn update myCodeDir 
svn update myCodeDir > version.txt
type version.txt
At revision 342.

Apache2: Allowing Directory Listings for a Particular Directory

Assuming you haven’t modified the default httpd.conf <Directory> section for your webroot folder or done some else funky with permissions all you have to do is add the following lines somewhere in your httpd.conf.

<Directory “R:\webroot\some\subdirectory”>
   Options +Indexes
— Apache 2.2.x