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
var fs = require('fs'); | |
var redis = require('redis'); | |
var client = redis.createClient(); | |
client.psubscribe('juggernaut'); | |
client.on('pmessage', function(pattern, channel, msg){ | |
var message = JSON.parse(msg); | |
var data = message.data; |
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
cat /etc/*-release | |
cat /etc/issue | |
cat /proc/version | |
dmesg | head -1 |
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
# I want this method in ruby-core | |
def let | |
yield | |
end | |
def fib(i) | |
let do |n = 1, result = 0| | |
if i == -1 | |
result | |
else |
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
require 'minitest/spec' | |
require 'minitest/autorun' | |
describe "class inheritance" do | |
it "inherits public singleton methods" do | |
superclass = Class.new | |
superclass.define_singleton_method(:pub_sing_meth) {} | |
subclass = Class.new(superclass) | |
subclass.singleton_methods.include?(:pub_sing_meth).must_equal true | |
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
W, H = 44, 54 | |
c = 7 + 42 * W | |
a = [0] * W * H | |
g = d = 0 | |
f = proc do |n| | |
a[c] += 1 | |
o = a.map {|z| " :#"[z, 1] * 2 }.join.scan(/.{#{W * 2}}/) | |
puts "\f" + o.map {|l| l.rstrip }.join("\n") | |
sleep 0.005 | |
d += 1 - 2 * ((g ^= 1 << n) >> 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
# In case you haven't seen +@ before, it works as a unary operator (as does -@) | |
# Example: | |
# | |
# a = A.new | |
# +a #=> RuntimeError: You must provide a block! | |
# a.send(:+@, &proc { "hello world!" }) #=> "hello world!" | |
class A | |
def +@ | |
if block_given? | |
yield |
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
diff --git a/lib/guard.rb b/lib/guard.rb | |
index 368d5aa..2795dc4 100644 | |
--- a/lib/guard.rb | |
+++ b/lib/guard.rb | |
@@ -398,10 +398,10 @@ module Guard | |
def get_guard_class(name) | |
name = name.to_s | |
try_require = false | |
- const_name = name.downcase.gsub('-', '') | |
+ const_name = name.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } |
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
~$ rvm gemset create mygems | |
'mygems' gemset created (/home/ben/.rvm/gems/ruby-1.9.2-p290@mygems). | |
~$ rvm gemset use mygems | |
~$ rvm gemset empty | |
/home/ben/.rvm/gems/ruby-1.9.2-p290@ already does not exist. | |
~$ rvm use 1.9.2 | |
Using /home/ben/.rvm/gems/ruby-1.9.2-p290 | |
~$ rvm gemset empty | |
/home/ben/.rvm/gems/ruby-1.9.2-p290@ already does not exist. | |
~$ rvm info |
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
# This seems like it does exactly what decent_exposure does... | |
# app/controllers/people_controller.rb | |
class PeopleController < ApplicationController | |
helper_method :people | |
def index | |
end | |
private |
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
$ pry | |
1.9.3 (main):0 > find-method puts | |
#<Class:0x000000018326c8>#puts | |
#<Module:0x00000001743398>#puts | |
IO | |
IO#puts | |
IO::writable | |
IO::writable#puts |