Skip to content

Instantly share code, notes, and snippets.

View fearoffish's full-sized avatar

Jamie van Dyke fearoffish

View GitHub Profile
require 'net/ssh'
class Host
def initialize(host, user, options={})
@ssh = Net::SSH.start(host, user, options)
end
def close
@ssh.close
end
@fearoffish
fearoffish / setup.sh
Created June 18, 2012 10:36
Workstation Setup Script
# I run this script to install brew, git and rbenv. At this point I can run my chef
# cookbooks to set up the rest of my base applications.
#
# Remote Login turned on in System Preferences -> Sharing
echo "Installing zsh"
curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh
echo "Done"
echo 'Force zsh as the new $SHELL'
@fearoffish
fearoffish / install.rb
Created June 18, 2012 12:39
Homebrew install with no prompts (Chef says it has a tty but borks here)
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
# This script installs to /usr/local only. To install elsewhere you can just
# untar https://github.com/mxcl/homebrew/tarball/master anywhere you like.
module Tty extend self
def blue; bold 34; end
def white; bold 39; end
def red; underline 31; end
def reset; escape 0; end
def bold n; escape "1;#{n}" end
it 'should sign up and redirect' do
user = Fabricate.build(:user)
visit signup_path
fill_in "Email", with: user.email
fill_in "Password", with: user.password
fill_in "Confirmation", with: user.password_confirmation
fill_in "Company name", with: user.company.name
click_button "Sign Up"
@fearoffish
fearoffish / gist:3749328
Created September 19, 2012 12:12
Ruby Units: reliable??
>> Unit('1 g') >> 'ounce'
=> 160000045359237 oz
>> Unit('1 ounce') >> 'g'
=> 453592371600000 g
>> Unit('1 mm').convert_to 'cm'
=> 110 cm
>> Unit('10 ounce') >> 'g'
=> 45359237160000 g
>> Unit('100 ounce') >> 'g'
=> 4535923716000 g
The flow:
POST a form to braintree with customer details (our payment forms do this)
Braintree redirects to a URL we provided in the form
On this URL we ask braintree to confirm the result they give us
We create a customer
We set up the charges (different per payment plan)
The problem:
@fearoffish
fearoffish / server_spec.rb
Created December 19, 2012 20:00
rubymotion spec
describe "#get" do
it "adds an auth token to the params when given" do
stub_request(:get, "http://fcp.dev/api/?auth_token=token").
to_return(body: "{\"Hello\":\"World\"}", content_type: "application/json")
@body = nil
@server.auth_token = 'token'
@server.get('http://fcp.dev/api/') do |body|
@body = body
resume
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@fearoffish
fearoffish / Rakefile
Created March 21, 2013 19:23
Using the Sphero iOS SDK with RubyMotion
# 1 Copy the .framework files to your vendor folder e.g. vendor/RobotUIKit.framework
# 2 Copy the .bundle file to your resources folder e.g. resources/RobotUIKit.bundle
# 3 Add this to your Rakefile
app.libs << "-lstdc++ -all_load -ObjC -lsqlite3"
app.frameworks << 'ExternalAccessory'
app.frameworks << 'CoreMotion'
app.vendor_project('vendor/RobotUIKit.framework', :static,
@fearoffish
fearoffish / Calculator
Last active December 16, 2015 20:29 — forked from anonymous/Calculator
Module Module1
Sub Main()
Dim intNumber1, intNumber2 as Integer
Dim strOperator As String
Do
strOperator = InputBox("Please choose an operator to use: +, -, *. Or type Q to quit.")
If strOperator = "Q" Then Exit
intNumber1 = InputBox("Please Enter The Value For The First Number")