Skip to content

Instantly share code, notes, and snippets.

View atom.rb
class Atom
attr_reader :symbol
def initialize(symbol)
@symbol = symbol
def ==(other)
self.symbol == other.symbol
zetter / enrolment_spec.rb
Last active Aug 29, 2015
Enrolment rspec feature spec
View enrolment_spec.rb
feature 'Enrolment' do
scenario 'Enrolling in a course' do
course = FactoryGirl.create(:course)
learner = FactoryGirl.create(:learner)
login_as learner
visit course_path(course)
expect(page).to have_content('Thanks for joining!')
zetter / enrolling.feature
Last active Aug 29, 2015
Enrolling in a course Cucumber feature
View enrolling.feature
Feature: Enrolment
Scenario: Enrolling in a course
Given there is a course
And I am logged in as a learner
When I enrol on a course
Then the course should appear in 'my courses'
zetter /
Created Dec 6, 2014
Deploying my personal site using s3cmd
jekyll build
s3cmd sync -r --acl-public public/ s3://
View gist:295978
class Hash
def hash_map()
result = self.inject({}) do |hash, (k, v)|
hash.merge(yield(k, v))
{:a => 1, :b => 2}.hash_map {|k,v| {k.to_s*2, v*2}} # => {"aa"=>2, "bb"=>4}
View Cycle through colours using jquery
<script src="" type="text/javascript"></script>
<script src="" type="text/javascript"></script>
<script type="text/javascript">
View random slicer
#! /usr/bin/ruby
# Saves two random and contiguous cropped images from a larger image
# Written so an image that is too big can be displayed on a dual screen desktop
IMAGE_NAME = "file_small.png"
IMAGE_WIDTH, IMAGE_HEIGHT =[0x10..0x18].unpack('NN')
# # For non-pngs:
# IMAGE_WIDTH, IMAGE_HEIGHT = [12304, 8605]
View Unzoomify
# Hacked from
require 'fileutils'
require 'open-uri'
require 'rubygems'
require 'rmagick'
require 'rexml/document'
class Zoomify
zetter / Bubble Free Click
Created Mar 26, 2011
jquery extension to register click events that won't bubble. Call instead of click(func).
View Bubble Free Click
jQuery.fn.preventDefaultClick = function(f) {{, e);
return this;
zetter / deconstruct.markdown
Created Jan 31, 2012
therubygame deconstruct by @czetter
View deconstruct.markdown

therubygame deconstruct by @czetter

This is a deconstuction of matematikaadit's submission to therubygame challenge 5; 'Roman numerals. What are they good IV?'. The goal of the challenge is to take a string representing a roman numeral as input and return the integer that the numeral represents.

matematikaadit currently has the honour of the shortest (by character count) submission for this challenge. At first glance I didn't understand how it worked so I re-wrote and analyzed it until I did.

Making it readable

matematikaadit's original submission: