Postgres.app, an easier way to use PostgreSQL on Mac #

A week or so back, I was chatting with Craig Kerstiens, a product guy at Heroku, about an issue I was having with my Postgres install (through Homebrew) — he suggested that I use Postgres.app.

There’s an easier way

Just download, install and run the app when you want to run Postgres locally for development. I always found myself fumbling with commands like pg_ctl -D /usr/local/var/postgres start or pg_ctl -D /usr/local/var/postgres stop -s -m fast to start and stop my Postgres server. Running Postgres.app is a much simpler and easier user experience now. Just run the app when you’re hacking, and quit the app when you’re done. Simple.

The classic Postgres elephant icon will hang out in your system tray for easy access.

Heroku and Rails specifics

If you’re hacking on a project and deploying to Heroku with a Postgres database, you’ll need to run heroku addons:add heroku-postgresql:dev to setup Postgres for your app before running something like heroku run rake db:migrate.

For more details on using Postgres on Heroku check out postgres.heroku.com. You should also subscribe to Postgres Weekly – a free, once–weekly e-mail round-up of PostgreSQL news and articles curated by Craig Kerstiens.

Mackup keeps your dotfiles and app settings in sync using Dropbox #

If all you want to do is keep your dotfiles and app settings in sync between machines (OS X machines, of course), then Laurent Raufaste’s Mackup might just be the perfect thing for you.

Basically it symlinks the supported applications to copied versions of your dotfiles and app settings to ~/Dropbox/Mackup.

For example, once you’ve ran mackup backup your .gitconfig file will live at ~/Dropbox/Mackup/.gitconfig and ~/.gitconfig will be symlinked to it. That way all your precious dotfiles and app settings are synced to Dropbox. When it comes time to get another machine (presumably your next machine) setup, it’s as easy as installing Mackup, and running mackup restore.

Laurent’s notes from the readme:

I change my workstation every X months. Each time I either loose the configuration of all the apps I use, or I just waste a bunch of hours getting setup like I was on my old box. I also spent a lot of time reconfiguring the same stuff again on all my workstations (home, work)

Boring…

I agree.

There are a number of ways to backup your dotfiles, but Mackup is super simple, doesn’t require sharing them on GitHub (if that’s not your thing), and leverages Dropbox — which you likely have on your machine anyways.

Check out the install instructions to get started. You might also consider reading this as well to learn exactly how Mackup does what it does. If you haven’t yet, checkout the unofficial guide to dotfiles on GitHub while you’re at it. There’s more than one way to skin this cat.

Install Node.js and npm using Homebrew on OS X

If you’re looking for an easy to follow guide on installing Node.js and npm on OS X, the default method is to download a pre-built installer for your platform, install it, and make sure it’s on your $PATH. But, if you’re a Homebrew fan like me and prefer to install all of your packages with […]

KGNoise — The easiest way to draw noise in Objective-C #

Today David Keegan released KGNoise. It’s hands down the simplest way to draw noise on iOS or Mac.

There’s two simple class methods to draw noise:

+ (void)drawNoiseWithOpacity:(CGFloat)opacity;
+ (void)drawNoiseWithOpacity:(CGFloat)opacity andBlendMode:(CGBlendMode)blendMode;

David even provides a UIView or NSView (depending on which platform you’re building for) subclass that wraps up this behavior nicely. Here’s the interface:

@property (strong, nonatomic) NSColor/UIColor *backgroundColor;
@property (nonatomic) CGFloat noiseOpacity;
@property (nonatomic) CGBlendMode noiseBlendMode;

Since NSView doesn’t have a backgroundColor property, he adds one for you. Super handy.

Lots of designs, including Apple’s, have been using noise lately. KGNoise makes it dead simple to accomplish this now. Definitely give it a look!

TextMate 2 now on GitHub #

As announced on the Macromates blog, TextMate 2 source is now on GitHub.

Allan Odgaard:

I’ve always wanted to allow end-users to tinker with their environment, my ability to do this is what got me excited about programming in the first place, and it is why I created the bundles concept, but there are limits to how much a bundle can do, and with the still growing user base, I think the best move forward is to open source the program.

Starred.

