Skip to content

Instantly share code, notes, and snippets.

View hannahwhy's full-sized avatar

Hannah Yip hannahwhy

View GitHub Profile
$ bundle exec irb
ruby-1.8.7-p302 > require 'pp'
=> ["PP"]
ruby-1.8.7-p302 > require 'active_support'
=> true
ruby-1.8.7-p302 > resp = %q{<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>
ruby-1.8.7-p302'> <cas:authenticationSuccess>
ruby-1.8.7-p302'> <cas:user>username</cas:user>
ruby-1.8.7-p302'> <cas:proxyGrantingTicket>PGTIOU-84678-8a9d...</cas:proxyGrantingTicket>
ruby-1.8.7-p302'> <cas:proxies>
@hannahwhy
hannahwhy / original.c
Created January 19, 2011 05:17
modification of rb_get_expanded_load_path to handle /a/b/../c
diff --git a/load.c b/load.c
index 185d6e0..5e6b9d0 100644
--- a/load.c
+++ b/load.c
@@ -48,14 +48,6 @@ rb_get_expanded_load_path(void)
VALUE ary;
long i;
- for (i = 0; i < RARRAY_LEN(load_path); ++i) {
- VALUE str = rb_check_string_type(RARRAY_PTR(load_path)[i]);
@hannahwhy
hannahwhy / json_fragment_resolution.rb
Created February 25, 2011 17:29
an implementation of JSON Schema's fragment resolution algorithm
require 'uri'
##
# Attempts to resolve a fragment identifier (`identifier`) in a deserialized
# JSON object (`object`).
#
# This method always returns a pair of values. The first value is the
# resolution result, and the second value is the portion of the identifier
# that was successfully resolved. The characteristics of these values
# therefore directly depend on resolution success:
@hannahwhy
hannahwhy / gist:934406
Created April 21, 2011 12:44
recreation of the listerine server
require 'redis'
require 'sinatra'
# to do:
# (1) checkout expiration
# (2) /introduce (not sure what it does)
# (3) support vidid harvesters
# more?
R = Redis.new
import tornado.ioloop
import tornado.web
import redis
import urllib2
r = redis.Redis(host='127.0.0.1', port=6379, db=0)
current_block="test"
class MainHandler(tornado.web.RequestHandler):
def get(self):
7e5fc6e2eae2c8465088d0c5a4104765 ./profile_photo.jpg
56e3bf31b2ff5437fa9f091737f862db ./photos/88/25/115288/34773709564203.jpg
7e5fc6e2eae2c8465088d0c5a4104765 ./photos/88/25/115288/29698781930.jpg
4331120d7aeff58781bebd476037148c ./photos/88/25/115288/20292609011806.jpg
e29545258ac7e746a3f64e7d3791cb55 ./photos/88/25/115288/34671797120964.jpg
52288d1ef1509d2c1a26ebed8f519fe6 ./photos/88/25/115288/34773831612115.jpg
5f28e71f153b997f3f50b0124661f1f0 ./photos/88/25/115288/34773600824556.jpg
2061bd92e457fffdbe7279c44884021e ./photos/88/25/115288/34773359147162.jpg
93e261a398e39a7e8d046ec0e173342c ./photos/88/25/115288/29603344283.jpg
@hannahwhy
hannahwhy / nothread.c
Created August 2, 2011 17:30
omp_get_max_threads crash in pthread body on OS X Snow Leopard using libgomp
$ gcc -Wall -g -lgomp nothread.c ; ./a.out ; echo $?
2
$ gcc -Wall -g -lgomp thread.c ; ./a.out ; echo $?
Segmentation fault
139
$ gdb ./a.out
GNU gdb 6.3.50-20050815 (Apple version gdb-1518) (Sat Feb 12 02:52:12 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
$ bundle exec cucumber -f pretty features/cas_proxy.feature:18
Using the default profile...
@cas @no_jruby
Feature: CAS proxy authentication
Background: # features/cas_proxy.feature:4
SQL (0.5ms) SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
@hannahwhy
hannahwhy / run
Created September 30, 2011 22:25
$ uname -mprsv
Darwin 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64 i386
$ ~/src/rubinius/bin/rbx -v
rubinius 2.0.0dev (1.8.7 1a792212 yyyy-mm-dd JI) [x86_64-apple-darwin10.8.0]
$ ~/src/rubinius/bin/rbx zlib_crash_example.rb
Segmentation fault
$ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]
$ ruby zlib_crash_example.rb
$ echo $?
@hannahwhy
hannahwhy / 0001-Example-for-compression-of-large-strings.-1178.patch
Created October 4, 2011 06:51
[PATCH] Zlib::GzipWriter#write segfaults when given large (2^23 byte) strings
From 28fa610732b8621bbac1019be00622ac77caee24 Mon Sep 17 00:00:00 2001
From: David Yip <[email protected]>
Date: Fri, 30 Sep 2011 21:34:24 -0500
Subject: [PATCH 1/2] Example for compression of large strings. #1178.
The expected output was generated by the following Ruby program run in
Ruby 1.8.7-p352:
require 'stringio'
require 'zlib'