Skip to content

Instantly share code, notes, and snippets.

View olauzon's full-sized avatar

Olivier Lauzon olauzon

View GitHub Profile
require 'autotest/redgreen'
# require 'autotest/pretty'
# require 'autotest/snarl'
# require 'autotest/timestamp'
module Autotest::Growl
def self.growl title, msg, img, pri=0, sticky=""
system "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{sticky}"
end
#!/usr/bin/env ruby
# Place this script in your shell's load path
require 'rubygems'
begin
require 'highline/import'
rescue
puts "'sudo gem install highline' in your system Ruby"
end
# Generate .rvmrc file in a project directory
@olauzon
olauzon / git-commit-prefixes
Created May 16, 2011 20:26 — forked from indexzero/git-commit-prefixes
Short list of Git commit prefixes used at Nodejitsu
[api]: New apis / changes to apis
[test]: Update test/* files
[dist]: Changes to submodules, version bumps, updates to package.json
[minor]: Small changes
[doc]: Updates to documentation
[ux]: Updates to UX
[fix]: Bug fixes
[bin]: Update binary scripts associated with the project
[merge]: Resolved git merge from upstream or otherwise
[refactor]: Refactor of existing code with no external API changes
# Set postgis-1.5 path.
$ POSTGIS_SQL_PATH=`pg_config --sharedir`/contrib/postgis-1.5
# Creating the template spatial database
$ createdb -E UTF8 -T template0 template_postgis
# and add PLPGSQL language support.
$ createlang -d template_postgis plpgsql
# Loading the PostGIS SQL routines.
$ psql -d template_postgis -f $POSTGIS_SQL_PATH/postgis.sql
# Array#join vs String#+
require 'benchmark'
n = 1_000_000
Benchmark.bm do |x|
x.report('Array#join :') {
n.times { ['this', 'is', 'a', 'test'].join(' ') }
}
x.report('String#+ :') {
@olauzon
olauzon / useragent_example.js
Created December 16, 2011 18:01
useragent module examples
var http = require('http'),
userAgent = require('useragent');
http.createServer(function (request, response) {
var userAgentString = request.headers['user-agent'],
ua_obj = userAgent.parse(userAgentString),
is = userAgent.is(userAgentString),
content = "";
12345678901234567890123456789012345678901234567890123456789012345678901234567890
00000000001111111111222222222233333333334444444444555555555566666666667777777777
@olauzon
olauzon / ruby_wat.rb
Created May 11, 2012 19:40
Ruby WAT
# 1.8.7
[1, 2, 3].to_s
# => "123"
# 1.9.3p194
[1, 2, 3].to_s
# => "[1, 2, 3]" # WAT?
# `Array#to_s` is an alias to `Array#inspect`
@olauzon
olauzon / counter.cql
Created June 12, 2012 17:35
Cassandra counter example
-- Works with CQL SPEC 3.0.0 and Cassandra 1.1.1
-- Usage: cqlsh -3 < counter.cql
CREATE TABLE counters (
counter_name varchar,
value counter,
PRIMARY KEY (counter_name)
)
WITH comment='Aggregate counters';
@olauzon
olauzon / memoize-vs-deref.core.clj
Created August 13, 2013 18:08
Simple Clojure memoize vs deref benchmark
(ns memoize-vs-deref.core
(:use criterium.core))
(def test-vec
[{ :a 1 }
{ :f 6 }
{ :c 3 }
{ :d 4 }
{ :g 7 }
{ :h 8 }