Skip to content

Instantly share code, notes, and snippets.

View jlecour's full-sized avatar

Jérémy Lecour jlecour

View GitHub Profile
require 'connection_pool'
require 'redis'
require 'metriks'
class RedisClientWrapper
def initialize(options)
@options = options.delete(:pool)
@pool = ConnectionPool.new(@options) do
::Redis.new(options)
end
@jlecour
jlecour / var-from-selection.tmCommand
Created August 31, 2012 08:13 — forked from sellmerfud/var-from-selection.tmCommand
Textmate bundle command to create a variable declaration with the contents of the selection.
#!/usr/bin/env ruby -wKU
# Save: Nothing
# Input: Document
# Output: Replace Input
# Caret Placement: Line Interpolation
COCOA_DIALOG_COMMAND = "#{ENV["TM_SUPPORT_PATH"]}/bin/CocoaDialog.app/Contents/MacOS/CocoaDialog"
@madx
madx / LICENSE
Created April 5, 2012 09:16
Managing your identity in Git
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2012 François Vaux <madx+github@yapok.org>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
#!/usr/bin/tclsh8.5
#
# Usage: unmerged branch1 branch2
proc getlog branch {
lrange [split [exec git log $branch --oneline] "\n"] 0 100
}
proc diff {title c1 c2} {
puts "\n$title"
@rafl
rafl / elasticsearch_cache
Created March 22, 2012 16:32
Munin ElasticSearch plugins
#!/usr/bin/env perl
# Parameters supported:
#
# config
# autoconf
#
# Magic markers:
#%# family=auto
#%# capabilities=autoconf
@asenchi
asenchi / maximum_battery_life.md
Created March 19, 2012 15:58 — forked from mrflip/maximum_battery_life.md
maximum battery life checklist -- use before a long plane flight

Max Battery Life Checklist

Here is a checklist to follow if you want maximum battery life -- for instance if you're about to get on a long plane flight.

10 hour battery life on a non-SSD Macbook Pro 17"

Low power use checklist

With power connected:

@hotchpotch
hotchpotch / .pryrc
Created March 5, 2012 13:26
pry clipboard copy utility
def pbcopy(str)
IO.popen('pbcopy', 'r+') {|io| io.puts str }
output.puts "-- Copy to clipboard --\n#{str}"
end
Pry.config.commands.command "hiscopy", "History copy to clipboard" do |n|
pbcopy _pry_.input_array[n ? n.to_i : -1]
end
Pry.config.commands.command "copy", "Copy to clipboard" do |str|
namespace :log_resque do
desc "Print out (every 2 seconds) the number of busy and total workers for Resque"
task :working do
# In your Rails app directory :
# bundle exec rake log_resque:working --silent >> log/resque_working.log &
interval = 2.0
@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.
@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).