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.
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.
| require 'bundler/inline' | |
| ## | |
| # Get dependencies | |
| gemfile do | |
| source 'https://rubygems.org' | |
| gem 'pg' | |
| gem 'activerecord', require: 'active_record' | |
| gem 'benchmark-ips' | |
| gem 'pry' |
| 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) |
| 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' |
| Shoes.app do | |
| end |
| @ -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 | |
| From: Murray Steele <[email protected]> | |
| To: London Ruby Users Group <[email protected]> | |
| Subject: [LRUG] [GIVEAWAY] Copies of "The Well Grounded Rubyist (2nd Edition)" to give away | |
| Hi all, | |
| As announced at the start of the meeting on Monday the nice folks at | |
| Infinitium Global have decided to give a little back to the community in | |
| some way. One thing they were keen for is that they were giving back to | |
| the community in a way that would help it grow and encourage folk just |
| def find_previous_table_for(element) | |
| find_previous_sibling_of_type(element, 'table') | |
| end | |
| def find_previous_sibling_of_type(element, element_type_to_find) | |
| previous_siblings(element).find do |previous_element| | |
| previous_element.node_name == element_type_to_find | |
| end | |
| end |
| class BWT | |
| def encode(string) | |
| chars = "#{string}$".chars | |
| rotations = [] | |
| chars.length.times. | |
| inject(chars) do |new_chars, _| | |
| rotations << new_chars | |
| new_chars.rotate | |
| end |
I hereby claim:
To claim this, I am signing this object: