Skip to content

Instantly share code, notes, and snippets.

View avocade's full-sized avatar
💭
Founder & CTO at Multiply.co

Oskar Boëthius Lissheim avocade

💭
Founder & CTO at Multiply.co
View GitHub Profile
#!/usr/bin/env xcrun swift
// http://learnyouahaskell.com/functionally-solving-problems
enum Label : String { case A = "A", B = "B", C = "C" }
typealias Section = (Int, Int, Int)
typealias RoadSystem = [Section]
typealias Path = [(name:Label, price:Int)]
// Helpers, A little bit of F# in my life
infix operator |> { associativity left }
def calculate_range_start_of_months
#Catacrocker obscurism
[current = range.begin.beginning_of_month].tap { |result| result << current while (current += 1.month) <= range.end }
end
require 'eventmachine'
require 'json'
require 'mimic'
require 'logger'
module FakeCampfireServer
class Handler
def initialize(ipc)
@ipc = ipc
@ipc.delegate = self
class Sequence
class << self
def sequences
Enumerator.new do |y|
sequence = Sequence.new
while sequence
sequence = sequence.next
break unless sequence
require 'rubygems'
require 'rspec'
require 'sequence'
describe Sequence do
describe "validation" do
it "should be able to sum its items" do
sequence = Sequence.new(1, 2, 3, 4)
The Redis Book (don't know still what the final title will be ;)
authors: Pieter Noordhuis, Ted Nyman, Salvatore Sanfilippo, 33.33333333% each
writing it with O'Reilly
01-introduction 11.26% (31 pages)
02-volatile-keys 7.76% (21 pages)
03-data-integrity 12.6% (35 pages)
04-replication 6.16% (17 pages)
05-messaging 5.16% (14 pages)
@seivan
seivan / gist:750598
Created December 21, 2010 21:00
User class
class User < ActiveRecord::Base
def following_ids
FriendShip.following_ids_for(self)
end
def followings
User.where(:id => following_ids)
end
def following?(user)
@porras
porras / why_steak.md
Created January 8, 2011 14:48
Why Steak (over Cucumber)

Why Steak (over Cucumber)

From here

  • Plain text have no value if people writing and reading the specs are developers. Code is natural language for developers (specially if that code is Ruby). Having a client who reads the specs is a possible situation and Cucumber is cool there, but in my experience that situation is not the most common one. If in your case there's no value in having your specs in English rather than in Ruby, Cucumber is an additional layer of abstraction in exchange of nothing.

  • There's a myth about clients writing the specs. It sounds like a unicorn to me, but let's take it. Still, I wouldn't want it. Clients are experts in problems, I am expert in solutions. I want the client to describe the problem I have to solve, not to describe the solution.

  • Some people say Cucumber is cool because you write the stories, the client validates them, and then you can start developing. That is not Agile. The on

def self.create_single_girlfriend_for_user(user_id, girlfriend_id, friend_hash)
if friend_hash['gender'] == 'female'
R.hset "user:#{user_id}:girlfriends", girlfriend_id, friend_hash['relationship_status']
if friend_hash['relationship_status'] == "Single"
return Friend.build_for_user_id(user_id, girlfriend_id, friend_hash)
end
end
end
@markbates
markbates / gist:1163187
Created August 22, 2011 18:53
Launch TextMate with Pry (.pryrc)
require 'digest/md5'
require 'fileutils'
Pry.config.commands.command "mate" do
FileUtils.mkdir_p(File.expand_path('~/tmp/pry'))
file = File.expand_path("~/tmp/pry/_#{Digest::MD5.hexdigest(FileUtils.pwd).to_s}.rb")
system "mate -w #{file}"
Object.class_eval(`cat #{file}`)
end