Something new: Closure

Now that I’ve talked about Functions as first-class values and anonymous functions I can talk about closures. A closure retains the environment it was created in. This is a programming language feature that is nearly always associated with first-class functions. In fact, the two concepts are related, but distinct.

Consider this JavaScriptL

function getIncrementor() {
    var outerLocal = 0;
    return function(incrementBy) {
        outerLocal += incrementBy;

        return outerLocal;

var incrementor1 = getIncrementor();

var incrementor2 = getIncrementor();

incrementor1(1); // Produces 1
incrementor2(2); // Produces 2
incrementor1(3); // Produces 4
incrementor2(4); // Produces 6
incrementor1(5); // Produces 9
incrementor2(6); // Produces 12

Take a look at this example on


Leave a comment

Filed under Uncategorized

Something new: Anonymous function

An anonymous function is a function that has no name, or identifier. Functions must be first-class values for anonymous functions to exist. See my previous post about first-class functions for more details. Since an anonymous function has no identifier, it must be called using the variable or parameter it was assigned to.

A JavaScript example:

var funkeyVariable = function() {
    return "I am a first-class function.  Respect me!";

var anonymousFunctionReturned = funkeyVariable();
//  anonymousFunctionReturned == "I am a first-class function.  Respect me!";

Leave a comment

Filed under Uncategorized

Something new: First-class functions

First-class functions are functions you can use like a value. You can assign it to a variable and call it by using the variable like you would use a function. You can also pass First-class functions as parameters.¬†First-class value¬†actually means “an entity that can be passed as a parameter, returned from a subroutine, or assigned into a variable.” In every programming language I know strings are first-class values, for example.

A JavaScript example:

function freakyFunction() {
    return "I am a first-class function.  Respect me!";

var freakyVariable = freakyFunction; // Notice no parentheses...
//  freakyVariable == function freakyFunction() {
//      return "I am a first-class function.  Respect me!";
//  }

var freakyFunctionReturned = freakyVariable();
//  freakyFunctionReturned == "I am a first-class function.  Respect me!";

Leave a comment

Filed under Uncategorized


I’ve noticed the .NET Framework has a number of functions that start with ‘Try‘. I’ve come to like this pattern as a way to indicate a few things about a function.

* The function does something internally that could throw an exception.
* The function will never throw an exception itself.
* Failure is indicated by the Boolean return value.

I don’t think ‘Try‘ requires the function take a parameter by reference and return a value in that parameter like most of the TryParse methods do. Sometimes it’s nice to have a indicator that a method simply will never throw an exception.

So, for example:

public bool TryGetBanana(out Banana banana);
public bool TryEatBanana(Banana banana);

While TryGetBanana gets you a banana it will never throw the OutOfBananasException. And on the same note, while TryEatBanana takes a banana, it will never throw the BananaTooRipeException.

Leave a comment

Filed under Uncategorized

The value of IT certificates

My friend asked me “What certificates do you recommend I get for an IT job?” Since I’m not in IT, I had a conversation with the IT manager here and he gave me some great info, that I promptly relayed to my friend. Here’s the run-down for those interested.

Don’t bother with these:
* Microsoft Certified Professional (MCP): It doesn’t say anything specific about you.
* Linux+: It’s not in depth or useful.

These could be useful, depending on the role your looking for:
* A+: It’s very basic, but could help with an entry-level position.
* Network+: Again, very basic, but could help.

These are valuable and worth getting:
* Cisco Certified Network Associate Routing & Switching (CCNA)
* Red Hat Certified Engineer (RHCE)
* Red Hat Certified Architect (RHCA)
* Microsoft Certified Systems Engineer (MCSE)
* Microsoft Certified Systems Administrator (MCSA)
* Project Management Office (PMO)
* HP Certified System Administrator (CSA)
* HP Certified System Engineer (CSE)

Some additional advice:
* Don’t put your certificates after your name like a Ph.D would. Your not Jo Rock MCP. Your Jo Rock with an MCP.

1 Comment

Filed under Uncategorized

Get a SVN dump of an external repo without shell access

Here is a script that will run svnsync to pull in a local copy of a repo and then dump that local repo. It’s a good way to make a copy of a repo you don’t have admin access to.

Use –help to get usage and examples.

Special thanks to [ cournape] for his post [ Making a local mirror of a subversion repository: using svnsync].

[ Download here]

or Copy:



this_path=$( cd $( dirname "$0" ); pwd)
stamp=$( date "+%Y-%m-%d-%Hh%M-%S"; )

#hook_contents='exit 0'

hook_contents=$( cat <&2n
exit 1

function usage()
	echo usage: $( basename "$0" ) SOURCE_URL [DUMP_File]
	echo example: $( basename "$0" )
	echo example: $( basename "$0" )  PROJECT-trunk.dump
	return 0;

if [ -z "$source_repo" ]; then
	echo Source repository required.
	exit 1

if [ "$source_repo" == "--help" ]; then	usage; exit 1; fi
if [ "$source_repo" == "-h" ]; then usage; exit 1; fi

if [ -z "$dump" ]; then
	echo dumping to $dump

# This tells bash to exit if any command returns non-zero.
set -e

svnadmin create $sync_repo

#if [[ $? -ne 0 ]]; then  exit 1;  fi

echo $hook_contents > $hook_file

chmod +x $hook_file

echo svnsync init ...
echo You will now be prompted for the password to $source_repo
echo * Press 'enter' to clear the user name 'svnsync'
echo * type the user name, press enter
echo * type the password, press enter

svnsync init --username svnsync  $sync_url  $source_repo

echo Syncing...

svnsync sync $sync_url

echo Syncing again in case anything new came in during the previous sync.

svnsync sync $sync_url

echo Dumping...

svnadmin dump $sync_repo > $dump

echo All done.

Leave a comment

Filed under Uncategorized

[NSString stringWithFormat:…] wrapper

Here is some code to make a wrapper around [NSString stringWithFormat:…] to make using your objects easier, or whatever.

+ (NSString *)wrapperToMakeStringWithFormat:(NSString *)format, ...
    va_list args;
    va_start(args, format);
    NSString * string = [[[NSString  alloc]  initWithFormat:format  arguments:args]  autorelease];
    // Do something here with string.
    return string;

Leave a comment

Filed under Uncategorized