Skip to content

Instantly share code, notes, and snippets.

View h-lame's full-sized avatar
💀
a momentary diversion on the road to the grave

Murray Steele h-lame

💀
a momentary diversion on the road to the grave
View GitHub Profile
@h-lame
h-lame / Benchmark semver ordering in Postgresql.rb
Last active March 16, 2024 16:44 — forked from Bodacious/Benchmark semver ordering in Postgresql.rb
Benchmarking different SEMVER ordering strategies in PostgreSQL
require 'bundler/inline'
##
# Get dependencies
gemfile do
source 'https://rubygems.org'
gem 'pg'
gem 'activerecord', require: 'active_record'
gem 'benchmark-ips'
gem 'pry'
module Scoring
def self.included(base)
base.class_eval do
let(:__score_keeper) { ScoreKeeper.new }
extend ScoreHelpers
include ScoreMatchers
end
end
class ScoreKeeper
@h-lame
h-lame / gist:300181
Created February 10, 2010 09:35 — forked from sandro/gist:204016
# ARCHFLAGS may or may not matter - I set mine up this way just in case.
~$ echo $ARCHFLAGS
-arch i386 -arch x86_64
# Be sure to compile ruby with --enable-shared
~$ rvm install 1.9.1 --debug --reconfigure -C --enable-shared=yes
# Test to ensure that --enable-shared worked
~$ ruby -e "require 'rbconfig'; puts Config::CONFIG['ENABLE_SHARED']"
yes
# something like ...
# I think this goes in specs/support/whatever.rb
def it_should_be_invalid_without(*fields)
object_name = described_class.name.underscore
fields.each do |field|
it "should fail if #{field} is missing" do
instance_variable_get("@#{object_name}").send(:"#{field}=", nil)
instance_variable_get("@#{object_name}").should_not be_valid_for_create
@h-lame
h-lame / gist:279963
Created January 18, 2010 12:12 — forked from tomlea/gist:279962
class SomeController
before_filter :find_product
before_filter :sanitise_segment
def show
@product.reviews.for_segment(@segment).order_by(sort_order)
end
def show_extended_detail
class Schedule
def initialize(service)
@service = service
end
attr_accessor :schedule
def day
(1..23).map { [] }