Skip to content

Instantly share code, notes, and snippets.

Avatar

Lachlan Pitts parameme

  • Bentley Systems
  • Brisbane, Australia
View GitHub Profile
@parameme
parameme / datafix.rb
Created Dec 21, 2016
Quick and dirty Heroku datafix runner
View datafix.rb
class Datafix
def initialize(options)
@options = options
@context = options[:context] || {}
@table = options[:table] || {}
@table_name = @table[:name] || 'tmp_datafix'
@table_reader_sql = @table[:reader_sql] || "SELECT * FROM #{@table_name}"
@table_row_action = @table[:row_action]
@apply_action = options[:apply_action]
@connection = options[:connection] || ActiveRecord::Base.connection
View scrabble_benchmarking.rb
POINTS = {
"A" => 1, "B" => 3, "C" => 3, "D" => 2,
"E" => 1, "F" => 4, "G" => 2, "H" => 4,
"I" => 1, "J" => 8, "K" => 5, "L" => 1,
"M" => 3, "N" => 1, "O" => 1, "P" => 3,
"Q" => 10, "R" => 1, "S" => 1, "T" => 1,
"U" => 1, "V" => 4, "W" => 4, "X" => 8,
"Y" => 4, "Z" => 10
}
@parameme
parameme / serializable_sha1_using_ffi.rb
Created Apr 2, 2012
Quick and dirty way to serialize and restore ruby Digest::SHA1 using FFI
View serializable_sha1_using_ffi.rb
require 'ffi'
require 'digest'
# Thanks to all ruby hackers everywhere who have donated their knowledge to the commons!
# With thanks to @judofyr for ffi/"evil.rb" - https://gist.github.com/2238438
class Object
def memory_location
object_id * 2
end