especially when it's drivetrain swapout time of year on the foulweather commuter bike.
the mental meanderings of a nerd in the twin cities who has a family and a bike and some other stuff...
04 March, 2012
02 March, 2012
craziest tulip bouquet ever
bought some flowers for my wife last week and i think i left too much stem for the vase. they've been striking crazy poses all week.
28 February, 2012
frozen buckles
made it home in a winter rainstorm with dry and warm feet (thanks to the geniuses at endura and the sock scientists at smartwool). by the time i made it home, i was coated with ice. here's the buckle of my bag waiting to thaw so i can get my computer out of my nicely waterproof r.e.load bag.
25 February, 2012
17 February, 2012
04 February, 2012
frosty morning
02 February, 2012
01 February, 2012
21 January, 2012
macvim dev env update
as i've been watching grails webcasts like bobby warner's jump into grails 2.0, i've been a little jealous of textmate's ability to "find files." so i started searching for a vim plugin to do the same and found command-t. it's pretty cool. as i've mentioned before, i've been doing a few things with keymappings to make macvim act the way my fingers need it to work. i had to add a little magic to my .gvimrc to make it work for me.
macmenu &File.New\ Tab key=<nop> map <D-t> :CommandT<cr>
now, command + t enables the file finding feature of the command-t plugin.
20 January, 2012
plowed bike path
wow, snowed this afternoon and the city of roseville had the bike paths plowed by tthe time i rode home. those are MY tax dollars at work.
19 January, 2012
18 January, 2012
have a ball
of soup! literally, a ball of soup! my frozen soup thawed from outside in, leaving a baseball-sized frozen chunk in my bowl.
17 January, 2012
keymappings for mac vim
thought i'd share... i hate the goddamn keymapping of command+W closing mac vim. i can't seem to get my fingers to actually use control + W + [h,j,k,l] when i want to move to a different pane in vim on the mac, so i have a tendency to hit command + W, which has horrible consequences in mac vim. ugh! anyway, after digging around i found info on how to remap some keys. i now have remapped all my vim pane navigations in mac vim by adding the following to my .gvim file:
if has("gui_macvim")
macmenu &File.Close\ Window key=
macmenu &File.Close key=
nnoremap <D-w>h <C-W>h
inoremap <D-w>h <C-W>h
nnoremap <D-w>l <C-W>l
inoremap <D-w>l <C-W>l
nnoremap <D-w>j <C-W>j
inoremap <D-w>j <C-W>j
nnoremap <D-w>k <C-W>k
inoremap <D-w>k <C-W>k
endif
so, i guess you want this in a .gvim file because .vim file options are loaded first and macvim then puts all of its mappings on top of that. if you add these to .gvim they are preserved.
my understanding of how i needed to put this in the .gvim file as opposed to the .vim file came from this posting on superuser.com.
14 January, 2012
08 January, 2012
fried egg sandwich topped with black bean chili and cheese
when i said what i was making, my wife asked, "are you pregnant?"
the dog asked, "can i have some?"
it was great
26 December, 2011
running a simple rails app (like wagn) with ubuntu upstart
I had a hell of a time getting my upstart script to start. It kept launching, reporting that it started and even showing a pid, but it would die. This was a version of the same script I had written in a shell script and it would execute just fine. The addition of the export HOME, suddenly made things come together.
I'd been chasing the various values in the expect stanza, but nothing made sense. Once I had the HOME export in place, I was able to find the right setting for the expect stanza after a couple of tries.
Anyway, I wanted to run a very simple rails app, called wagn, as an internal tool on an internal server. In the event that our box goes down, I want wagn to restart. Furthermore, I don't have a bunch of time to muck about with all of those full-on production ways of deploying ruby, so I went looking for the best way to run this on the platform I had in front of me. I found out the new way of running services on ubuntu is through upstart.
After looking through a bunch of things on upstart:
I found a hint... well, something I hadn't tried yet. Anyway, upstart seems to need a HOME var set when you execute. So, if you've been searching, here's a good example to go on if you want to run a rails server with upstart. You can create something similar to the following in /etc/init/servicename.conf. If you are using it specifically for wagn, edit my path below to match your install location for wagn.
# example script offered with NO WARRANTY. # feel free to use it or just learn from it # wagn-server - wagn-server job file description "wagn server" author "robert tomb" # restart process if crashed try 10 times every 5 seconds respawn respawn limit 10 5 # let upstart know the process will detach expect daemon # When to start the service start on runlevel [234] # When to stop the service stop on runlevel [016] # don't know why but home=root is necessary # found it here: http://kevin.vanzonneveld.net/techblog/article/run_nodejs_as_a_service_on_ubuntu_karmic/ script export HOME="/root" exec /usr/local/wiki/wagn-1.7.0/script/server -b 192.168.1.54 -e production -p 3000 -d > /var/log/wagn.log 2>&1 end script
24 December, 2011
the squashes are stuffed
and placed in the baking dish with care...
we're hosting christmas for t's family and she asked me to make little stuffed squash for everyone. the rice, honey, butter, raisins, craisins, cashews, cloves, cinnamon, and nutmeg have been mixed and the squashes are ready to go in the oven.
--rt
14 December, 2011
Hate bat scripting? Me too...
Abstract
Hate BAT files? Yeah, so do I. Stuck on windows for reasons beyond your control but need to do some scripting? Sure, you can use perl, ruby, python or jruby, but all of those require the installation of an interpreter.
How do you survive if you have a bare-metal windows box and aren't allowed to dictate prerequisites? You could fall back on bat scripting and risk the integrity of your hairline or you could fall back on your JavaScripting skills and go against the WSH.
I'll show you a couple of minor examples in a JS coding idiom that makes sense to me and share as many of the references as I remember that helped me with my code. Lastly, I'll give a few suggestions as to where this can be used. Hopefully, this will be enough to spur your imagination to use JavaScript solve problems you have on the windows platform.
Windows Scripting Host
Here's your goto microsoft site for this http://msdn.microsoft.com/en-us/library/9bbdkx3k.aspx . This site is going to give you all of the conceptual stuff you need to know about this. I'll talk about some things I had to reconcile and give you a codesample walkthrough.
Executing your scripts
- just execute a js script from the cmd line
jsmn_all.js - execute it from the command line with cscript
cscript /Nologo jsmn_all.js - create a .wsf file to define and execute it with cscript
cscript /Nologo jsmn.wsf - or just execute your wsf file from the command line
jsmn.wsf
Go here for info on wsh files. Basically, they offer the ability to define a script and do imports, similar to what you do in an html file with
I'm not going to get too far ahead of my self decomposing this entire script. Suffice it to say that this allows you to connect to jsmn.js and use things in it, such as the ScriptHelper object. Objects that are part of the windws scripting host, e.g., the WScript object are going to be in your execution scope no matter what, so there's no need to root around for some WSH javascript file to "include."
You can have multiple script references, but I don't know the limitations. You can even have your script entry point in one of the referenced scripts. I can see where it might make better sense (and make your editor of choice happier) if you put all logic in a js file and only used hour WSH file like a project file.
What can you do with this here WSH thingy?
Good question. Well, I have a progressive "hello jsmn" demo for you that might help to enlighten. You'll really have to dig through the Microsoft pages to see all that you can do. You can even use this to wrap windows commandline commands.
I see it as a great way to drop a toolkit onto a bare metal windows box and make yourself productive. Seems like something that could be very powerful for sysadmins or testing engineers especially for windows VMs.
Oh yeah, the demo
Running just this with no Arguments yields a dialog box with:Needs two arguments: one to specifiy the subject and another for desired action. Here's the ScriptHelper class we instantiate and call methods from:
/*
* Class for grouping functions that are important to this script.
*/
function ScriptHelper(word1,word2) {
this.desktopiconfolder = "";
this.envname = "jsmn";
this.write_script;
this.fullFileName = WScript.ScriptFullName;
this.wshShell = WScript.CreateObject("WScript.Shell");
this.objFSO = WScript.CreateObject("Scripting.FileSystemObject");
this.wordOne = word1;
this.wordTwo = word2;
this.speak = function() {
WScript.echo(this.wordOne + " " + this.wordTwo);
}
}
I'd like to do something slightly more sophisticated than just echo some crap out
So, let's write to a file. I'll add a speakToFile function to my ScriptHelper class
this.speakToFile = function(loc) {
this.write_script = loc;
var filelocation = loc;
if ( this.objFSO.fileExists(filelocation) ) {
this.objFSO.moveFile(filelocation,filelocation + ".bak");
}
var ForWriting = 2;
propFile = this.objFSO.OpenTextFile(filelocation,ForWriting,true);
propFile.WriteLine("WScript.echo('from file:" + this.wordOne + " " + this.wordTwo + "');");
propFile.Close();
}
and tell my WSF file to call that instead of speak.
Now, when I run
jsmn.wsf hellooooo jsmnit writes a file to disk called jsmn_write.js. This file contains one line of javascript and if I execute jsmn_write.js, I'll see
"hellooooo jsmn"
So, I can write a file, what else?
There's all sorts of windowsey stuff you can do like write shortcuts... So, I add a call to a createShortcuts() method
And, this takes a few more methods to support it, but I add the following methods to ScriptHelper
this.createShortcuts = function() {
this.createShortcutFolder("Shortcuts for " + this.envname);
this.createShortcut("TestShortcutFor-" +
this.envname,this.getScriptDir()+"\\"+this.write_script,this.env
name);
};
this.createShortcutFolder = function(name) {
var desktop = this.wshShell.SpecialFolders("Desktop");
this.desktopiconfolder = desktop + "\\" + name;
this.objFSO.CreateFolder(this.desktopiconfolder);
};this.getScriptDir = function() {
var forShortening = this.fullFileName;
var lastSlash = forShortening.lastIndexOf("\\");
var shortened = forShortening.substring(0,lastSlash);
return shortened;
};
this.createShortcut = function(linkName,tgtPath,args) {
var myShort = this.wshShell.CreateShortcut(this.desktopiconfolder +
"\\"+linkName+".lnk");
myShort.WindowStyle = 1;
myShort.TargetPath = tgtPath;
myShort.Arguments = args;
myShort.Save();
};Now when I run
jsmn.wsf hellooooo jsmn
I get a shortcut folder on my desktop with a shortcut in it that has a link to jsmn_write.js. That's it for my demo, I hope it was simple enough to follow but sophisticated enough to give you some ideas for new ways to use your javascripting skillz.
Debugging?
cscript has an option for a debugger, but I have not successfully used it.
//X Execute script in debugger
NOTE: I will research this further and update or write a new entry on this
Soo... What else is possible?
Unit testing is pretty cool and if you're developing some sort of a toolkit with WSH scripts, you might want to be able to build them with TDD or just have some tests to prove that your code doesn't toally suck. I have not tried either of these, but they look very promising:
The next time someone tells you that JS is a toy language and you can't do anything with it, you can tell them to kiss your asterisk.
Acknowledgements
Also, this post uses the awesome syntax highlighter from alex gorbatchev it's some pretty cool javascripting in its own right.
25 November, 2011
24 November, 2011
be sure to look for our results when they're posted
getting up early to run the turkey day 5k as a family. i can't wait until they post the race resultz. lookz likez we're all winnerz.
19 November, 2011
my 2011 mn cx championships experience
anyway, b, my youngest daughter came along and snapped a few photos of me. here's my story:
in the staging area at the start, i'm chatting it up with, what i believe to be the only other single-speeder in the race. we ended up battling it out for a couple of laps, but i eventually pulled away from him.
getting ready to grind up the hill... this is a mean course because right in the middle of the hill they send you on a zig zag that steals any momentum you thought you had.
just past said zig-zag!
the course loops around and here i get to go down the hill i'd fought my way up only just 1/3 of a lap before.
and then there's the stairs. these classic stairs have become a mn cyclo-cross tradition.
the stairs on another lap.
and... i'm done. this was a fun day AND i completed my race before the snow fell. the experts will be cranking through an epicly snowy state championships for the second year in a row. thanks to @smithersmpls and his promotion and setup teams for putting on this race. it's an awesome event.
playing with gimp cx photo
17 November, 2011
15 November, 2011
lather, rinse, repeat
since getting the job, i've experienced a number of up and down days. the days running up to agile day were some real down ones, and i was feeling quite isolated. i have some customer issues on my desk that are keeping me from implementing the infrastructure we need to get this shop running smoothly.
anyway, agile day was kicked off by a video address by ward cunningham download it here. in it, he makes some great suggestions that have already affected what i'm doing and how i feel about heading to the office.
- programmers are at their best when the help others succeed
- put the top list of things out there for the team to accomplish, together
- work from the known to the unknown
- when you have a good idea, you have to put it into code or else you're wasting the good idea

































