Git your game on with Githug! #

Githug is a cool new way to learn git by Gary Rennie. From the readme:

Githug is designed to give you a practical way of learning git. It has a series of levels, each utilizing git commands to ensure a correct answer.

Game on!

#108: Exercism.io with Katrina Owen

Adam and Jerod talk with Katrina Owen – Panelist on Ruby Rogues, Instructor at Jumpstart Lab and creator of Exercism.io, an open source platform for crowd-sourced code reviews on daily practice problems.

Pynt versus Invoke

Just the other day I saw someone mention on Twitter that Pynt was their new favorite pure Python replacement for make. I have some minor experience using Invoke, a very similar tool. This prompted me to experiment with both utilities and report on my findings. Background Both tools take great advantage of decorators in Python […]

Multi-user tmux made easy with wemux #

Two of the many things in the development community that are growing in popularity are remote work and pair programming. Traditionally, pairing meant you had two people looking at the same computer and one person doing the typing. This is great, as long as you are in the same room.

What about those developers, like myself, who rarely (if ever) find themselves in the same room as their coworkers? Enter wemux by Matt Furden, the tmux tool that makes it simple for multiple users to connect to the same tmux session so you can see the same thing.

The only requirement, according to the README, is tmux >= 1.6. Installation is simple, with the preferred method being Homebrew:

>> brew install https://github.com/downloads/zolrath/wemux/wemux.rb

After installation, you — the host — would start a new wemux server:

>> wemux start

At this time, anyone else — the clients — could connect with any of the following three commands:

  • wemux mirror – attach to the server in read-only mode.
  • wemux pair – attach to the server in pair mode, where both the client and the host can control the terminal.
  • wemux rogue – attach to the server in rogue mode, where the client and host can work independently of eachother.

There are plenty of other features, from listing users to running multiple wemux servers at once. Once you get the hang of it, pairing while working remotely becomes much simpler than screen sharing on Skype!

You can find out everything you need to know in the README or discuss this post on HackerNews.

Searching, improved with The Silver Searcher #

The Silver Searcher by Geoff Greer is a tool which aims to take searching to the next level. Installation is simple:

brew install the_silver_searcher

If you aren’t on a Mac, or using homebrew, there are other installation instructions on the README. Using it is very straightforward, especially if you have used ack (or grep) in the past:

ag stringtofind ~/code

I know what you’re thinking, what is ag? Well, Ag is the chemical symbol for silver, and it’s a lot easier to type than the_silver_server, so Geoff went with it! There are a number of features that make The Silver Searcher worth giving a try:

  • Speed: 3-5x faster than ack
  • It honors .gitignore, .hgignore, and .agignore
  • ag is 33% shorter than ack (admittedly this is silly, but you can’t argue the facts!)

Discuss this on HackerNews or view the repo on GitHub.

Ghost means never having to touch ssh/config again (either) #

As a throwback to our original coverage of Ghost back in 2010, I wanted to share a hidden feature I just discovered in Ghost.

Two years ago Felipe Coury submitted a pull request to add ghost-ssh to manipulate ~/.ssh/config files. If it weren’t for Google pointing me to this pull request, I would have never known ghost-ssh existed. The readme says nothing about it!

This is what Felipe had to say when he submitted his patch:

I had a need to manipulate ~/.ssh/config file the same way I can manipulate my hosts entries, so I made this change.

Not sure if it will be useful for the upstream project, but be welcome to merge if you like.

An intro to ghost-ssh

Just like with ghost on the command line, ghost-ssh has basic list, add, and delete options, as well as an import operation to import files.

To save you some time, here’s the contents of ghost-ssh --help:

$ ghost-ssh --help
USAGE: ghost-ssh add <host> <hostname> [--user=<user>] [--port=<port>]
       ghost-ssh modify <host> <hostname> [--user=<user>] [--port=<port>]
       ghost-ssh delete <host>
       ghost-ssh list
       ghost-ssh empty
       ghost-ssh export
       ghost-ssh import <file>

An example of adding a new entry to your ssh/config might look something like this:

$ ghost-ssh add tclprod xxxxxx.gridserver.com --user=tcladmin
  [Adding] tclprod -> xxxxxx.gridserver.com

You can confirm the entry was added to ssh/config by running the ghost-ssh list command:

$ghost-ssh list                                             
Listing 1 configs(s):
  tclprod -> tcladmin@xxxxxx.gridserver.com:22

Now that I have this new entry in place, I can easily ssh into the server by running ssh tclprod and boom goes the dynamite!

Checkout the source for Ghost on GitHub for install and usage details.

Discuss on Hacker News if you’d like.

Nodefront – Node.js-powered rapid front-end development utility #

Nodefront from Karthik Viswanathan aims to make a front-end developer’s life easier. Built in Node.js, Nodefront bundles a local web server for serving up HTML, CSS, and JavaScript assets and supports live reloading via web sockets. Additionally it ships with a command line interface:

  • nodefront compile – Compiles Jade and Stylus files to HTML and CSS. Can compile upon modification, serve files on localhost, and even automatically refresh the browser/styles when files are changed.

  • nodefront fetch – Automatically fetches CSS/JS libraries for use in your project. Provides an interactive mode to add new libraries.

  • nodefront insert – Inserts CSS/JS libraries directly into your HTML or Jade files.

  • nodefront minify – Minifies CSS and JS files. Can also optimize JPG and PNG images.

Karthik has put together a twenty minute screencast for a full demonstration.

Check out the project web site or source on GitHub for more.

ascii.io – Python-powered terminal recording and sharing #

Yesterday we featured codestre.am, a Node.js app that lets you record and livestream your terminal to others. Łukasz Korecki was quick to point us to ascii.io:

Powered by Python, ascii.io from Marcin Kulik is fully open source, both client and server. You can install the client with a simple shell script:

$ curl -sL get.ascii.io | bash

Once installed, use the asciiio command line interface to record your session, optionally logging in with GitHub or Twitter to store your recordings under your profile at ascii.io.

ascii.io screencap

Check out the source on GitHub for info on usage and how to contribute.

Bonus: Nyan Cat!

noexec – Run Ruby scripts without bundle exec #

We’ve covered a few of Josh Hull’s projects on this blog. His latest is so simple, yet quite useful. If you use Bundler, you probably spend a good part of your day running bundle exec. I even use a zsh alias be for this purpose. Well now, we can stop.

With noexec, Josh has created a small script that will walk up your directory structure until it can find a Gemfile. If the executable you’re running is in that Gemfile, it will use it instead of Bundle.setup.

Simply install the gem:

gem install noexec

… and be sure to export the following environment variable in your shell profile:

RUBYOPT="-r`noexec`"

Check the source on GitHub for more.

httpie – Python-powered HTTP CLI for humans #

Although cURL is great, we’re always looking for great console tools for working with HTTP. Jakub Roztocil has released HTTPie. Built on Requests, HTTPie provides a clean command line interface for HTTP requests:

http PATCH api.example.com/person/1 X-API-Token:123 name=John email=john@example.org

PATCH /person/1 HTTP/1.1
User-Agent: HTTPie/0.1
X-API-Token: 123
Content-Type: application/json; charset=utf-8

{"name": "John", "email": "john@example.org"}

I appreciate the colored terminal output:

HTTPie output

Source on GitHub.

Methadone – Build better Ruby-based CLI’s with logging and Cucumber support #

There’s no shortage of projects to build CLI apps in Ruby, but few ship with as many tools to help you build better command line interfaces as David Copeland’s Methadone. Features include bootstrapping, logging, command DSL, and even Cucumber support via Aruba.

The DSL aims to be a readable, convenience wrapper around OptionParser:

#!/usr/bin/env ruby

require 'optparse'
require 'methadone'

include Methadone::Main

main do |name,password|
  name # => guaranteed to be non-nil
  password # => nil if user omitted on command line
  options[:switch] # => true if user used --switch or -s
  options[:s]      # => ALSO true if user used --switch or -s
  options[:f]      # => value of FILE if used on command-line
  options[:flag]   # => ALSO value of FILE if used on command-line

  ...
end

description "One line summary of your awesome app"

on("--[no-]switch","-s","Some switch")
on("-f FILE","--flag","Some flag")
on("-x FOO") do |foo|
  # something more complex; this is exactly OptionParser opts.on 
end

arg :name
arg :password, :optional

go!

