Skip to content

Instantly share code, notes, and snippets.

View deepak's full-sized avatar

Deepak Kannan deepak

View GitHub Profile
@holman
holman / SAFE-RUBY.rb
Created February 16, 2011 05:38
This shows some of my favorite ways to ensure robust, high-security Ruby Applications.
require 'net/https'
module SecurityModule
class HighSecurity
class ReallyHighSecurity
def self.turn_on_safe_connections
OpenSSL::SSL::VERIFY_NONE
end
end
end
@AlanQuatermain
AlanQuatermain / gist:830865
Created February 17, 2011 02:59
All the external private APIs referenced by iBooks.app version 1.2.1
From PrivateFrameworks/Bom.framework:
U _BOMCopierCopyWithOptions
U _BOMCopierCountFilesInArchive
U _BOMCopierFree
U _BOMCopierNew
U _BOMCopierSetCopyFileFinishedHandler
U _BOMCopierSetCopyFileStartedHandler
U _BOMCopierSetCopyFileUpdateHandler
U _BOMCopierSetFatalErrorHandler
U _BOMCopierSetFatalFileErrorHandler
@funny-falcon
funny-falcon / patch-1.9.2-gc.patch
Created March 5, 2011 11:11
GC tunning simple patch ruby 1.9.2 p180
diff --git a/gc.c b/gc.c
--- a/gc.c
+++ b/gc.c
@@ -77,6 +77,41 @@ void *alloca ();
#ifndef GC_MALLOC_LIMIT
#define GC_MALLOC_LIMIT 8000000
#endif
+#define HEAP_MIN_SLOTS 10000
+#define FREE_MIN 4096
+
[1 : 0] eric@kiccoro:/Users/eric > wget http://bazaar.launchpad.net/~graphite-dev/graphite/main/download/head:/whisper.py-20080505183243-3ypo8j4r6x1np8hq-2/whisper.py
--2011-03-19 13:11:15-- http://bazaar.launchpad.net/~graphite-dev/graphite/main/download/head:/whisper.py-20080505183243-3ypo8j4r6x1np8hq-2/whisper.py
Resolving bazaar.launchpad.net... 91.189.90.11
Connecting to bazaar.launchpad.net|91.189.90.11|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 21690 (21K) [text/x-python]
Saving to: `whisper.py'
100%[================================================================================================>] 21,690 90.5K/s in 0.2s
def self.local_ip_address
require 'socket'
# turn off reverse DNS resolution temporarily
orig, Socket.do_not_reverse_lookup =
Socket.do_not_reverse_lookup, true
# does not actually hit network
UDPSocket.open do |s|
s.connect '64.233.187.99', 1
s.addr.last

Output of benchmarking/pipeline.rb with hiredis C extension and pure Ruby implementation on MRI 1.9 and JRuby.

MRI 1.9.2 with hiredis extension

                              user     system      total        real
set                       0.370000   0.260000   0.630000 (  1.231756)
set (pipelined)           0.080000   0.000000   0.080000 (  0.110779)
lpush+ltrim               0.360000   0.250000   0.610000 (  1.231982)
lpush+ltrim (pipelined)   0.080000   0.010000   0.090000 (  0.142768)
$ git clone github:lenary/guides.git
Cloning into guides...
remote: Counting objects: 255, done.
remote: Compressing objects: 100% (216/216), done.
remote: Total 255 (delta 111), reused 163 (delta 35)
Receiving objects: 100% (255/255), 1.49 MiB | 564 KiB/s, done.
Resolving deltas: 100% (111/111), done.
$ cd guides
$ git remote -v
@brianmario
brianmario / config.ru.rb
Created April 21, 2011 06:11
minimal rails3 app
# minimal rails3 app
require 'action_controller'
Router = ActionDispatch::Routing::RouteSet.new
Router.draw do
root :to => 'site#index'
end
class SiteController < ActionController::Metal
@jimweirich
jimweirich / RubyCodingHigh.txt
Created June 25, 2011 02:55
Ruby Coding High Lyrics and Chords
Ruby Coding High
Weirich / Denver
G C D
It was born in the mountains of a far and distant land,
G C
Bringing hope to a world lost and drear.
G Em C D
Created as a promise to coders far and wide,
@jimweirich
jimweirich / mystery_test.rb
Created July 25, 2011 22:31
Testing Mystery Solved
# ...
620: if ENV['RAILS_ENV'] == 'test'
621: print "."
622: elsif
623: # ... code elided ...
624: end
# ...