Skip to content

Instantly share code, notes, and snippets.

View jlecour's full-sized avatar

Jérémy Lecour jlecour

View GitHub Profile
@pasviegas
pasviegas / mongodb
Created March 27, 2010 01:26
Simple monit script for mongodb
check host mongodb with address localhost
start program = "/usr/bin/sudo /opt/database/mongo/bin/mongod"
stop program = "/usr/bin/sudo /usr/bin/pkill -f mongod"
if failed port 28017 protocol HTTP
request /
with timeout 10 seconds
then start
# I cannot credit the original author
class Haversine
#EARTH_RADIUS = 3963.19 # miles
EARTH_RADIUS = 6371 # kilometers
RADIAN_PER_DEGREE = Math::PI / 180.0
def self.distance(lat1, lng1, lat2, lng2)
lat1_radians = lat1 * RADIAN_PER_DEGREE
lat2_radians = lat2 * RADIAN_PER_DEGREE
@jlecour
jlecour / gist:591321
Created September 22, 2010 07:49
Geokit-rails and Rails 3

In my effort for porting the geokit-rails plugin to Rails 3, I've found that it would really benefit a full rewrite of the query composition parts.

My work can be followed here : http://github.com/jlecour/geokit-rails/ (make sure to look at the gem branch until it is merged into master) Any help is welcome.

The current version, compatible with Rails 2, has 2 main methods (find and count) and some utility methods, that are making some changes to the select/conditions/limit/order/… parts of the options hash passed to ActiveRecord and then call the super related method on the model's class.

With ActiveRecord 3 and its scope approche, I think we don't need to mess with the hash anymore if we use the power of scopes. I would be cleaner, more chainable and reusable, …

That said, we have to consider the kind of additions Geokit makes to a typical query. As a brief summary, here is how it works.

@jlecour
jlecour / stages_dev_autrement.md
Created October 1, 2010 15:16
Autrement propose des stages dans son équipe Développement

Autrement propose des stages dans son équipe Développement

L'équipe technique d'Autrement (Timothée Barray, Christophe Moins et Jérémy Lecour) s'amuse (enfin travaille) avec plein de technos différentes pour produire ses sites web (http://chambresapart.fr/, http://hotelhotel.com/, …) et ses applications mobiles (Apple iOS et Android). Pour ça on manipule des langages aussi variés que Ruby (et Rails), PHP (et Symfony), Objective-C, Java et Javascript, on utilise des bases de données SQL et NOSQL, on fait du design en HTML/CSS, …

Nous recherchons 1 ou 2 stagiaires à qui nous proposons de participer pendant quelques mois à la mise en place, la maintenance et l'évolution de technologies et composants stables/éprouvés autant que chercher du côté d'éléments émergents/innovants pour utiliser au mieux les outils disponibles.

Plus concrè

@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
@colinux
colinux / subtitles-renamer.sh
Created January 27, 2011 23:21
Rename subtitles files according to tv shows names found in a directory
#!/bin/bash
# Renames subtitles files according to tv shows names found in a directory
# Acceped syntaxes for season/episode are: 304, s3e04, s03e04, 3x04 (case insensitive)
#
# Usage:
# Put this gist somewhere in your $PATH, like /usr/local/bin/subtitles-renamer
# Chmod +x it
# cd ~/YourHolidaysTvShowsWithSubtitles
# subtitles-renamer
@thbar
thbar / Gemfile
Created February 13, 2011 17:46
How to use a bundler group to define a reduced-memory consumption environment for your workers
# these gems won't be loaded by our Rakefile with WORKER_ENVIRONMENT enabled
gem 'rails', '3.0.3'
gem 'haml', '3.1.0.alpha.147'
# ...
# load these both for the app and the workers
group :default, :worker do
gem 'mongo', '1.1.5'
gem 'bson', '1.1.5'
gem 'bson_ext', '1.1.5'
Some brief instructions on how to use Sprocket 2 in Rails to get CoffeeScript
powered JS and SASS powered CSS with YUI compression all via the magic of rack.
This stuff will be native in Rails 3.1 and the layout of the files on the
filesystem will be different but this guide will get you working with it
while we wait for all that to finalize.
Ignore the number prefixes on each file. This is just to ensure proper order in the Gist.
It's based on eric1234 gist https://gist.github.com/911003. ijust made it 3.1 compliant in terms of convention
@fxn
fxn / post.md
Created May 23, 2011 21:08
GeoPlanet data with ancestor chain cache imported in 10 minutes

GeoPlanet data with ancestor chain cache imported in 10 minutes

Yahoo! provides its GeoPlanet data as three separate TSV files, available for download here.

That's a database with some 17 million records:

  • 5.7 million records: locations (aka places).
  • 2.2 million records: alternative names for each place (aka aliases).
  • 9.6 million records: matrix of neighbourhoods per place (aka adjacencies).
@thbar
thbar / deploy.rb
Created December 14, 2011 15:57
Custom capistrano task to do db:schema:load
# cap deploy deploy:db_schema_load
namespace :deploy do
desc "Load the initial schema - it will WIPE your database, use with care"
task :db_schema_load, :roles => :db, :only => { :primary => true } do
puts <<-EOF
************************** WARNING ***************************
If you type [yes], rake db:schema:load will WIPE your database
any other input will cancel the operation.