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! s:Ruby(l1,l2,fn) | |
exe a:l1 . ',' . a:l2 .'!ruby -n ' . a:fn | |
endfunction | |
command! -nargs=1 -range -complete=file Ruby call s:Ruby(<line1>,<line2>,<q-args>) |
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 express = require('express'); | |
var app = express(); | |
app.get('/', function(req, res){ | |
res.send('Hello World'); | |
}); | |
app.listen(3000); |
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 http = require('http'); | |
http.createServer(function (req, res) { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end('Hello World\n'); | |
}).listen(1337, '127.0.0.1'); | |
console.log('Server running at http://127.0.0.1:1337/'); |
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
# ... | |
SINATRA_ENV = ENV.fetch "SINATRA_ENV", "development" | |
# ... | |
DataMapper.setup :default, "sqlite3://#{File.expand_path("../db", __FILE__)}/bookmarx_#{SINATRA_ENV}.db" |
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
# part of spec_helper.rb | |
ENV['SINATRA_ENV'] = 'test' | |
# ... | |
require 'database_cleaner' | |
# ... | |
RSpec.configure do | conf | | |
# ... |
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
Dir.new("/tmp").each_path.to_a # ---> [ ["aaa", "/tmp/aaa"], ["bbb", "/tmp/bbb"], ... ] | |
# alternatively / additionally | |
Dir.each_path( "/tmp" ).to_a # ---> same result |
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
%{0x12 0x13 0x14}.split.map{ |x| x.to_i(16).inc }.inject(&:+) | |
%{0x12 0x13 0x14}.split.map(&sendmsg(:to_i, 16).and(sendmsg(:inc))).inject(&sendmsg(:+)) |
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
describe OpenHash do | |
let( :from_hash ){ {a: 42, b: 43} } | |
subject do | |
described_class.new from_hash | |
end | |
context "read access by both methds" do | |
it{ subject.a.should eq( 42 )} | |
it{ subject[:a].should eq( 42 )} | |
end | |
context "write access by both methods" do |
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() { | |
var a, aHash, b, putab; | |
putab = function() { | |
return console.log("a: " + a + ", b: " + b); | |
}; | |
aHash = { | |
a: 1, | |
b: 2, |