I hereby claim:
- I am davidbalbert on github.
- I am davidbalbert (https://keybase.io/davidbalbert) on keybase.
- I have a public key whose fingerprint is C59D 970A 2A49 D78B ACE7 6722 F447 4DD8 FC80 DAB5
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
(def hmm-state (atom {:value "Hmm..."})) | |
(defn hmm [state owner] | |
(reify | |
om/IRender | |
(render [_] | |
(om.dom/textarea #js {:value (:value state) | |
:onChange (fn [e] (.log js/console (.. e -target -value)))})))) | |
(om/root |
slashes = ["|", "/", "-", "\\"] | |
slashes.cycle do |s| | |
system "clear" | |
puts ":#{s}" | |
sleep 0.3 | |
end |
# This will be pasted into the REPL | |
require 'csv' | |
# these were extracted from the first line of the CSV | |
GoogleGroupContact = Struct.new(:email_address, :nickname, :group_status, :email_status, :email_preference, :posting_permissions, :join_year, :join_month, :join_day, :join_hour, :join_minute, :join_second, :time_zone) | |
class InteractiveContactFinder | |
def self.find_all(contacts) | |
@@done = false |
# Returns the number of user+thread combinations with more than one visited | |
# status, this should be greater than zero before the fix and zero after the | |
# fix. | |
VisitedStatus.group([:user_id, :thread_id]).having("COUNT(*) > 1").count.size | |
# The number of user+thread combinations with at least one visited status. This | |
# number should remain the same before and after the fix. | |
VisitedStatus.group([:user_id, :thread_id]).count.size | |
# The fix: Group all visited statuses by user+thread, select the visited statuses. |
module Enumerable | |
def reductions(sym = nil, &block) | |
raise LocalJumpError, "no block given" unless sym || block | |
if sym | |
block = sym.to_proc | |
end | |
arr = to_a | |
This is a partial implementation of Piumarta and Warth's Open, extensible object models paper in Ruby. It is the simpler implementation where bind
returns a method rather than a closure that wraps the method and some arbitrary piece of data. It also doesn't implement any method caching. I'm not super happy with the the split between in the "low level" Ruby object system, and the "higher level" system that we're implementing, but I don't have time to do a redesign before publishing today's PotW :).
Running the program will drop you into a shell where you can play with the object model. It's nicer if you have pry installed because then you'll have access to local variables like symbol
and s_delegated
.
class Object | |
def not | |
NotProxy.new(self) | |
end | |
end | |
class NotProxy | |
def initialize(obj) | |
@obj = obj | |
end |
#!/usr/bin/env ruby | |
if ARGV.empty? | |
$stderr.puts("usage: #{$0} rdio-or-spotify-url") | |
exit 1 | |
end | |
require 'net/http' | |
require 'uri' |
begin | |
require 'bundler/inline' | |
rescue LoadError => e | |
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler' | |
raise e | |
end | |
gemfile(true) do | |
source 'https://rubygems.org' | |
gem 'rails', github: 'rails/rails' |