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 "thread" | |
Thread.abort_on_exception = true | |
class ReadWriteLock | |
def initialize | |
@lock_request_queue = SizedQueue.new(1) | |
@thread = Thread.new { thread_main } | |
@readers = 0 | |
@writer_queue = [] |
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 variable.c variable.c | |
index d142255..27b1237 100644 | |
--- variable.c | |
+++ variable.c | |
@@ -1851,7 +1851,7 @@ rb_const_get_0(VALUE klass, ID id, int exclude, int recurse, int visibility) | |
continue; | |
} | |
if (exclude && tmp == rb_cObject && klass != rb_cObject) { | |
- rb_warn("toplevel constant %"PRIsVALUE" referenced by %"PRIsVALUE"::%"PRIsVALUE"", | |
+ rb_raise(rb_eNameError, "toplevel constant %"PRIsVALUE" referenced by %"PRIsVALUE"::%"PRIsVALUE"", |
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
λ for shard in /dev/null*; do echo -n "$shard: "; command time dd if=/dev/zero of=$shard bs=1024 count=$((1024*1024)) |& tail -1; done | |
/dev/null: 0.87 real 0.17 user 0.69 sys | |
/dev/null0: 0.87 real 0.17 user 0.69 sys | |
/dev/null1: 0.87 real 0.17 user 0.69 sys | |
/dev/null2: 0.87 real 0.17 user 0.69 sys | |
/dev/null3: 0.88 real 0.18 user 0.70 sys | |
/dev/null4: 0.87 real 0.17 user 0.69 sys | |
/dev/null5: 0.86 real 0.17 user 0.68 sys | |
/dev/null6: 0.88 real 0.17 user 0.70 sys | |
/dev/null7: 0.87 real 0.17 user 0.69 sys |
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 "thread" | |
q = SizedQueue.new(1) | |
Thread.start do | |
q << "foo" | |
q << "bar" | |
end | |
p q.deq |
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
#!/bin/bash | |
if [ $# = 0 ]; then | |
echo "Usage: git pr-for <commit>" >&2 | |
exit 1 | |
fi | |
SHA="$(git log "$1"..master --ancestry-path --merges --reverse --oneline | grep 'Merge pull request' | head -1 | cut -d' ' -f1)" | |
if [ -n "$SHA" ]; then |
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
def pipe_to_pager(pager = "less") | |
r, w = IO.pipe | |
if fork | |
# parent | |
$stdin.reopen(r) | |
w.close | |
exec pager | |
else | |
# child |
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 MA; end | |
module MB; end | |
module MC; end | |
module MD; end | |
module ME; end | |
class A; end | |
class B < A | |
include MA |
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
Thread #0 was switched to 125044 times | |
Thread #1 was switched to 124994 times | |
Thread #2 was switched to 124994 times | |
Thread #3 was switched to 124993 times | |
Thread #4 was switched to 124993 times | |
Thread #5 was switched to 124994 times | |
Thread #6 was switched to 124994 times | |
Thread #7 was switched to 124993 times | |
1,000,000 thread switches took 2.143874 seconds |
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 | |
gem "twitter", "~> 5.3.0" | |
require "twitter" | |
def usage | |
abort "Usage: twitter-intersect (<username>.following|<username>.followers)..." | |
end | |
usage if ARGV.empty? |
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
#include <stdlib.h> | |
#include <stdio.h> | |
#include <luajit-2.0/lua.h> | |
#include <luajit-2.0/lauxlib.h> | |
int | |
main() | |
{ | |
lua_State* L = lua_open(); | |
if(!L) { |