Skip to content

Instantly share code, notes, and snippets.

View btaitelb's full-sized avatar

Ben Taitelbaum btaitelb

View GitHub Profile
module Omnomnivore
def omnomname(name_extension)
define_method "name" do
@name + name_extension
end
end
end
##
# Usage:
require './dice_game'
class WaitForOdds
include DiceGame
def winner?
@rolls ||= []
if @rolls.size >= 3
@rolls[-3..-1].all?{|r| r % 2 == 1}
else
require './dice_game'
class WaitFor7
include DiceGame
def winner?
last_roll == 7
end
end
module DiceGame
def roll
die1 = rand(1..6)
die2 = rand(1..6)
@rolls ||= []
@rolls << die1+die2
end
def last_roll
require './animal'
class Panda < Animal
def initialize
super(2)
puts "Panda#initialize"
end
def speak
class Animal
attr_reader :legs
attr_accessor :name
def initialize(legs = 4)
@legs = legs
puts "Animal#initialize in #{__FILE__}"
end
def self.classname_from_filename
@btaitelb
btaitelb / github_light.user.js
Created February 11, 2017 00:15
make github light again
/* Instructions
1. Open chrome://extensions
2. Drag this file into the chrome window
*/
// ==UserScript==
// @match https://*.github.com/*
// ==/UserScript==
function fixHeader() {
el = document.getElementsByClassName("header-dark")[0]
module Cacheable
def self.extended(base)
@@unaliased_methods = {}
@@cacheable_methods = Module.new
end
def method_added(m)
if @@unaliased_methods[m]
cache_method(m)
#!/usr/bin/env expect
set timeout 5
spawn meteor login
expect "Username:" { send "$env(METEOR_USERNAME)\r" }
expect "Password:" { send "$env(METEOR_PASSWORD)\r" }
@btaitelb
btaitelb / wp_domain_count.rb
Created May 7, 2014 19:20
How many recently visited domains used wordpress?
#!/usr/bin/env ruby
## Dependencies:
## * curl
## * jq (not really needed, but I like it)
## * sqlite
## * quit chrome before running this since the History file is locked
require 'uri'