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 / Slide 11: my first ruby.diff
Last active November 8, 2016 23:25
My First Ruby - code snippets from slides - see: http://h-lame.com/talks/my-first-ruby/
@ -24,8 +24,8 @@ class Config < Hash
}
end
- def initialize(name)
- self[Config::Name] = name
+ def initialize(name=nil)
+ self[Config::Name] = name if name != nil
end
@h-lame
h-lame / Slide 13: The simplest shoes app - code.rb
Last active April 2, 2017 19:14
Tying your shoes - code snippets from slides - see: http://h-lame.com/talks/tying-your-shoes/
Shoes.app do
end
@h-lame
h-lame / bom-removal.rake
Created June 30, 2017 12:12
Rake task to hook into assets:precompile in a rails app and remove any BOMs that are inserted by sprockets/sass in CSS files (and their gzipped siblings)
namespace :assets do
task :remove_bom => :environment do
require 'sprockets/utils/gzip'
# object that has enough of the Sprockets::Asset API to be
# used in the Sprockets::Utils::Gzip class without us needing
# to use the real class which needs more data
class DeBOMedCSSAsset < Struct.new(:file_name)
def content_type
'text/css'
@h-lame
h-lame / benchmark.rb
Created July 20, 2017 13:55
Benchmarking some alternate implementations for checking if a BOM is present in a string and removing it.
require 'benchmark'
# you'll want this to be a largeish file that is representative of the kinds
# of CSS files you'll be using this on in the real world. I used a compiled
# version of application.css from https://github.com/alphagov/government-frontend
css = File.binread "bom.css"
class BomBench
def remove_bom_force_encoding_slice!(input)
input.force_encoding('UTF-8').slice!(0)
@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'
@h-lame
h-lame / .Generating averages of faces.md
Last active January 7, 2025 14:18
Code for generating digital averages of faces extracted from a macos photo library, or any collection of images with face metadata in an XMP file.

What?

Inspired by the work of Jason Salavon I wanted to extract all the photos of my face and generate the average of them.

This is the ruby code for doing that.

Pre-requisites

osxphotos