INAppStoreWindow – A Mac App Store style Cocoa NSWindow subclass #

This is handy NSWindow subclass that lets you center the traffic lights (close, minimize, and zoom) or do custom drawing in the window’s title bar. INAppStoreWindow doesn’t use any private APIs, so it’s App Store friendly. It also supports ARC or non-ARC.

The custom drawing is really simple. You just give it a block:

[self.window setTitleBarDrawingBlock:^(BOOL drawsAsMainWindow, CGRect drawingRect, CGPathRef clippingPath){
    // Custom drawing code!    
}];

David Keegan has a little demo app you can checkout as well.

MBRequest – Easier API wrappers in iOS and OSX #

A good API wrapper should handle network transport, payload serialization/deserialization, and authentication, abstracting these details away in order to let the developer deal with the business domain of the API. Projects like Faraday, Requests, and others have made creating higher level wrappers much easier.

MBRequest from Mobiata does the same for iOS and OSX:

NSURL *url = [NSURL URLWithString:@"https://gdata.youtube.com/feeds/api/standardfeeds/top_rated?alt=json?time=this_week"];
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url];
[urlRequest setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"];
MBJSONRequest *jsonRequest = [[[MBJSONRequest alloc] init] autorelease];
[jsonRequest performJSONRequest:urlRequest completionHandler:^(id responseJSON, NSError *error) {
    if (error != nil)
    {
        NSLog(@"Error requesting top-rated videos: %@", error);
    }
    else
    {
        NSArray *videos = [[responseJSON objectForKey:@"feed"] objectForKey:@"entry"];
        for (NSDictionary *videoInfo in videos)
        {
            NSString *title = [[videoInfo objectForKey:@"title"] objectForKey:@"$t"];
            NSString *author = [[[[videoInfo objectForKey:@"author"] objectAtIndex:0] objectForKey:@"name"] objectForKey:@"$t"];
            NSLog(@"'%@' by %@", title, author);
        }
    }
}];

Check out the examples folder in the project source for implementation ideas.

git-dude: Lightweight Git commit notifier for Linux and OSX #

You might have seen our post last year on Gitifier, the Git commit notifier for OSX. If you prefer something a bit more *nix-y, check out git-dude from Marcin Kulik. Git-dude is a command line utility that monitors Git repos and provides desktop notifications using Growl on OSX or libnotify on Linux.

ScreenshotScreenshot

Configuration is done in the standard Git way:

git config --global dude.interval 30
git config --global dude.icon ~/.git-dude/github_32.png

Check the README for installation and advanced usage.

Color Picker Pro for Mac #

It’s always neat to see desktop applications go open source. Oscar Del Ben has done just that with Color Picker Pro; it’s a desktop app that lets you, well, pick colors.

If you’ve ever wondered how other people structure their desktop apps, or if you’re looking to figure out what exactly that color someone else used is, you might want to give it a look.

Check out the README for more.

Prey: Simple yet powerful application for tracking stolen computers #

As Joshua Kaufman recently demonstrated with
his “This Guy Has My MacBook” Tumblr site, stolen laptop recovery
tools like Hidden really do work. It was even covered in the tech section on CNN.com.

While Hidden
is a proprietary Mac app, Prey is an open source, multi-platform
alternative. Available for Windows, MacOS, Linux, and even Android, Prey
lies dormant, waiting for a signal to activate itself and phone home
with your device’s latest location, screen captures, and snapshots from
your laptop’s buit-in camera.

UPDATE: If you’re not completely sold on Prey, check out this Storify of Sean Power tracking down his stolen laptop Man tracks stolen laptop hundreds of miles away, calls thief – storify.com

If your organization needs to track more than three devices, Prey now
offers pro plans, with higher limits as
well as advanced features such as:

  • hardware scans and change notifications
  • increased updated frequency up to 2-minute intervals
  • SSL encryption of data
  • automated deployments to devices

Best of all, since Prey is open source, you have a chance to
contribute.

[Source on GitHub]

Episode 0.5.6 – Vim with Drew Neil, Tim Pope, and Yehuda Katz

Wynn sat down with three Vim users and experts to talk about tips and tricks for using and pimping the popular text editor. Items mentioned in the show: Vim seeks to provide the power of Unix’s Vi Drew Neil hosts VimCasts Tim Pope has created numerout Vim plugins Yehuda Katz from SproutCore, Rails, and jQuery […]

pow: Zero-configuration Rack server for Mac OS X #

I’ve been a long-time Passenger user to switch between multiple Ruby web apps during development without needing to crank up rails s for each. When I began using RVM to switch back and forth between multiple Ruby versions, Passenger no longer solved my problem. That’s why I’m excited to try out Pow from 37 Signals. Pow aims to be “a zero-config Rack server for Mac OS X.”

To install, run the install script

curl get.pow.cx | sh

To add apps, just symlink them to your ~/.pow folder:

$ cd ~/.pow
$ ln -s /path/to/myapp

… and browse to http://myapp.dev/.

[Source on GitHub] [Annotated Source]

lunchy: A friendly wrapper for OS X launchctl #

If you run OS X, you’ve probably encountered some frustration with Apple’s launchctl command line options when starting, stopping, and restarting your launchd daemons. Whereas most things Apple are minimalist, launchctl options are quite verbose. For example, how many times have you installed a Homebrew package only to get met with something like:

If this is your first install, automatically load on login with:
    cp /usr/local/Cellar/mongodb/1.6.5-x86_64/org.mongodb.mongod.plist ~/Library/LaunchAgents
    launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist

If this is an upgrade and you already have the org.mongodb.mongod.plist loaded:
    launchctl unload -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
    cp /usr/local/Cellar/mongodb/1.6.5-x86_64/org.mongodb.mongod.plist ~/Library/LaunchAgents
    launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist

Or start it manually:
    mongod run --config /usr/local/Cellar/mongodb/1.6.5-x86_64/mongod.conf

So to crank up Mongo you want me to pass that entire path to launchctl?

Lunchy – “Start your agents and go to lunch”

Thank goodness there’s Lunchy from Mike Perham. Lunchy simplifies the command line interface to launchctl. To get started, install the gem:

gem install lunchy

Now we can list all of our agents with ls

» lunchy ls
com.adobe.AAM.Updater-1.0
com.adobe.CS5ServiceManager
com.apple.FTMonitor
com.apple.apsd-ft
com.apple.imagent
com.apple.marcoagent
com.bjango.istatlocal
com.embercode.TVShowsHelper
com.github.dotjs
com.google.keystone.agent
com.mysql.mysqld
com.wacom.pentablet
net.culater.SIMBL.Agent
net.sourceforge.tvshows
org.mongodb.mongod
org.postgresql.postgres
ws.agile.1PasswordAgent

… and start MongoDB with

lunchy start mongo

To see the full range of options, just type lunchy with no arguments:

Supported commands:

 ls [pattern]       Show the list of installed agents, with optional [pattern] filter
 start [pattern]    Start the first agent matching [pattern]
 stop [pattern]     Stop the first agent matching [pattern]
 restart [pattern]  Stop and start the first agent matching [pattern]
 status [pattern]   Show the PID and label for all agents, with optional [pattern] filter

Got an idea to improve upon Lunchy? Go ahead and fork the project

[Source on GitHub]

teamocil: Ruby and YAML-powered terminal layout manager for tmux #

It’s a bit ironic that as a UX developer I spend most of my time in the terminal. That’s why I’m always on the lookout for new tools that improve my command line user experience.

My latest find is Teamocil a nice Ruby gem from Rémi Prévost that manages your tmux layouts. For those new to tmux:

tmux is a terminal multiplexer: it enables a number of terminals (or windows), each running a separate program, to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached.

Here’s a quick look at a simple Teamocil and tmux layout in action:

Screencap

To set up your own tmux session, you’ll need to install it via your favorite package manager. On the Mac, I use Homebrew.

brew install tmux

Next, you’ll need the Teamocil gem:

gem install teamocil

Now we need to set up our layout:

mkdir ~/.teamocil
touch ~/.teamocil/styles.yml

Here’s my quick 50-50 split example from the screenshot:

thechangelog » cat ~/.teamocil/styles.yml                          ~/Blogs/thechangelog  
windows:
  - name: prototype
    splits:
      - cmd: cd ~/hp/code/styles
      - cmd:
        - cd ~/hp/code/styles
        - serve
        width: 50%

Now we just run tmux and teamocil:

$ tmux
$ teamocil styles

Be sure and check the Readme for more info or how to create vertically split layouts, too.

[Source on GitHub]

nib2objc: Convert iPhone NIB files into Objective-C code #

Interface Builder is one of the coolest things about Cocoa development. Being able to draw your interfaces visually can save you tons of otherwise tedious code to create layouts and set visual styles for your user interface elements.

Adrian Kosmaczewski, iPhone and iPad developer and creator of Device DNA and several other apps in the App Store turned us on to nib2objc, which is a brilliant name because it takes NIB (or XIB) files from Interface Builder and converts them to Objective-C.

To run from the command line, simply run nib2objc, passing the path to your NIB file:

nib2objc yourfile.xib > code.m

The output is a rather nice looking set of UIKit objects and property assignments to match values from your NIB:

// ...
UIView *view6 = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 460.0)];
view6.frame = CGRectMake(0.0, 0.0, 320.0, 460.0);
view6.alpha = 1.000;
view6.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
view6.backgroundColor = [UIColor colorWithWhite:0.750 alpha:1.000];
view6.clearsContextBeforeDrawing = NO;
// ...

