Skip to content

Instantly share code, notes, and snippets.

View deathbob's full-sized avatar

Bob Larrick deathbob

View GitHub Profile
@deathbob
deathbob / chunkybrawl.rb
Created June 29, 2011 19:25
Entry to CodeBrawl - ChunkyPNG edition
#! /usr/bin/env ruby
require 'rubygems'
require 'chunky_png'
image = ChunkyPNG::Image.from_file('input.png')
h = image.dimension.height
print "height #{h} \n"
w = image.dimension.width
print "width #{w} \n"
module Foo
def self.included(base)
class << base
attr_accessor :bar
end
base.instance_eval do
@bar = "pig"
end
end
end
@deathbob
deathbob / gist:1102683
Created July 24, 2011 14:38
Meta module madness
module Foo
def self.included(base)
class << base
attr_accessor :bar
end
base.instance_eval do
@bar ||= proc{self.snakes}.call
end
end
@deathbob
deathbob / gist:1102763
Created July 24, 2011 15:59 — forked from ianterrell/gist:1102751
Meta module madness
module Foo
def bar
@bar ||= self.snakes
end
def bar=(val)
@bar = val
end
end
def output name=((default=true); "caius")
puts "name: #{name.inspect}"
puts "default: #{default.inspect}"
end
output
# >> name: "caius"
# >> default: true
output "avdi"
@deathbob
deathbob / gist:1589597
Created January 10, 2012 15:26
FGO gems
actionmailer (2.3.14, 2.3.8, 2.3.5)
actionpack (2.3.14, 2.3.8, 2.3.5)
activerecord (2.3.14, 2.3.8, 2.3.5)
activeresource (2.3.14, 2.3.8, 2.3.5)
activesupport (2.3.14, 2.3.8, 2.3.5)
airbrake (3.0.9)
awesome_print (1.0.2)
builder (3.0.0)
bundler (1.0.21)
capistrano (2.9.0)
# What's the rspec 1 version of this?
# The context here is I'm maintaining a Rails 2.3 project, where there are very few tests, and the ones that exist are some
# test::unit, some rspec. We're trying to standardize on rspec going forward and port the existing test::unit stuff to
# rspec as time allows.
# I think I have to use rspec 1 because it's a rails 2.3 project.
# I tried a spec/views/users/activate.html.erb_spec.rb file, but ran into trouble when I couldn't figure out how to set up
# all the state necessary without things feeling very brittle.
# Because I was setting up all the state for the view, I could imagine a scenario where the controller code changed,
# which would cause the view to blow up in real life, even though the test for the view would continue to pass, because
ubuntu@ip-10-118-125-89:~$ sudo chef-client -l debug
[Fri, 04 May 2012 20:38:54 +0000] INFO: *** Chef 0.10.8 ***
[Fri, 04 May 2012 20:38:54 +0000] DEBUG: Loading plugin os
[Fri, 04 May 2012 20:38:54 +0000] DEBUG: Loading plugin kernel
[Fri, 04 May 2012 20:38:54 +0000] DEBUG: Loading plugin ruby
[Fri, 04 May 2012 20:38:54 +0000] DEBUG: Loading plugin languages
[Fri, 04 May 2012 20:38:54 +0000] DEBUG: ---- Begin ruby -e "require 'rbconfig'; puts %Q(target_cpu=#{::Config::CONFIG['target_cpu']},host_os=#{::Config::CONFIG['host_os']},target_vendor=#{::Config::CONFIG['target_vendor']},target_os=#{::Config::CONFIG['target_os']},target=#{::Config::CONFIG['target']},host_cpu=#{::Config::CONFIG['host_cpu']},platform=#{RUBY_PLATFORM},host=#{::Config::CONFIG['host']},bin_dir=#{::Config::CONFIG['bindir']},host_vendor=#{::Config::CONFIG['host_vendor']},version=#{RUBY_VERSION},release_date=#{RUBY_RELEASE_DATE},ruby_bin=#{::File.join(::Config::CONFIG['bindir'], ::Config::CONFIG['ruby_install_name'])},)" STDOUT ----
[Fri, 04
@deathbob
deathbob / gist:2785614
Created May 25, 2012 03:37
Overly complicated d3
<script>
var trans = [["2-21","129.68"],["2-22","92.79"],["2-23","196.22"],["2-24","187.71"],["2-25","16.47"],["2-26","18.5"],["2-27","110.48"],["2-28","122.61"],["2-29","114.11"],["3-01","121.74"],["3-02","267.23"],["3-03","167.61"],["3-04","10.26"],["3-05","46.32"],["3-06","40.76"],["3-07","309.39"],["3-08","71.91"],["3-09","246.11"],["3-10","148.21"],["3-11","10.01"],["3-12","118.58"],["3-13","109.69"],["3-14","125.81"],["3-15","116.23"],["3-16","201.83"],["3-17","64.68"],["3-19","44.28"],["3-20","118.25"],["3-21","365.65"],["3-22","216.62"]];
var vans = [["3-23","105.78"],["3-24","46.01"],["3-26","144.34"],["3-27","193.03"],["3-28","112.92"],["3-29","147.45"],["3-30","103.91"],["3-31","70.93"],["4-02","153.63"],["4-03","116.56"],["4-04","124.04"],["4-05","135.46"],["4-06","200.77"],["4-07","141.15"],["4-09","145.97"],["4-10","218.34"],["4-11","169.59"],["4-12","235.91"],["4-13","200.32"],["4-14","207.49"],["4-16","230.42"],["4-17","254.29"],["4-18","186.4"],["4-19","164.49"],["4-20","235.65"],["4-21"

A Friendlier Approach for CSS Color Manipulation

By Chris Eppstein and Michael Parenteau

These ideas build on ones proposed by Tab Atkins but expand the concepts to apply to any color value, not just named colors.

They provide the full power of Sass's color system while preserving a more human-readable system when multiple transformations are applied because the arguments are closer to the operations.