Skip to content

Instantly share code, notes, and snippets.

View deepak's full-sized avatar

Deepak Kannan deepak

View GitHub Profile
@panicsteve
panicsteve / gist:1641705
Created January 19, 2012 18:26
Form letter template for acquired startups
Dear soon-to-be-former user,
We've got some fantastic news! Well, it's great news for us anyway. You, on
the other hand, are fucked.
We've just been acquired by:
[ ] Facebook
[ ] Google
[ ] Twitter
sasha:rubinius brian$ irb
ruby-1.9.3-p0 :001 > __ENCODING__
=> #<Encoding:UTF-8>
ruby-1.9.3-p0 :002 > s = "\u{61}"
=> "a"
ruby-1.9.3-p0 :003 > s.encoding
=> #<Encoding:UTF-8>
ruby-1.9.3-p0 :004 > re = Regexp.new s
=> /a/
ruby-1.9.3-p0 :005 > re.encoding
@emboss
emboss / gist:1614643
Created January 15, 2012 06:00
Krypt Asn.1 decoding performance
Krypt Asn.1 decoding performance for Rubinius, JRuby and CRuby
****** Rubinius ******
[martin@localhost krypt]$ rbx -X19 -v
rubinius 2.0.0dev (1.9.3 b976944f yyyy-mm-dd JI) [x86_64-unknown-linux-gnu]
[martin@localhost krypt]$ rbx -X19 -Ilib -I../krypt-core/lib bm/bm_asn1.rb
user system total real
Krypt::Asn1.decode String(n=1000) 0.002000 0.000000 0.002000 ( 0.002414)
OpenSSL::Asn1.decode String(n=1000) 0.254962 0.006999 0.261961 ( 0.508823)
@peterc
peterc / unary.rb
Created November 8, 2011 16:44
Ruby unary operator overriding demo
class MagicString < String
def +@
upcase
end
def -@
downcase
end
def ~
@jorgenpt
jorgenpt / objc_calling.rb
Created November 3, 2011 08:15
Objective-C-esque calling convention in Ruby (or: Why I shouldn't be let near method_missing)
# See the bottom of the file for how this actually works.
module ObjC
def method_missing(method, *args)
ObjCCall.new(self, [], []).send(method, *args)
end
end
class ObjCCall
def initialize(obj, selector, args)
module MultiBlock
class NoBlockError < StandardError; end
class Catcher < BasicObject
def initialize(&blk)
@self = blk.binding.eval "self"
@blocks = {}
@mode = :catch
instance_eval &blk

From the standpoint of OSSL (Ruby’s OpenSSL binding), 1.9.3 is a small release; bug fixes, performance improvements, official OpenSSL 1.0.0 support and a few API enhancements. We had a new digital time-stamp and ASN.1 Template(DSL) implementation presented by Martin Boßlet, but we could not merge those bleeding-edge new features into 1.9.3, since there's no Ruby developer who can review it. It was quite obvious for us to ask him to be a maintainer of OSSL, as an expert in crypto and network security.

Since then, he helped us to clean up lots of OSSL issues piled on our issue tracker, by fixing SEGV bugs, consulting with users, and tailoring the build system to fit OpenSSL versions/variants. Though he discreetly didn’t merge his new feature implementations into 1.9.3, it seems clear that you can utilize those at the next release.

OSSL is the best language binding implementation of OpenSSL in the way of offering most OpenSSL features through an easy API with some help from Ruby. Without Martin Boßlet's help,

@headius
headius / gist:1234935
Created September 22, 2011 14:38
OS X 'pickjdk' command with single-command selection and updated JDK location
#!/bin/bash
#
# Provides a function that allows you to choose a JDK. Just set the environment
# variable JDKS_ROOT to the directory containing multiple versions of the JDK
# and the function will prompt you to select one. JAVA_HOME and PATH will be cleaned
# up and set appropriately.
_macosx()
{
if [ $(uname -s) = Darwin ]; then
How to add cmd-left-arrow and cmd-right-arrow (without shift) key bindings to the mac os x Terminal
app if the Lion install removed this bindings from your system.
1) Open "System Preferences".
2) Go to "Keyboard".
3) Select the "Keyboard Shortcuts" tab.
4) Select "Application Shortcuts" from the list of items in the left.
5) Press "+" to add a new shurtcut.
6) As "Application" select "Terminal", as "Menu Title" use: "Select Next Tab". For the "Keyboard Shortcut" field just select the field and press cmd-right-arrow.
7) Repeat again from step 5, using "Select Previous Tab" as Menu Title and pressing cmd-left-arrow as keyboard shortcut.
@fogus
fogus / about.md
Created August 11, 2011 00:28 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer