Skip to content

Instantly share code, notes, and snippets.

View kuahyeow's full-sized avatar

Thong Kuah kuahyeow

View GitHub Profile
@tmm1
tmm1 / ruby19_date_marshal.rb
Created February 6, 2013 06:07
Fix marshal incompatibility between Date/DateTime on 1.8 and 1.9
require 'date'
class Date
if RUBY_VERSION < '1.9'
## accept 1.9 marshaled data on 1.8
## based on ext/date/date_core.c d_lite_marshal_dump_old
def marshal_load(data)
nth, jd, df, sf, of, @sg = data
real_jd =
@raggi
raggi / validate_local_cache.sh
Last active December 11, 2015 23:39
A script to validate your local gem cache against the public s3 repositories. If you find mismatches that contain both local and remote values, please post them in comments.
#!/usr/bin/env sh
if ! which md5sum > /dev/null; then
echo Install md5sum
exit 1
fi
if ! which curl > /dev/null; then
echo Install curl
exit 1
@benjchristensen
benjchristensen / index.html
Created August 9, 2011 05:38
Simple Sparkline using SVG Path and d3.js
<html>
<head>
<title>Simple Sparkline using SVG Path and d3.js</title>
<script src="http://mbostock.github.com/d3/d3.v2.js"></script>
<style>
/* tell the SVG path to be a thin blue line without any area fill */
path {
stroke: steelblue;
stroke-width: 1;
fill: none;
@lifthrasiir
lifthrasiir / README.txt
Created July 10, 2011 19:04
A little program that converts "a hundred" to "100". (Updated!)
These little programs read a spelt (EDIT: it is not "spoken") number from the
standard input and write the corresponding number to the standard output. Weigh
just 243 bytes and 227 bytes of C. (EDIT: was originally 256 and 240 bytes.)
The longer version handles numbers up to 999,999,999,999,999, that is, just
shy of 1,000 trillions. The shorter version handles numbers up to 19,999,999,
or 999,999,999 if your "int" is 64 bits long. The input should be correct,
although it will handle "a" and "and" correctly and ignore some invalid
words.
@jarib
jarib / gist:774802
Created January 11, 2011 17:58
fx launch debug script
require "rubygems"
require "selenium-webdriver"
$DEBUG = true
profile = Selenium::WebDriver::Firefox::Profile.new
profile.log_file = File.expand_path("firefox.log")
profile.log_file.gsub!("/", "\\") if Selenium::WebDriver::Platform.windows?
begin
@kashif
kashif / mk_postgis_template.sh
Created November 7, 2010 16:16
make a postgis template
# 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
@matthewtodd
matthewtodd / asset_tag_helper.rb
Created July 12, 2010 04:57
Rails + Sass + Asset Fingerprints + Heroku
# Ensure AssetTagHelper has been loaded before we try to monkey-patch it.
require 'action_view/helpers/asset_tag_helper'
module ActionView::Helpers::AssetTagHelper
# Insert the asset id in the filename, rather than in the query string. In
# addition to looking nicer, this also keeps any other static file handlers
# from preempting our Rack::StaticCache middleware, since these
# version-numbered files don't actually exist on disk.
def rewrite_asset_path(source)
source.insert source.rindex('.'), "-#{rails_asset_id(source)}"