Skip to content

Instantly share code, notes, and snippets.

View masonforest's full-sized avatar

Mason Fischer masonforest

View GitHub Profile
@masonforest
masonforest / gist:4048732
Created November 9, 2012 22:28
Installing a Gem on Heroku from a Private GitHub Repo

Installing a Gem on Heroku from a Private GitHub Repo

Sometimes you want to use a gem on Heroku that is in a private repository on GitHub.

Using git over http you can authenticate to GitHub using basic authentication. However, we don't want to embed usernames and passwords in Gemfiles. Instead, we can use authentication tokens.

  1. Get an OAuth Token from GitHub

First you will need to get an OAuth Token from GitHub using your own username and "note"

@masonforest
masonforest / gist:4107758
Created November 18, 2012 21:55
The First Runnable Gist!
name = params['name'];
callback("Hello "+name)
@masonforest
masonforest / gist:4226421
Created December 6, 2012 17:42
jQuery spies
describe "Quickpay.startQuickPay", ->
it "calls animate on .single_item_quick_pay", ->
quickPay = new Threadflip.QuickPay()
event = new jQuery.Event("click")
animateSpy = spyOn($.fn, "animate")
quickPay.startQuickPay(event)
expect($.fn.animate).toHaveBeenCalledWith({height: "300px"})
expect(animateSpy.mostRecentCall.object.selector).toEqual('.single_item_quick_pay')
@masonforest
masonforest / gist:4226449
Created December 6, 2012 17:46
How jQuery spies should work
describe "Quickpay.startQuickPay", ->
it "calls animate on .single_item_quick_pay", ->
quickPay = new Threadflip.QuickPay()
event = new jQuery.Event("click")
$('.single_item_quick_pay').spyOn('animate')
quickPay.startQuickPay(event)
expect($('.single_item_quick_pay').animate).toHaveBeenCalledWith({height: "300px"})
@masonforest
masonforest / gist:5199929
Last active December 15, 2015 04:09
validate USPS tracking numbers in Ruby
def valid(tracking_number)
chars = tracking_number.chars.to_a
expected_check_digit = chars.pop.to_i
total = 0
chars.reverse.each_with_index do |digit, index|
if index.even?
total += digit.to_i * 3
else
total += digit.to_i
{"ref":"refs/heads/master","after":"71875ba99b5109cbdfef770e590ba7504536eb53","before":"bb86ebb305cf27a94e2249ee1b0c8a96919bfa03","created":false,"deleted":false,"forced":false,"compare":"https://github.com/21x9/ServiceLog/compare/bb86ebb305cf...71875ba99b51","commits":[{"id":"171bbbae6646c0bc6bdabf2e0b0ea04392c86ce1","distinct":true,"message":"Fixed another bug related to the status bar disappearing after resigning from the photo view controller while the bars are hidden","timestamp":"2012-01-24T10:48:58-08:00","url":"https://github.com/21x9/ServiceLog/commit/171bbbae6646c0bc6bdabf2e0b0ea04392c86ce1","author":{"name":"Mark Adams","email":"mark.adams86@gmail.com","username":"21x9"},"committer":{"name":"Mark Adams","email":"mark.adams86@gmail.com","username":"21x9"},"added":[],"removed":[],"modified":["ServiceLog/PhotoViewerViewController.m"]},{"id":"417939bf185774585cedacf91dfc111260d30d8b","distinct":true,"message":"Fixed some interface stuff like disclosure indicators and the ability to select maintenance e
@masonforest
masonforest / deliver_email_matcher.rb
Created May 17, 2013 22:00
rspec matcher for ActionMailer rails email delivery
# Usage
# order = create(:order)
#
# expect {
# order.pay!
# }.to deliver_email(OrderMailer, :paid, order.id)
#
#

Accounts

Create an account

POST /accounts

Input

  • account_id
var Docker = require('dockerode');
var docker = new Docker({ socketPath: false, host: '192.168.59.103', port: '2375' });
var optsc = {
'Hostname': '',
'User': '',
'AttachStdin': true,
'AttachStdout': true,
'AttachStderr': true,
'Tty': false,
@masonforest
masonforest / Dockerfile
Last active March 18, 2020 16:34
Test Drive Your Dockerfiles with RSpec and ServerSpec
FROM ubuntu:14.04
MAINTAINER Mason Fischer <mason@thoughtbot.com>
RUN apt-get update && apt-get install -y nodejs