articles tagged with tools

One command to rule them all

no comments yet, post one now

LOTR rings DRY isn’t only a good practice in software development. Developers should always be looking for better ways to not repeat themselves. Everything we do more than once could (and probably should) be a candidate for optimisation. From simple repetitive tasks like, connecting to remote servers to setting up a fresh development environment (and everything in between).

At HouseTrip we have amassed a collection of shortcuts, scripts, and rake tasks to make our lives that little bit easier. In an effort share them throughout the team and make some of them more well-known, I decided to create an all new ht command.

37signals Sub

The ht command uses sub, a command line framework from 37signals. It’s a great starting point for building commands like this; with autocompletion, help, bash/zsh support and aliases all built in.

Helpers and configuration

Sub has some great conventions, but to allow us to direct commands at any one of our (many) staging and production servers, I forked it and added some helpers and configuration options of our own. Our staging servers can be temporary things, so its important we can easily change where we want to direct and auto-complete commands to.

Our server connection information lies in a simple yml file for each Rails environment we have. So we can issue a single command like this;

ht console staging100 # or ht c staging100

and have a Rails console (running on the remote staging100 machine) in no time. In the future I’ll try to create a pull-request with these helpers (to sub).

These helpers also include methods for handling and logging command output (even speaking output with the built-in OSXsay’ command). So far the ht command has been a hit, a trusty friend (with a voice) to call on for saving time.

Command Ideas

To give you some idea of what I’ve implemented so far (or plan to soon);

  • `ht-ssh (env)` – connect to any server
  • `ht-console (env)` – ssh and ans start a Rails console on a remote server
  • `ht-dump (db-name)` – grab a fresh (anonymised) database dump and import it to your development env
  • `ht-cache-clear (env)` – clear the Rails.cache on a remote server
  • `ht-be-admin (env) (username)` – convert an existing remote user to an admin
  • `ht-jobs (env)` – get some basic stats on job queues
  • `ht-bump-job (env) (id)` – bump the priority of a remote job
  • `ht-booking (env)` – show stats on the last few live bookings
  • `ht-gif (keyword)` – fetch an animated gif into your paste buffer (with giphy.com)
  • `ht-git-visual (time-ago) (repo)` – visualise git repository activity (with Gource)
  • `ht-add-server (config)` – add new server details to your local ht config file
  • `ht-mugshot (keyword)` – search and grab a photo from our team intranet page
  • `ht-laptop` – kick off a setup script that installs and configures your laptop for HouseTrip development
  • `ht-hammer` – replay a realistic log file of traffic requests to a staging server (with httperf)

Our ht command isn’t open source just yet, but it will be soon!

Conditional .vimrc configs

no comments yet, post one now

This is new to me, but probably old hat to vim regulars. You can have conditional statements in your vimrc config depending on which machine you are working on. In this case I have disabled end of line white space cleaning on my ‘calcifer’ and ‘alderann’ machines.

" get hostname
let machine = substitute(system('hostname'), "\n", "", "")
" auto strip whitespace when saving
" don't auto strip on these machines
if machine !~ "[calcifer|alderann]"
  autocmd BufWritePre * :%s/\s\+$//e
endif

I’ve taken to sharing my development workbench and vim configuration across multiple machines and this comes in really handy.

December 21, 2011 10:11 by

Prepping for a MacBook Pro

no comments yet, post one now

Last week I finally gave in and placed an order for a new 2Ghz MacBook Pro. Being a PC user all my life, this will be my first switch to working on a Mac environment. I chose the MacBook Pro for 3 main reasons;

  • to test websites and work in a mac environment
  • for portability (I currently don’t own a laptop)
  • performance-wise it seems like it will have enough longevity to last me at least 3 years

Gearing up for this monumentous event, Ive been collecting bookmarks of Mac tips and tools I hope will be useful;

And for people switching from Windows to a Mac, or for those trying Bootcamp (Windows on an Intel Mac)

April 18, 2006 09:16 by
← (k) prev | next (j) →