Skip to content

Instantly share code, notes, and snippets.

@boriscy
boriscy / install-ruby-debug-ubuntu-ruby-1.9.3
Created November 1, 2011 18:57
ruby-debug in ruby-1.9.3 and ubuntu
#To install ruby-debug on Ubuntu ruby-1.9.3 you need to download from http://rubyforge.org/frs/?group_id=8883
linecache19-0.5.13.gem
ruby_core_source-0.1.5.gem
ruby-debug19-0.11.6.gem
ruby-debug-base19-0.11.26.gem
#Then in your console
export RVM_SRC=/your/path/to/ruby-1.9.3
@ajokela
ajokela / distance.rb
Created October 16, 2011 20:53
Ruby/Rails - Distance between latitude/longitude points
GeoName.find_by_sql("SELECT ordered.* FROM (SELECT gn.*, round(distance.d * 6371.0, 2) AS distance_km, round(distance.d * 6371.0 * 0.621371192, 2) as distance_miles FROM
(SELECT (2*atan2(sqrt(calcs.a), sqrt(1-calcs.a)))::numeric d, calcs.id FROM
(SELECT (sin(consts.dlat/2) * sin(consts.dlat/2) + sin(consts.dlon/2) * sin(consts.dlon/2) * cos(consts.lat1) * cos(consts.lat2)) as a, consts.id FROM
(SELECT f.id, abs((#{self.exif_data.latitude} - f.latitude)*(#{Math::PI}/180)) AS dlat,
abs((#{self.exif_data.longitude} - f.longitude)*(#{Math::PI}/180)) AS dlon,
#{self.exif_data.latitude} * (#{Math::PI}/180) as lat1,
f.latitude * (#{Math::PI}/180) as lat2 FROM geo_names f) consts) calcs) distance,
geo_names gn WHERE gn.id = distance.id ORDER BY distance.d ASC LIMIT 10) ordered ORDER BY random() LIMIT 1")
@linuxbender
linuxbender / install-rvm-rubyonrails.bash
Created October 9, 2011 18:31
Install rvm rubyonrails 3.1.1 linux (ubuntu in my case)
# rvm homepage :http://beginrescueend.com/
# rubyonrails homepage :http://rubyonrails.org/
# using gemset : http://beginrescueend.com/gemsets/using/
# js env : https://github.com/sstephenson/execjs
# heroku hosting : http://www.heroku.com/
# github repo : https://git.521000.bestlow
# gmate for gedit : https://github.com/gmate/gmate
# ruby dependencies
sudo apt-get install build-essential openssl libssl-dev libreadline6 libreadline6-dev curl
@andreacfm
andreacfm / resque_worker_upstart.sh
Created October 3, 2011 15:33
resque workers via upstart runned by unpriviledge user
#!upstart
description "Workers [resque]"
start on (local-filesystems and net-device-up IFACE=eth0)
stop on shutdown
respawn
respawn limit 99 5
console none