Skip to content

Instantly share code, notes, and snippets.

View fearoffish's full-sized avatar

Jamie van Dyke fearoffish

View GitHub Profile
require 'artoo'
# Circuit and schematic here: http://arduino.cc/en/Tutorial/Blink
connection :firmata, adaptor: :firmata, port: '/dev/tty.usbmodem1411'
# device :board, :driver => :device_info
device :led, :driver => :led, :pin => 13
work do
➜ examples ruby blink_led.rb
I, [2014-09-23T19:40:42.022607 #2719] INFO -- : Registering connection 'firmata'...
I, [2014-09-23T19:40:42.022695 #2719] INFO -- : Registering device 'led'...
I, [2014-09-23T19:40:42.022726 #2719] INFO -- : Preparing work...
I, [2014-09-23T19:40:42.023406 #2719] INFO -- : Initializing connection firmata...
I, [2014-09-23T19:40:42.024618 #2719] INFO -- : Initializing device led...
I, [2014-09-23T19:40:42.026586 #2719] INFO -- : Starting work...
I, [2014-09-23T19:40:42.026800 #2719] INFO -- : Connecting to 'firmata' on port '/dev/tty.usbmodem1411'...

Keybase proof

I hereby claim:

  • I am fearoffish on github.
  • I am fearoffish (https://keybase.io/fearoffish) on keybase.
  • I have a public key whose fingerprint is 258F 3E66 7DC3 98B3 A454 E611 84C0 40D5 06DF 5149

To claim this, I am signing this object:

@fearoffish
fearoffish / Dockerfile
Last active August 29, 2015 14:16
Cloud Foundry Inception/Jumpbox Dockerfile
# A basic inception/jumpbox server for connecting to a bosh or cloud foundry instance
https://registry.hub.docker.com/u/fearoffish/bosh-inception/
@fearoffish
fearoffish / amazon_linux_inception.sh
Last active August 29, 2015 14:16
Set up a bosh jump box (inception) on Amazon Linux
#!/bin/bash
sudo yum install -y git gcc make readline-devel openssl-devel vim emacs libffi-devel make glibc-devel gcc patch libxslt-devel libxml2-devel mysql mysql-devel postgresql-devel dnsmasq autoconf automake bison gcc-c++ libyaml-devel zlib-devel sqlite-devel cmake libssh2-devel
echo 'GIT_PROMPT_THEME=Solarized' >> ~/.bashrc
echo 'source ~/.bash-git-prompt/gitprompt.sh' >> ~/.bashrc
git clone git://github.com/sstephenson/ruby-build.git /tmp/ruby-build
cd /tmp/ruby-build
./install.sh
Your Guide to Testing
This book will assume the user already knows Ruby and Ruby on Rails. It will focus on the different techniques you can use to test behaviour in Ruby/Rails applications.
Table of Contents
Chapter 1: Why Test?
Chapter 2: The Process
Chapter 3: Recipes
Fixtures or not
# Comments may or may not make sense.
class Array
def bigger?( ary )
# Check that self element is greater than comparison element
# Uses 0 if either is nil
if (self[0]||0) > (ary[0]||0)
return true
else
# if either of them don't exist as elements, comparison is bigger
# so return false
# Rails 2.1, with latest shoulda
context "POST #create" do
context "with an existing email address" do
setup do
@user = Factory.create(:user)
post :create, :email => @user.email
end
should_respond_with :redirect
@fearoffish
fearoffish / Hacked autotest.rb for running single test files
Created May 27, 2009 11:05
Quick hack of a script to replace autotest temporarily
#!/usr/bin/env ruby
require 'rubygems'
require 'directory_watcher'
puts "Watching #{Dir.pwd}/test/**/*.rb'"
dw = DirectoryWatcher.new "#{Dir.pwd}/test", :glob => '**/*.rb', :interval => 2
dw.add_observer do |*args|
args.each do |event|
case event.type
require "rubygems"
require "redis"
require 'benchmark'
count = 1000000
r = Redis.new
Benchmark.bm(10) do |x|
x.report("base") do
count.to_i.times do |i|