Since Methadone also scaffolds out your Cucumber features, you can test your CLI via Aruba:

Feature: My bootstrapped app kinda works
  In order to get going on coding my awesome app
  I want to have aruba and cucumber setup
  So I don't have to do it myself

  Scenario: App just runs
    When I run `newgem --help`
    Then the exit status should be 0
    And the output should contain:
    """
    Usage: newgem [options]
    """

Check out the README for advanced usage or the roadmap to see how you might contribute.

Cement2, Python CLI framework nears beta #

Cement2, the next version of the Python application framework is almost ready for a beta release. I love Command Line Interfaces, and Cement2 is a slick way to create a CLI in Python. The canonical Hello World CLI is just five lines:

from cement2.core import foundation
app = foundation.lay_cement('helloworld')
app.setup()
app.run()
print('Hello World')

With the single call to lay_cement, this Python script is a full-fledged CLI complete with usage and help information:

$ python helloworld.py --help
usage: helloworld.py [-h] [--debug] [--quiet]

optional arguments:
  -h, --help  show this help message and exit
  --debug     toggle debug output
  --quiet     suppress all output

I especially like how Cement separates interfaces and handlers, allowing for swappable implementations of features based on command line arguments. There is also a robust plugin architecture for those that want to extend it. Be sure and check out the Portland branch for the source as Cement2 is still under active development.

JazzLibs – Ruby CLI to rollout and manage JavaScript libraries #

JazzLibs is a small Ruby library from Paul Engel to stamp out a repository structure and manage JavaScript libraries. The simple Thor-based CLI unfurls a new project that includes:

  • a source folder
  • a demo folder and nice looking HTML page with your assets wired up
  • default license
  • Rakefile for managing releases

Screenshot

The bundled Rakefile includes a release task that lets you easily version and deploy new versions of your script. Check out the GitHub repo to fork and contribute.

capt: Command line tool for creating Backbone.js apps #

If you set out to use Backbone.js for a client-centric application, one thing you might miss coming from a server-side MVC framework is some basic file structure, dependency managment, and generator support. To solve this problem Ben Nolan has created Capt.

Capt is aimed at developers building single page, stand alone applications as well as server-backed applications using Node.js, bundling the following projects and languages:

Languages

  • Coffeescript
  • JavaScript
  • SCSS
  • LESS

Testing frameworks

  • Qunit
  • Jasmine [planned]

Libraries

  • jQuery
  • Backbone.js
  • Underscore.js
  • json2.js

Installation

You can grab Capt from npm

npm install capt

To check your installation and see usage help, just run capt in your
terminal:

Usage:

capt new projectname 
  - create a new project

capt server
  - serve the current project on port 3000

capt watch
  - watch the current project and recompile as needed

There’s also generators to create Backbone models and controllers:

capt generate model <model name>

capt generate controller <controller name>

Capt is still in alpha but is under active development. Got ideas? Why
not contribute?

[Source on GitHub] [Web
site
]

jsonpipe: Convert JSON to a UNIX-friendly line-based format using Python #

As the web seems to be moving to JavaScript Object Notation over XML for data transfer, it’s nice to find tools to help you work with JSON from the command line. Changelog listener Jason Williams pointed us to JSON Pipe, a simple Python command line utility for visualizing JSON document structure.

Installation and usage

Install JSON Pipe via pip

pip install jsonpipe

Now we can pipe data into jsonpipe to see a breakdown of the structure of the document:

$ echo '[{"a": [{"b": {"c": ["foo"]}}]}]' | jsonpipe
/   []
/0  {}
/0/a        []
/0/a/0      {}
/0/a/0/b    {}
/0/a/0/b/c  []
/0/a/0/b/c/0        "foo"

How about inspecting an NPM package?

curl https://github.com/jashkenas/coffee-script/raw/master/package.json | jsonpipe

/ {}
/name "coffee-script"
/description  "Unfancy JavaScript"
/keywords []
/keywords/0 "javascript"
/keywords/1 "language"
/keywords/2 "coffeescript"
/keywords/3 "compiler"
/author "Jeremy Ashkenas"
/version  "1.1.0-pre"
/licenses []
/licenses/0 {}
/licenses/0/type  "MIT"
/licenses/0/url "http://github.com/jashkenas/coffee-script/raw/master/LICENSE"
/engines  {}
/engines/node ">=0.2.5"
/directories  {}
/directories/lib  "./lib"
/main "./lib/coffee-script"
/bin  {}
/bin/coffee "./bin/coffee"
/bin/cake "./bin/cake"
/homepage "http://coffeescript.org"
/repository {}
/repository/type  "git"
/repository/url "git://github.com/jashkenas/coffee-script.git"