UIButton *button9 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button9.frame = CGRectMake(167.0, 65.0, 72.0, 37.0);
button9.adjustsImageWhenDisabled = YES;
button9.adjustsImageWhenHighlighted = YES;
button9.alpha = 1.000;
button9.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin;
button9.clearsContextBeforeDrawing = NO;
button9.clipsToBounds = NO;
button9.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
// ...
[button9 setTitleShadowColor:[UIColor colorWithWhite:0.000 alpha:1.000] forState:UIControlStateSelected];

// ...
[view6 addSubview:button9];
// ...

Bonus #1

As an added bonus, nib2objc includes a GUI to browse NIB files and even peer into their generated Objective-C code, complete with Fragaria-based syntax highlighting.

GUI

Check the project home page for more details, not to mention the most minimalistic Redmine theme we’ve seen.

Bonus #2

But wait, there’s more. We also stumbled across Adrian’s other project Bluwoki, a Bluetooth peer-to-peer walkie-talkie for iPhone and iPod Touch. Since my daughters get their Dad’s old hand-me-down iPhones, I may have to install this for them to have some fun around the house. Bluwoki is also open source, grab the code on GitHub.

Bluwoki

[Source on GitHub] [Home page]

Using Haskell to make a Mac App Store App #

app-store.png

Now that the Mac App store is open, everyone is wondering what they can get away with. Apple has added some interesting restrictions that applications must be compiled with XCode. There are tons of languages for which this is not exactly normal, and so people have been curious to see what kinds of things will actually make it in. In particular, the Ruby community has been pretty excited about building apps with MacRuby, since it fits the bill.

