Skip to content

Instantly share code, notes, and snippets.

@txus
txus / keybase.md
Created March 17, 2014 14:58
keybase.md

Keybase proof

I hereby claim:

  • I am txus on github.
  • I am txus (https://keybase.io/txus) on keybase.
  • I have a public key whose fingerprint is E0E1 1635 59E0 285A 5CBF DD8D 8CBD 973F AA87 A28E

To claim this, I am signing this object:

@txus
txus / brokers.rb
Created October 27, 2014 15:50
sigh
require 'json'
require 'verkehr/zookeeper'
module Verkehr
class Brokers
Broker = Struct.new(:id, :host, :port) do
def to_s
"#{host}:#{port}"
end
@txus
txus / wtf.rb
Created October 31, 2014 10:56
Haskell-like function composition in Ruby - let the mad horses unleash
require 'blankslate'
class Proc
def self.comp(f, g)
lambda { |*args| f[g[*args]] }
end
def *(g)
Proc.comp(self, g)
end
@txus
txus / core-typed-interop.clj
Last active August 29, 2015 14:19
Core Typed interop
(ns typed.core
(:require [clojure.core.typed :as t]))
(t/ann-datatype Foo [fooName :- t/Str])
(deftype Foo [fooName])
(t/ann-datatype Bar [barName :- t/Str])
(deftype Bar [barName])
(t/ann theName [(t/U Foo Bar) -> t/Str])
@txus
txus / core-typed-live-coding.clj
Created May 15, 2015 11:36
Live coding a lambda calculus with core.typed
(ns achilles.live
(:require [clojure.core.typed :as t]))
"term : x (Variable)
λx.term (Abstraction)
term term (Application)"
(t/ann-datatype TVar [name :- t/Str])
(deftype TVar [name])
1) Customer
Failure/Error: should_validate_uniqueness_of :email
could not find a Customer record in the database
# /Users/txus/.bundle/ruby/1.8/gems/remarkable_activerecord-4.0.0.alpha1/lib/remarkable_activerecord/matchers/validate_uniqueness_of_matcher.rb:49:in `find_first_object?'
# /Users/txus/.bundle/ruby/1.8/gems/remarkable-4.0.0.alpha1/lib/remarkable/dsl/assertions.rb:371:in `send'
# /Users/txus/.bundle/ruby/1.8/gems/remarkable-4.0.0.alpha1/lib/remarkable/dsl/assertions.rb:371:in `send_methods_and_generate_message'
# /Users/txus/.bundle/ruby/1.8/gems/remarkable-4.0.0.alpha1/lib/remarkable/dsl/assertions.rb:370:in `each'
# /Users/txus/.bundle/ruby/1.8/gems/remarkable-4.0.0.alpha1/lib/remarkable/dsl/assertions.rb:370:in `send_methods_and_generate_message'
# /Users/txus/.bundle/ruby/1.8/gems/remarkable-4.0.0.alpha1/lib/remarkable/dsl/assertions.rb:406:in `matches_collection_assertions?'
# /Users/txus/.bundle/ruby/1.8/gems/remarkable-4.0.0.alpha1/lib/remarkable/base.
# in customers_controller.rb
def CustomersController < ApplicationController
before_filter :load_languages, :only => :new
def new
...
end
protected
# Comparison between after_or_equal_to and
# before_or_equal_to behaviors (they should
# be the same, just that the former sends a
# >= and the latter a <=.
class Product < ActiveRecord::Base
validates :expiration_date, :date => {:before_or_equal_to => Time.now}
end
model = Product.new(:expiration_date => Time.now) # Should be valid
# Curl command to post "3 whatever" to daytum through your twitter account remotely!
# (Replace twitter_user, twitter_password, whatever and 3 as you wish)
# Note: you must have your twitter account linked to daytum (go to daytum settings)
curl -u twitter_user:twitter_password -d "text=whatever:3&user=daytum" http://twitter.com/direct_messages/new.xml
/Users/user/Code/project/vendor/plugins/backupmyapp/lib/backupmyapp/init.rb:5:in `included': undefined local variable or method `filter_chain' for ActionController::Base:Class (NameError)
from /Users/user/Code/project/vendor/plugins/backupmyapp/lib/backupmyapp/init.rb:4:in `class_eval'
from /Users/user/Code/project/vendor/plugins/backupmyapp/lib/backupmyapp/init.rb:4:in `included'
from /Users/user/Code/project/vendor/plugins/backupmyapp/init.rb:1:in `include'
from /Users/user/Code/project/vendor/plugins/backupmyapp/init.rb:1:in `send'
from /Users/user/Code/project/vendor/plugins/backupmyapp/init.rb:1
from /Users/user/.rvm/gems/ruby-1.8.7-p302@project/gems/railties-3.0.0.rc/lib/rails/plugin.rb:81
from /Users/user/.rvm/gems/ruby-1.8.7-p302@project/gems/railties-3.0.0.rc/lib/rails/initializable.rb:25:in `instance_exec'
from /Users/user/.rvm/gems/ruby-1.8.7-p302@project/gems/railties-3.0.0.rc/lib/rails/initializable.rb:25:in `run'
from /Users/user/.rvm/gems/ruby-1.8.7-p302@project/gems/railties-3.0.0.rc/