Since the output is regular STDOUT, JSON Pipe is piping hot:

curl https://github.com/jashkenas/coffee-script/raw/master/package.json | jsonpipe | grep "homepage"

/homepage   "http://coffeescript.org"

JSON Pipe will show you the key/value structure of your JSON documents faster than you can say XPath.

[Source on GitHub]

solarized: Light and dark precision color scheme for terminal apps, editors #

We developers spend as much time finding the right color scheme for our text editors and command line tools as we do using them. Normally, you find your tool of choice and then browse the gallery of themes to pick one to use or customize.

Ethan Schoonover has taken a different approach with Solarized, a theme that comes with support for a number of tools out of the box including:

  • Vim
  • Mutt e-mail client
  • Xresources / Xdefaults
  • iTerm2
  • OS X Terminal.app
  • Adobe Photoshop Palette (inc. Lab values)
  • Apple Color Picker Palette
  • GIMP Palette

Sample

Never before has so much design gone into a color theme. Ethan supports both light and dark variations to support selective contrast and other features

palette

There’s even a Sass implementation:

$base03:    #002b36;
$base02:    #073642;
$base01:    #586e75;
$base00:    #657b83;
$base0:     #839496;
$base1:     #93a1a1;
$base2:     #eee8d5;
$base3:     #fdf6e3;
$yellow:    #b58900;
$orange:    #cb4b16;
$red:       #d30102;
$magenta:   #d33682;
$violet:    #6c71c4;
$blue:      #268bd2;
$cyan:      #2aa198;
$green:     #859900;
@mixin rebase($rebase03,$rebase02,$rebase01,$rebase00,$rebase0,$rebase1,$rebase2,$rebase3) 
{
    background-color:$rebase03;
    color:$rebase0;
    * { color:$rebase0; }
    h1,h2,h3,h4,h5,h6 { color:$rebase1; border-color: $rebase0; }
    a, a:active, a:visited { color: $rebase1; }
}
@mixin accentize($accent) {
    a, a:active, a:visited, code.url { color: $accent; }
    h1,h2,h3,h4,h5,h6 {color:$accent}
}
/* light is default mode, so pair with general html definition */
html, .light { @include rebase($base3,$base2,$base1,$base0,$base00,$base01,$base02,$base03)}
.dark  { @include rebase($base03,$base02,$base01,$base00,$base0,$base1,$base2,$base3)}
html * {
    color-profile: sRGB;
    rendering-intent: auto;
}

We didn’t see TextMate support. Perhaps you could fork the project and contribute.

[Source on GitHub]

earthquake: Twitter terminal client with streaming API support #

As at least one observant Twitter user has noticed, I’m testing out a new Twitter client. Earthquake, from jugyo (十行), is a Command Line Interface Twitter client similar to Console Tweet but with support for Twitter’s Streaming API.

screencap

Installation and usage

To get started, install Earthquake via RubyGems:

gem install earthquake

The gem installs a command line application, invoked via earthquake. The first time you run the application, you’ll be redirected to Twitter in a new browser window to authorize the application and provide a PIN to enter into the Earthquake prompt to complete the OAuth setup:

~ » earthquake                                                                        ~  
1) open: http://api.twitter.com/oauth/authorize?oauth_token=UF5HD9XH8pvAQtrhvQwpO0iZmyvLgJ8sGhEPdhLA
2) Enter the PIN: 

Once authenticated, you’ll get a nifty lightning bolt prompt (⚡) from which you can tweet, search, even eval Ruby:

# tweet
⚡ Hello World!

# Search
⚡ :search #ruby

# Eval
⚡ :eval Time.now

As Mathias Meyer was nice to point out, you’ll want to type :exit not exit to leave the application.

Be sure and check the README for advanced usage and color customization.

Earthquake for Node.js?

