Skip to content

Instantly share code, notes, and snippets.

View rkh's full-sized avatar
👀
heeeyyyy

Konstantin Haase rkh

👀
heeeyyyy
View GitHub Profile
def require_or_install(path, gem_name = path, version = '> 0')
require path
rescue LoadError
require 'rubygems'
require 'rubygems/user_interaction'
require 'rubygems/dependency_installer'
installer = Gem::DependencyInstaller.new
installer.install gem_name, version
@postmodern
postmodern / c_parser.rb
Created January 16, 2011 04:24
An ANSI C Parser using the Ruby Parslet library.
#
# A C Parser using the Parslet library.
#
# ANSI C Grammar:
#
# * http://www.lysator.liu.se/c/ANSI-C-grammar-l.html
# * http://www.lysator.liu.se/c/ANSI-C-grammar-y.html
#
require 'parslet'
@sstephenson
sstephenson / gist:771090
Created January 8, 2011 19:41
Automatic *.test host resolution in OS X
$ sudo su -
# mkdir /etc/resolver
# cat > /etc/resolver/test
nameserver 127.0.0.1
port 2155
^D
^D
$ brew install dnsmasq
$ dnsmasq --port=2155 --no-resolv --address=/.test/127.0.0.1
$ ping foo.test
require 'benchmark'
n = (ARGV.shift || 1000000).to_i
def append(words, n)
n.times { res = words.inject("") {|string, p| string << "#{p}_"} }
end
def join_under(words, n)
n.times { res = words.map{|s| s}.join("_") }

StillMaintained status buttons

Nice status buttons you can add to your README file in your Github repositories to show your project’s current status, fetched from StillMaintained:

   

For a live demo, check out StillMaintained’s own README.

Code

def stat(args)
p :stat => args
end
def xtest(number)
p "number is: #{number}"
return false if number == 3
return true
end
@igrigorik
igrigorik / webapp.rb
Created November 13, 2010 21:28
Inspired by @JEG2's talk at Rubyconf... Any ruby object, as a webapp! 'Cause we can. :-)
require 'rubygems'
require 'rack'
class Object
def webapp
class << self
define_method :call do |env|
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?)
[200, {}, send(func, *attrs)]
end

Building MLVM version of OpenJDK (Java 1.7) on Mac OS X

Take a look at the comments and code in update.sh.

I use update-usr-local.sh after a successful build to copy the new JVM into /usr/local.

I add pickjdk.sh into my ~/.bash_profile to allow easy switching between multiple JVMs.

I use create_tarball.sh to make a copy of the build to share.

PaaS: The good the bad and the ugly.
VMware will be hosting a technology meetup on Thursday night 11/11, at
the Newberry room, Hilton New Orleans Riverside, 6pm-8pm local time.
Join us for an open discussion where Engine Yard, Heroku and VMware
will share their experience of building a scalable PaaS solution.
What to expect? no slides, lots of beer and exciting debates.

Google closure JavaScript minifier

Super cheapo (and super effective!) minification.

Usage:

In Ruby:

code = 'alert("hello there");'