Skip to content

Instantly share code, notes, and snippets.

@tatey
tatey / gist:6018632
Created July 17, 2013 08:00
Example integration with TheBestDay JavaScript API.
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<title></title>
<script type="text/javascript" src="https://js.thebestday.com/v1"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<h1>2 Stews and a Cockatoo</h1>
'use strict';
describe('route', function() {
beforeEach(function() {
module('route');
});
describe('#projectPath', function() {
it('replaces :org', inject(function(route) {
var options = {org: 'tatey'},

This is a typical controller spec.

let(:contact_service) { double('FacebookContactService', import_in_background_for_stale_member: nil) }

it 'does something' do
  controller.contact_service = contact_service

  post :create
@tatey
tatey / designate.rb
Created June 11, 2013 11:08
I know this isn't quite right, but I'd love to do something like this.
module Designate
def designate method_name, arity: 0
define_singleton_method method_name do |*args|
new(*args).send method_name
end
end
end
class HipChatService
extend Designate
@tatey
tatey / bugsnag_wrapper.html
Created May 16, 2013 01:17
Would something like this work?
<script type="text/javascript">
(function() {
'use strict';
var ExceptionNotifier = function() {
this.service = window.Bugsnag;
};
ExceptionNotifier.prototype.notify = function() {
if (this.service) {
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __FILE__)
require 'bundler/setup'
require 'sequel'
if ARGV.size != 2
puts "usage: #{__FILE__} <DATA_PATH> <DB_PATH>"
puts " #{__FILE__} ~/Desktop/sites.txt ~/Desktop/database.sqlite"
abort
@tatey
tatey / 0_0.js
Last active December 15, 2015 08:59
// Create a function on the controller that computes propA
// and popC.
function ModelCtrl($scope) {
$scope.models = [{propA: 'A', probB: 'B'}];
$scope.propC = function(model) {
return model.propA + model.propB;
}
}
class ViewController
include TableSection
def numberOfSectionsInTableView(tableView)
2
end
def numberOfRowsInSection0(tableView)
@data.count
end
# RecursiveClosedStruct is similar to OpenStruct, except:
#
# * Immutable. Cannot be changed after instantiation.
# * Raises NoMethodError on undefined methods instead of returning nil.
# * Recursively coerces descendants into a RecursiveClosedStruct.
#
# NoMethodError example:
# struct = RecursiveClosedStruct.new(key1: "value")
# struct.key1 # => "value"
# struct.key2 # => NoMethodError
@tatey
tatey / delayed_job
Created March 12, 2013 06:55
Delayed Job, Rails 4 and Capistrano
#!/usr/bin/env ruby
require_relative '../config/boot'
require_relative '../config/environment'
require 'delayed/command'
Delayed::Command.new(ARGV).daemonize