Intrigued by my exit tweet, Changelog alum Tim Caswell wants to rebuild Earthquake in Node.js and offered a fine start in under thirty seconds.

[Source on GitHub]

WatchWednesday for 20101006

Another WatchWednesday, is upon us. Here’s a quick list of projects you might have missed or you should watch. Commander TJ Holowaychuk’s latest projects seem to have a Node.js flavor, but TJ has released a ton of Ruby projects, too. Commander is a robust API for creating Ruby command line applications. Commander sits atop OptionParser, […]

Optitron: Easily add option and command parsing to your Ruby CLI #

We love command line interfaces. We’ve written before about how we use the Tumblr gem to post to this site. If you want to add a nice CLI to your Ruby app, Joshua Hull from the Padrino team has released Optitron, an easy way to support option and command parsing.

Install the gem

gem install optitron

A quick example

@parser = Optitron.new {
  opt 'verbose', "Be very loud"
  cmd "install", "This installs things" do
    arg "file", "The file to install"
  end
  cmd "show", "This shows things" do
    arg "first", "The first thing to show"
    arg "second", "The second optional thing to show", :required => false
  end
  cmd "kill", "This kills things" do
    opt "pids", "A list of pids to kill", :type => :array
    opt "pid", "A pid to kill", :type => :numeric
    opt "names", "Some sort of hash", :type => :hash
  end
  cmd "join", "This joins things" do
    arg "thing", "Stuff to join", :type => :greedy
  end
}

Then you can print those options with @parser.help:

Commands

show [first] <second>          # This shows things
install [file]                 # This installs things
kill                           # This kills things
  -p/--pids=[ARRAY]            # A list of pids to kill
  -P/--pid=[NUMERIC]           # A pid to kill
  -n/--names=[HASH]            # Some sort of hash
join [thing1 thing2 ...]       # This joins things

Global options

-v/--verbose                   # Be very loud

Let’s see how Optitron parses inbound arguments

response = @parser.parse(%w(-v install file))
response.command
=> "install"
response.args
=> ["file"]
response.params
=> {"verbose" => true}

With four patch releases today, this gem is moving fast but one to keep an eye on.

[Source on GitHub]

tumblr-rb – Post to tumblr from the command line #

tumblr-rb from Mark Wunsch is a cool new Ruby wrapper for Tumblr, the blogging service that powers The Changelog. While not the first Ruby wrapper for Tumblr, nor even the first with CLI support, tumblr-rb is the first we know of to support YAML front-matter.

YAML front-matter isn’t a special part of your brain, rather it’s YAML formatted meta-data at the top of a text file, a pattern made popular by Webby, Jekyll, Nanoc, and other static-ish publishing tools:

---
title: The Tumblr Gem
state: queue
format: markdown
tags: Ruby, Tumblr, Weary
slug: tumblr-rb
---


You can also give it a URL:

  $ tumblr http://mwunsch.github.com/tumblr/tumblr.1.html

That will create a _Link_ post on Tumblr pointing to the `tumblr` manpage.

Another cool thing about tumblr-rb is how Mark has employed Chris Wanstrath’s new gem-man (Changelog article forthcoming) to create awesome looking man pages for the gem.

Tumblr is about removing the friction from blogging workflow. If you spend any time in the terminal, tumblr-rb takes it even farther.

[Source on GitHub] [Marks’ Tumblog]

Ghost means never having to touch /etc/hosts again #

Ghost from Bodaniel Jeanes is a Ruby gem that lets you manage your local host names without futzing with /etc/hosts.

To install:

gem install ghost

And then from the command line:

$ ghost add mydevsite.local
  [Adding] mydevsite.local -> 127.0.0.1

$ ghost add staging-server.local 67.207.136.164
  [Adding] staging-server.local -> 67.207.136.164

$ ghost list
Listing 2 host(s):
  mydevsite.local      -> 127.0.0.1
  staging-server.local -> 67.207.136.164

$ ghost delete mydevsite.local
  [Deleting] mydevsite.local

Aside from basic list, add, and delete options, Ghost provides powerful import and delete_matching operations to import files or delete entries based on pattern matching.

Check out the source on GitHub.

UPDATE: We covered ghost-ssh, a hidden feature of ghost which lets you manipulate your ~/.ssh/config file as well.