View bin_packing.rb
require "minitest/autorun"
require "benchmark/ips"
class CachingPack
def self.call(inventory, order)
return if inventory.nil? || inventory.empty?
return if inventory.inject(:+) < order
loop do
r = cached_pack(inventory, order)
View instructors_ungreeted_students.rb
gem 'activerecord', '~> 4.2'
require 'active_record'
require "minitest/autorun"
require 'minitest/pride'
require 'logger'
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
View gist:5a24567e7f24c5c238969dfde2e8aa5e
for i in $(find app/views/ -type f) ; do echo $(grep -R $(echo $i | sed "s/.*\/_\?\([^.]*\).*/\1/") app/ | wc -l) $i ; done | sort -rn | grep "^0" | sed 's/^0 //' | xargs git rm
View scrabble_cheater.md

Scrabble Cheater

  • I'd like you to help me cheat at Scrabble. I'd like you to write some code to give me all possible words that can be created given a set of tiles. The maximum number of tiles you can have in Scrabble is seven, so you'll need to find all of the words that can be made out of those tiles.

On most unix systems (including Mac OS X), you can find a word dictionary in "/usr/share/dict/words" - let's assume that all of these words (including "zymogenic"!) are up valid for scrabble. Feel free to use your own custom dictionary, but this will do for this purpose.

Here's sample code that reads in all of the words into an array, removes newlines, and downcases them.

words = File.readlines("/usr/share/dict/words").map(&:chomp).map(&:downcase)
View css_diff.rb
branches = %w[ master switch-to-sassc ]
tmp = Pathname.new(Dir.tmpdir)
branches.each do |branch|
asset_dir = tmp + "assets_#{branch}"
if asset_dir.exist?
puts "#{asset_dir} exists, skipping"
next
end
View gist:d6e91605ba744090c2a54466ea3ad29a
# Find all strings in a CSS file or files that start with a '.' and
# stop on some common CSS delimiters.
# This is only looking at _map.scss, but you could look at any other file or even
# app/assets/stylesheets if you wanted to see everything.
grep -hro "\.[^ .,():]\+" app/assets/stylesheets/partials/mobile/_map.scss |
# The sort | uniq part makes it so we don't look for duplicates.
sort |
uniq |
# Loop over the things we just found.
while read i ; do
View gist:59edc5b147f6dd1aad4c58ad47741f0a
# Find all thing strings in a CSS file or files that start with a '.' and
# stop on some common CSS delimiters.
# This is only looking at _map.scss, but you could look at any other file or even
# app/assets/stylesheets if you wanted to see everything.
grep -hro "\.[^ .,():]\+" app/assets/stylesheets/partials/mobile/_map.scss |
# The sort | uniq part makes it so we don't look for duplicates.
sort |
uniq |
# Loop over the things we just found.
while read i ; do
View debride_file_extension_fix.diff
diff --git a/lib/debride.rb b/lib/debride.rb
index 54e2f4f..7730457 100755
--- a/lib/debride.rb
+++ b/lib/debride.rb
@@ -35,31 +35,36 @@ class Debride < MethodBasedSexpProcessor
end
def self.load_plugins proj = PROJECT
- unless defined? @@plugins then
- @@plugins = []
View debride_test.sh
source "$HOME/.rvm/scripts/rvm"
for i in $(rvm list strings | sort) ; do
{ rvm use $i@debride-test --create ; \
ruby -v ; \
rvm gemset empty --force > /dev/null ; \
gem install debride debride-erb ; \
debride test.html.erb ; \
}