Archive of articles classified as' "Uncategorized"

Back home

big – A Quick Shell/AppleScript/LaunchBar Script to Shout Results

2011/05/17

I threw together a quick shell script, called big that leverages AppleScript and LaunchBar to display results in a huge font.

Often, when I’m demoing something, the results of what I’m doing don’t really jump out at my audience.

If I really want to get a point across to someone it’s nice to be able to do it in a really big, clear font. Just up arrow/ctrl-p to get the last command and append “| big” to get this:

This script takes the results of anything you pipe to it and sends it to LaunchBar to display in a really big font. It get smaller the more text that you send to it, but starts at a ~200pt font.

#! /bin/bash
 
TMP_FILE=`mktemp /tmp/big.XXXXXX` || exit 1
cat - | head -20 > $TMP_FILE
 
osascript <<EOF
tell application "LaunchBar"
    display in large type (do shell script("cat $TMP_FILE"))
end tell
EOF
 
rm $TMP_FILE

It uses the head command to take only the first 20 lines, in case you’re trying to display something HUGE (which can kill LaunchBar if you feed it too much). Adjust the head command appropriately to cap big to more/less output.

1 Comment

Vim Movement Shortcuts Wallpaper

2010/10/4

I’ve recently moved back to vim (actually MacVim) after a 5 year hiatus using TextMate. A big part of that move was inspired by Steve Losh’s recent post Coming Home to Vim which has a number of really great tips.

I’ve cribbed many of them and have my .vimrc / .vim dotfiles checked into a public bitbucket repo.

There have been some big changes in the last 5 years since I’ve been away from vim (or else I just didn’t know what the hell I was doing, which is also possible). The addition of pathogen for plugin management makes configuration much easier. All plugins are completely contained in their own directory. You can try something out and if it doesn’t work, just delete the plugin’s directory to uninstall it.

NerdTree is nice, but PeepOpen‘s integration with MacVim for finding/opening files beats TextMate’s cmd-T hands down.

I tend to be a hands-on, visual learner, so I looked around for a nice wallpaper to help me learn and retain the panoply of vim movement commands, but all I was able to find were simple lists of commands, so I decided to whip my own version up.

