Skip to content

Instantly share code, notes, and snippets.

@amiel
Last active December 15, 2015 13:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amiel/5264735 to your computer and use it in GitHub Desktop.
Save amiel/5264735 to your computer and use it in GitHub Desktop.

with_status

Use with_status to run commands and have your arduino let you know when they are done.

with_status starts by turning the LED off before running your command. Once your command completes, it will turn the LED on. Green if the command succeeded, and red if it failed.

I use this with long running commands (such as deploying to heroku), so I can start working on something else without forgetting about my process.

INSTALL

Copy both digicolor and with_status (without extension) to somewhere in your PATH and don't forget to chmod +x them.

USAGE

Simple example:

with_status "ls" # green
with_status "ls this/does/not/exist" # red

Rails (because rails is slow sometimes):

with_status rake routes
with_status rake -T
with_status bundle

Heroku processes:

with_status heroku db:pull

with_status "heroku maintenance:on && git push heroku master && heroku run rake db:migrate && heroku restart && heroku maintenance:off"
#!/usr/bin/env ruby -rubygems
require 'digiusb/digiblink'
# TODO:
COLORS = {
'success' => 'green',
'failed' => 'red',
'pending' => '#ff5500',
'off' => 'black',
'default' => 'black',
}
def get_spark
DigiBlink.sparks.last
end
def set_color(color)
get_spark.color = color
# rescue LIBUSB::ERROR_NO_DEVICE
# @light = nil
end
color = COLORS.fetch(ARGV[0]) do |key|
begin
key.to_color; key
rescue ArgumentError, NoMethodError
COLORS['default']
end
end
puts "DIGIRGB: #{color}"
if ARGV[1] == '--blink'
set_color('black')
sleep 1
end
set_color(color)
#!/bin/bash
digicolor black
if eval "$@";then
digicolor success
else
digicolor failed
fi
@rking
Copy link

rking commented May 1, 2013

Hardware:
http://digistump.com/
http://digistump.com/products/3

  • Bundler.with_clean_env

@anlek
Copy link

anlek commented Oct 29, 2013

I love it, one small adjustment I had to do to with_status.sh was to add "source ~/.zshrc" otherwise my aliases weren't being included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment