Skip to content

Instantly share code, notes, and snippets.

@alkema
alkema / node-argv.js
Created June 14, 2011 19:54
node argv
var sys = require('sys');
var arguments = process.argv.splice(2)[0];
console.log(sys.inspect(arguments))
@alkema
alkema / nowjs-join-path-based-group.js
Created June 14, 2011 16:40
nowjs join path based group
// Client
now.ready = function() {
now.changeGroup(window.location.pathname)
}
// Server
var app = express.createServer();
var nowjs = require("now");
var everyone = nowjs.initialize(app);
@alkema
alkema / config.ru
Created May 28, 2011 15:19
gollum rackup file
$:.unshift File.join(File.dirname(__FILE__), *%w[lib])
require 'rubygems'
require File.join(File.dirname(File.expand_path(__FILE__)), 'lib/gollum/frontend/app')
$path = '/var/gollum/wiki.git'
Precious::App.set(:gollum_path, $path)
run Precious::App
@alkema
alkema / letter-press-on-heroku.rb
Created April 9, 2011 21:10
letter-press-on-heroku
routes
map.connect "/images/letterpress/:letterpress.png", :controller => 'pages', :action => 'letterpress'
controller
def letterpress
send_file "tmp/letterpress/#{params[:letterpress]}.png", :disposition => 'inline'
end
@alkema
alkema / js-geolocation-to-geocoded-formatted-address.js
Created March 15, 2011 19:16
grab lat + lng from js, geocode and then fill in input as formatted address
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script>
var geocoder = new google.maps.Geocoder();
function success(position) {
var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
geocoder.geocode({'latLng' : latlng}, function(results, status){
$('#saddr').val(results[0].formatted_address);
});
}
jody@jodys-macbook-pro-2 ~/code/benefic (master) $ git pull
remote: Counting objects: 11, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 6 (delta 5), reused 0 (delta 0)
Unpacking objects: 100% (6/6), done.
From github.com:domain7/benefic
e58ffce..fa0dd49 master -> origin/master
Updating e58ffce..fa0dd49
Fast-forward
.../_client_organization_contact.html.erb | 10 +++++-----
@alkema
alkema / sms-via-enail.rb
Created September 17, 2010 13:38
sms-via-email.rb
class MobileProvider < ActiveRecord::Base
validates_uniqueness_of :name
end
class Mobile < ActiveRecord::Base
include ActionView::Helpers::NumberHelper
belongs_to :user
belongs_to :mobile_provider
before_validation :strip_non_numeric
pg_dump -Uuser db | gzip > filename.gz
scp host:~/filename.gz .
psql -U postgres
drop database db;create database db;
\quit
gunzip filename.gz
psql db < filename
wget http://www.five-ten-sg.com/libpst/packages/libpst-0.6.34.tar.gz
cd libpst-0.6.34
./configure
make
make test
make install
readpst -o ~/contacts ~/MS.pst
Opening PST file and indexes...
#!/usr/bin/env ruby
# github + launchy = gaunchy
# open your current repo (+ path) in your browser
# $ gaunchy.rb app/models
require 'rubygems'
require 'git'
require 'launchy'
g = Git.open('.')