It shows all of the default movement commands, each command is placed relative to the center of the image and are ordered based on how far your cursor will likely travel. All of these are active in vim’s “normal” mode (though I believe most if not all of them will also work in “visual” mode.

I also find it useful to set my MacVim window to be slightly transparent so that I can see the shortcuts through the window if I need to. In MacVim 7.3 you need to turn on the Advanced->”Use experimental renderer” option. Then you can “:set transp=20″ to make it 20% transparent (which feels right to me, but you might want to move it up/down depending on your preferences).

You can download the full size (1900×1200) (or 2560×1600) image for yourself.

Vim Shortcuts Wallpaper

I’ve also got the original OmniGraffle file that I used to create it checked in to a BitBucket repo if anyone feels like remixing it or adding their own shortcuts or customizations to it.

49 Comments

Grails Jasypt Encryption Plugin presentation at Groovy Users of Minnesota

2010/08/11

Last night I gave a presentation to the Groovy Users of Minnesota (GUM) group on the Grails Jasypt Encryption Plugin. It was well received and I was happy with the number of people that showed up on a hot summer night.

A pdf of the presentation as well as the sample source code that I used during the presentation can be found on bitbucket.

Thanks to everyone who showed up, GUM is a great group to present to, lots of good questions.

11 Comments

Grails build-test-data 1.1 released with new buildLazy functionality

2010/04/4

Version 1.1 of the build-test-data plugin has just been released.

It adds a new buildLazy method that will only create a new object graph if it can’t find an existing object that matches the build criteria specified.

Example:

    def a = new Author(firstName: "Ray", lastName: "Bradbury")
    a.save()
    assert 1 == Author.count()
 
    // Author table already has Ray Bradbury in it, finds existing record
    def bradbury = Author.buildLazy(lastName: "Bradbury")  
    assert 1 == Author.count()
    assert bradbury.firstName == "Ray"
 
    def newAuthor = Author.buildLazy(lastName: "Moore")
    assert 2 == Author.count() // creates a new record, no existing "Moore" author previously

I find this particularly useful for building testing data in the grails console. It allows me to do some quick setup of new objects and then concentrate on creating the code that I actually want to try out. Without buildLazy, I was always commenting out my creation code so that multiple executions of the test script didn’t create multiple copies of the same data (and potentially hit unique constraints issues that I had to screw around with).

Now, I no longer need to worry about commenting out the creation code after running it the first time.

Example:

def u = User.buildLazy(ssn: "123-456-7890") // User.ssn has unique constraint
u.foo()
u.bar()
u.baz()

Before buildLazy I’d need to comment out the user creation and replace it with a user.findBySsn. Now buildLazy does the creation and later finding for me. I can concentrate on making foo/bar/baz do what I want them to (the reason I opened the console in the first place).

2 Comments

Updated grails autocomplete script for zsh

2010/03/2

A couple of years ago, I created a grails auto-completion script for bash and zsh.

Since then, I’ve completely abandoned bash, in favor of zsh (which I consider to be the superior shell) and I’d been getting annoyed at a few issues in the last grails autocomplete script.

I finally got motivated to make some enhancements to it. Including support for grails 1.2 plugin scripts (1.2 moved the plugins into the ~/.grails directory), and support for test class name autocompletion (very useful for grails test-app).

To get it working (assuming you’re using zsh), you can either add the contents of my zshrc_grails_compinstall to your .zshrc file, or you can switch over to using my full zshrc setup, which has a number of nice features that I’ve collected over the years. I’ll also continue to update this as I think of new tricks.

After getting it installed, just type “grails” followed by a space and then hit tab. It will show you a list of all of the potential grails scripts for the application that you’re in. It’s aware of the version of the current app, as well as it’s application name based on the contents of application.properties, and also will include any scripts for the plugins you have installed in that app in ~/.grails/GRAILS_VERSION/projects/APP_NAME/plugins (in addition to the scripts in ./scripts, $GRAILS_HOME/scripts and ~/.grails/scripts).

After you choose your script (such as grails test-app hit space again and it will show you all of the test classes, with the full package for the class, under your test directory.

No Comments

Using iWork Numbers.app AppleScript to Sum Columns For All Tables on a Sheet

2010/02/7

Overall, I’m pretty happy with Numbers.app (part of Apple’s iWork suite) as a replacement for Excel. It’s considerably cheaper and has lots of user interface tweaks to make it more pleasant to work with.

One of these changes is that each sheet can actually have multiple tables on it, and these can be arranged independently on the same page. This prevents the problem that happens in excel where you have multiple sets of data you want to see at the same time, but the cell/row sizing for one set of data affects the data in the other set that happens to be on the same row.

I’ve been leveraging this for a one-off personal project and I had a need to sum up all of the data in the 2nd column on all of the tables within a particular sheet.

This brought me to AppleScript, Apple’s scripting language that’s used to drive applications.
Read the rest of this article »

3 Comments

Updated wordpress

2009/09/6

I’ve just switched hosting providers from slicehost to a reserved EC2 instance. I also upgraded from a really old version of wordpress to wordpress 2.8.4. I’ve been meaning to do this for a while now, but wanting to avoid yesterday’s worm prompted me to do it this weekend rather than next.

Let me know if you see any issues or broken links.

1 Comment

SelectorGadget makes CSS selectors really simple

2009/02/26

Today I’ve run across a few mentions of SelectorGadget. First when John Resig tweeted about it and now it’s at the top of Hacker News.

It’s worth all the attention it’s getting. It makes working with CSS selectors, and especially scraping websites, dead simple. This is the gateway into

The kind of information that it gives you can be fed into jQuery (or other CSS selector aware API’s like nokogiri or hpricot for Ruby or beautiful soup for Python) to easily get the right syntax for querying the DOM.

Check out the author’s screencast on the front page. He very quickly demonstrates how easy it is to use SelectorGadget to modify the scope of the intended selector.

P.S. if anyone is aware of any Groovy/Java parsers that can take CSS 3 selectors, I’d love to hear about them. Some quick googling isn’t showing anything.

2 Comments

StackOverflow.com

2008/09/23

I’m pretty impressed with the community that’s forming over at StackOverflow.com (Jeff Atwood and Joel Spolksy‘s new developer focused Q&A startup).

I just asked a fairly detailed question about working with mercurial. Something that wasn’t (obviously) covered on the mercurial wiki, through googling, or in the mercurial handbook, and got a quality answer back in only 8 minutes. That’s fantastic for a general purpose development website and is a great start after only being open for a couple of weeks.

They’ve started up an interesting reward/karma system over there where they award badges (similar to achievements on Xbox360) for a bunch of different positive behaviors. A nice little token system that’s paired with “power-ups” at different point levels. It’s easy to get the first few badges with just a little participation on the website, and I can see how certain personality types that are common in engineers would get big rewards out of collecting these.

No Comments

Ubiquity – interesting looking command line for Firefox

2008/08/26

Just ran across Ubiquity over on on waxy.

It’s an alpha Firefox plugin that’s attempting to be a command line for the internet. It reminds me a little of yubnub, but quite a bit more powerful as it’s available on every page and is context sensitive.

Essentially, it has a set of built in commands (that you can add to an extend) and it’s aware of the current browser context, so if you have something highlighted, it can act on that subset of the current page.

Previously, I’ve been a heavy user of Firefox smart keywords, which allow you to assign aliases to bookmarks and type the aliases in the location bar. I’ve created smart keywords that allow me to search wikipedia, amazon, imdb and the dictionary. Ubiquity has all of these, plus a lot more built-in.

I’ve only been using it for a little bit, and there are some rough edges, but I think that there is quite a bit of promise here as well and thought that there might be a few other keyboard jockeys out there that would appreciate what Ubiquity is trying to do.

3 Comments