Skip to content

Instantly share code, notes, and snippets.

@mocoso
mocoso / keybase.md
Created April 1, 2014 05:16
Keybase

Keybase proof

I hereby claim:

  • I am mocoso on github.
  • I am mocoso (https://keybase.io/mocoso) on keybase.
  • I have a public key whose fingerprint is FF92 D1B4 2106 5723 5C13 1180 44DB 133B D0A0 F39D

To claim this, I am signing this object:

@mocoso
mocoso / gist:6413069
Created September 2, 2013 13:50
Failures once public
Failures:
1) session authentication inactive sessions expire after 48 hours
Failure/Error: current_path.should eql(sign_in_path)
expected: "/sign-in"
got: "/courses"
(compared using eql?)
# ./spec/features/user_sessions_spec.rb:26:in `block (2 levels) in <top (required)>'
@mocoso
mocoso / fibonacci.rb
Created August 28, 2013 05:06
Lambda calculus Fibonacci function (work in progress) - from The London Understanding Computation book club - chapter 6 meeting
# Ruby helpers for translating output
def to_integer(proc)
proc[-> n { n + 1 }][0]
end
def to_boolean(proc)
proc[true][false]
end
# Some numbers
@mocoso
mocoso / rails-project-stats.sh
Created June 18, 2013 10:53
Rails project stats
# Number of unique 'page' templates
find . * | grep -e "^app/views/.*/[^_][^/]*\.html" | grep -v 'app/views/layouts' | wc -l
# Number of form fields
grep -r "text_field\|text_area\|file_field" ./app/views | wc -l
# Please rewrite the MyString definition, without using ruby keywords
# http://www.ruby-doc.org/docs/keywords/1.9/
MyString = Class.new(String) {
define_singleton_method(:alphabet) {
'abc'
}
define_method(:exclaim) { |*args|
count = args.first || 1
@mocoso
mocoso / .pyrc
Created October 29, 2012 13:14
pryrc
# Enable you to write 100.pounds, or 1.report_credit etc.
require './spec/support/sugar'
# The way we use spork means this isn't normally loaded, adding this in means
# that I can use factories in the console
require 'factory_girl_rails'
def me
Account.find_by_email_address('joel.chippindale@econsultancy.com')
end
@mocoso
mocoso / print_gollum.js
Created October 21, 2012 08:42 — forked from robcowie/print_github.js
Github print styling bookmarlet
javascript:(function(e,a,g,h,f,c,b,d)%7Bif(!(f=e.jQuery)%7C%7Cg%3Ef.fn.jquery%7C%7Ch(f))%7Bc=a.createElement(%22script%22);c.type=%22text/javascript%22;c.src=%22http://ajax.googleapis.com/ajax/libs/jquery/%22+g+%22/jquery.min.js%22;c.onload=c.onreadystatechange=function()%7Bif(!b&&(!(d=this.readyState)%7C%7Cd==%22loaded%22%7C%7Cd==%22complete%22))%7Bh((f=e.jQuery).noConflict(1),b=1);f(c).remove()%7D%7D;a.documentElement.childNodes%5B0%5D.appendChild(c)%7D%7D)(window,document,%221.3.2%22,function($,L)%7B$('%23header,%20.pagehead,%20.breadcrumb,%20.commit,%20.meta,%20%23footer,%20%23footer-push,%20.wiki-actions,%20%23last-edit,%20.actions').remove();%20$('%23files,%20.file').css(%7B%22background%22:%22none%22,%20%22border%22:%22none%22%7D);%20$('link').removeAttr('media');%7D);
@mocoso
mocoso / Gemfile
Created September 26, 2012 09:10
A rack based 'redirector'
source :rubygems
gem 'rack'
gem 'rack-rewrite'
gem 'activesupport'
group :test do
gem 'rspec'
gem 'rack-test'
end
@mocoso
mocoso / sketch.rb
Created June 29, 2012 16:18 — forked from mattwynne/sketch.rb
sketch for Matt Wynne
class Organization
def to_param
"42"
end
end
class Organisations
def self.save(organisation)
rand > 0.5
@mocoso
mocoso / default.rb
Created July 8, 2011 14:14
Audit recipe to keep an eye on EngineYard's cloud updates
# If you use EngineYard cloud you will be aware that they change their 'main'
# recipes on a regular basis and that EngineYard provide no information about
# what they have changed.
#
# This can make it difficult to keep your application's environment stable.
#
# Add a personalised version of this recipe to your custom recipes and your
# custom recipes will fail if EngineYard have changed the versions of (or removed)
# any of software you've told your audit recipe to check.
#