Skip to content

Instantly share code, notes, and snippets.

View avocade's full-sized avatar
💭
Designing domains and coding clojure for Fluent.to

Oskar Boëthius Lissheim avocade

💭
Designing domains and coding clojure for Fluent.to
View GitHub Profile
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)
@lukeredpath
lukeredpath / process_last_months_finance_reports.rb
Created November 15, 2010 13:28
Loop through each finance report and run it using my process_finance_report script, creating an invoice in FreeAgent.
#!/usr/bin/env ruby
SECONDS_IN_DAY = (24*60*60)
REPORT_ROOT = File.expand_path("~/Documents/Business/Accounts/iTunes Finance Reports")
# I group US and WW on the same invoice as they are both in USD
INVOICE_GROUPS = [%w{AU}, %w{CA}, %w{GB}, %w{EU}, %w{US WW}, %w{JP}]
one_month_ago = Time.now - (30 * SECONDS_IN_DAY)
# My "fetch_finance_reports" script puts reports in a sub-dir e.g. 2010-09-Aug
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
@MyArtChannel
MyArtChannel / development.rb
Created April 25, 2011 20:42
Use Pry as IRB replacement in rails 3 console
# Add this to the end of your development.rb and add
#
# gem 'pry'
#
# to your Gemfile and run bundle to install.
silence_warnings do
begin
require 'pry'
IRB = Pry
@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
@Jaybles
Jaybles / UIDeviceHardware.h
Created October 28, 2011 19:33
UIDeviceHardware - Determine iOS device being used
//
// UIDeviceHardware.h
//
// Used to determine EXACT version of device software is running on.
#import <Foundation/Foundation.h>
@interface UIDeviceHardware : NSObject
- (NSString *) platform;
@tomstuart
tomstuart / gist:1466504
Created December 12, 2011 10:40
FizzBuzz in the lambda calculus in Ruby
>> IF = -> b { b }
=> #<Proc:0x007fb4e4049cc8 (lambda)>
>> LEFT = -> p { p[-> x { -> y { x } } ] }
=> #<Proc:0x007fb4e403d680 (lambda)>
>> RIGHT = -> p { p[-> x { -> y { y } } ] }
=> #<Proc:0x007fb4e4028ff0 (lambda)>
>> IS_EMPTY = LEFT