Tag Cloud
Monday
Jul272009

## Maker's vs. Manager's Schedule

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

Monday
Jul272009

## 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 'https://someserver.com:443': - The certificate is not issued by a trusted authority. Use the fingerprint to validate the certificate manually! Certificate information:   - Hostname: someserver.com   - 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 (https://someserver.com)

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.

@echo Running from postcommit hook! >> C:\sync_serverupdatessvn.log 2>&1call 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.

Thursday
Jun182009

## 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.

http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=14004&jump=true#M14004

Wednesday
May202009

## 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. Example: 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. Thursday Oct232008 ## 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: http://www.national.com/ds/LM/LM2678.pdf (see Inductor Section) Tuesday May202008 ## 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.

Monday
Feb052007

## 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>
[Category("Appearance")]
[DescriptionAttribute("Defines the label text that appears under the control.")]
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>
[Category("Appearance")]
[DescriptionAttribute("Defines the label text that appears under the control.")]
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>
[Category("Appearance")]
[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.
Sunday
Oct292006

## 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.

Friday
Oct202006

## 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 someproduct.zip but i wanted something todo someproduct-v2.x.x.zip.

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 2.1.95.0 and based on that you wanted
' to rename testPackage.zip to testPackage-v2.1.95.0"
'
' To do so, then set:
'    versionedFilePath = "test.exe"
'    nonversionedFilename = "testPackage.zip"
'
' REQUIREMENTS: the original filename cannot have more then one '.' in it.'
Dim versionedFilePath, nonversionedFilename, seperator

'### CUSTOMIZE THE FOLLOWING 3 LINES ###
versionedFilePath = "c:\path\to\exe"
nonversionedFilename = "c:\path\to\nonversioned\file.zip"
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”)


### 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.

Wednesday
Oct182006

## 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
</Directory>
— Apache 2.2.x
Page 1 ... 1 2 3 4 5