Well, I just heard about another oddball case, and it’s been successful: Jinjing Wang created an application called ClippingDetector, and he’s made a GitHub repo showing how he did it. Now, this isn’t the code for the ClippingDetector app itself, it’s Apple’s famed Currency Converter example. However, it does show how to use XCode together with a custom Python script that makes all of the magic happen.

I’m excited to see all kinds of programming languages being used for desktop Mac development; while I enjoy Objective-C, sometimes it can be a bit unwieldy. It’s also cool to have a real, working example of something when you’re attempting to do something new and interesting.

[Source on GitHub] [README]

kod: CSS3 themable, Node.js powered editor for OS X #

It’s a very Merry Christmas for Mac developers. Rasmus Andersson has open sourced Kod, the “programmers’ editor for OS X.”

Built from the ground to feel like a native OS X app, Kod sports Chrome-style tear-off tabs and aims for full concurrency, taking advantage of additional CPU cores when loading files, performing syntax highlighting, and other intensive tasks.

Even with the provided integrated scripting environment powered by Node.js, perhaps the most impressive feature for the web geek is that Kod is fully themable using CSS3.

screenshot

So if you’re still waiting on TextMate 2.0 and Vim or emacs isn’t your bag, then give Kod a try.

[Source on GitHub] [Web site]