This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Module | |
# Takes symbols representing instance methods defined in the module. | |
# Returns a new anonymous module with only those instance methods defined. | |
def slice(*methods) | |
src = self | |
Module.new do | |
methods.each do |sym| | |
define_method(sym, src.instance_method(sym)) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl -I https://shopify.github.io/dashing/ | |
HTTP/1.1 200 OK | |
Date: Sat, 14 Jun 2014 16:57:15 GMT | |
Server: GitHub.com | |
Content-Type: text/html; charset=utf-8 | |
Last-Modified: Wed, 07 May 2014 03:44:03 GMT | |
Expires: Sat, 14 Jun 2014 17:07:15 GMT | |
Cache-Control: max-age=600 | |
Content-Length: 15154 | |
Accept-Ranges: bytes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
debounce : Time -> Signal a -> Signal a | |
debounce t sig = sig |> sampleOn (Time.since t sig |> keepIf not False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Mouse | |
import Array | |
buildAppDataMap delta pos history = | |
{ frameDelta=delta | |
, mousePosition=pos | |
, clickHistory=history } | |
arrayTakeLast n array = | |
let inputLen = Array.length array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module AttributeReaders | |
class <<self | |
# str = "foo" | |
# overrides = { | |
# another_reverse: :reverse, | |
# exclaimed: ->(str) { str + "!" }, | |
# to_sym: ->(str) { str.reverse.to_sym } | |
# } | |
# reader = AttributeReaders.object_reader(str, overrides) | |
# [:reverse, :another_reverse, :exclaimed, :to_sym].map(&reader) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# gemmate | |
# open the directory of a rubygem as a project in textmate | |
# responds to anything that `gem which` can handle | |
# e.g.: | |
# gemmate autotest | |
# => `mate /Library/Ruby/Gems/1.8/gems/ZenTest-3.11.0` | |
# gemmate active_record | |
# => `mate /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# branchmate | |
# opens whichever files you've modified in this git branch compared to master | |
target = ARGV[0] || 'master' | |
p (cmd = "git diff #{target} --name-only") | |
files = `#{cmd}`.split.reject {|f| f =~ /^vendor/} | |
puts files.join("\n") | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# debug_in | |
# call debugger only when the stack trace includes a certain file and/or method | |
# | |
# use like: | |
# debug_in(:file => 'order_test', :method => 'test_taxes_included') | |
# debug_in(:r => /taxes.*included/) | |
# | |
# put in test_helper.rb | |
def debug_in(options = {}) | |
debugger if caller.detect {|c| c =~ /#{(options[:file].to_s + ".rb") if options[:file]}.*#{("`" + options[:method].to_s + "'$") if options[:method]}/ && c =~ (options[:r] || //)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul> | |
<r:feed:items | |
url="http://feeds.boingboing.net/boingboing/iBag" | |
order="creator ASC"> | |
<r:feed:header for="creator"> | |
<h2><r:feed:creator /></h2> | |
</r:feed:header> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bd { | |
if [ -z $1 ]; then | |
n=1 | |
else | |
n=$1 | |
fi | |
pushd +$n > /dev/null | |
} | |
function fd { |
OlderNewer