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
1.9.3p0 :004 > require 'pp' | |
=> true | |
1.9.3p0 :002 > p = proc { |a| pp proc_args: a } | |
=> #<Proc:0x0000010090b838@(irb):2> | |
1.9.3p0 :010 > p.call(1,2) | |
{:proc_args=>1} | |
1.9.3p0 :008 > stabby = ->(a) { pp stabby_args: a } | |
=> #<Proc:0x00000101099410@(irb):8 (lambda)> | |
1.9.3p0 :009 > stabby.call(1,2) | |
ArgumentError: wrong number of arguments (2 for 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
Mutant configuration: | |
Matcher: #<Mutant::Matcher::Method::Instance identification="SRSRB::CardEditorApp#card_models_as_dictionary"> | |
Filter: Mutant::Mutation::Filter::ALL | |
Strategy: #<Mutant::Strategy::Rspec::Full> | |
Subject: SRSRB::CardEditorApp#card_models_as_dictionary:/Users/cez/projects/srs-rb/lib/srsrb/rackapp.rb:110 | |
Alive: rspec:noop:SRSRB::CardEditorApp#card_models_as_dictionary:/Users/cez/projects/srs-rb/lib/srsrb/rackapp.rb:110:24ec0 (0.71s) | |
Killed: rspec:SRSRB::CardEditorApp#card_models_as_dictionary:/Users/cez/projects/srs-rb/lib/srsrb/rackapp.rb:110:3e242 (0.43s) | |
Killed: rspec:SRSRB::CardEditorApp#card_models_as_dictionary:/Users/cez/projects/srs-rb/lib/srsrb/rackapp.rb:110:5d14b (0.43s) | |
Killed: rspec:SRSRB::CardEditorApp#card_models_as_dictionary:/Users/cez/projects/srs-rb/lib/srsrb/rackapp.rb:110:3aca1 (0.42s) | |
Killed: rspec:SRSRB::CardEditorApp#card_models_as_dictionary:/Users/cez/projects/srs-rb/lib/srsrb/rackapp.rb:110:d8c97 (0.45s) |
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 'zlib' | |
require 'socket' | |
require 'thread' | |
WORKERID_BITS = 10 | |
MAX_WORKER_ID = -1 ^ (-1 << WORKERID_BITS) | |
SEQUENCE_BITS = 12 | |
MAX_SEQUENCE = -1 ^ (-1 << SEQUENCE_BITS) | |
SINCE_MILLIS = Time.utc(2012, 1, 1).to_f * 1000 |
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
web: (while true; do echo MARK $(date --iso-8601=seconds); sleep 5; done) & ruby --version; bin/rackup -Ilib -s puma rackup.ru -p $PORT | |
# Or slightly more clearly | |
web: rake resqueue:worker & ruby --version; bin/rackup -Ilib -s puma rackup.ru -p $PORT |
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 'hamster/hash' | |
original = Hamster.hash :foo => 42 | |
dumped = Marshal.dump(original) | |
undumped = Marshal.load(dumped) | |
STDERR.puts undumped[:foo] | |
STDOUT.puts dumped |
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
1 require 'rack/cors' | |
2 require 'sinatra' | |
3 | |
4 get '/' do | |
5 "Hello world" | |
6 end | |
7 | |
8 use Rack::Cors do | |
9 allow do | |
10 origins 'localhost:3000', '127.0.0.1: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
In [17]: pytz.UTC.localize(datetime.utcnow()).isoformat() | |
Out[17]: '2013-05-16T17:06:19.394052+00:00' | |
In [18]: (datetime.utcnow()).isoformat() | |
Out[18]: '2013-05-16T17:06:24.842408' | |
In [19]: |
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_relative 'mpsc' | |
class LoggerProxy | |
def initialize target | |
@target = target | |
@queue = MpscQueue.new | |
end | |
def start! | |
@reader, @writer = IO.pipe |
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
#define _XOPEN_SOURCE 700 | |
#include <stdio.h> | |
#include <stdlib.h> | |
int main(int argc, char **argv) { | |
int size = atoi(argv[1]); | |
char **resrv = calloc(size, sizeof(char*)); | |
int i = 0; size_t nread; | |
char *line = NULL; |
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 'sequel' | |
require 'tsort' | |
class TableCleaner | |
def initialize db, excluded_tables | |
@db = db | |
@excluded_tables = excluded_tables | |
end | |
def clean |