Skip to content

Instantly share code, notes, and snippets.

View octplane's full-sized avatar
👨‍💻
I came here for the javascript jokes and was disappointed

Pierre Baillet octplane

👨‍💻
I came here for the javascript jokes and was disappointed
View GitHub Profile
@octplane
octplane / backtrace
Created July 5, 2012 17:07
Backtrace of stuck resque worker
[Thread debugging using libthread_db enabled]
[New Thread 0x7f8672507700 (LWP 3582)]
0x00000000004ba000 in find_entry (table=0xaa60c8, key=86239440, value=0x7fffa63b4a78) at st.c:451
in st.c
#0 0x00000000004ba000 in find_entry (table=0xaa60c8, key=86239440, value=0x7fffa63b4a78) at st.c:451
#1 st_lookup (table=0xaa60c8, key=86239440, value=0x7fffa63b4a78) at st.c:505
#2 0x00000000004f53dd in rb_mark_generic_ivar (obj=86239440) at variable.c:910
#3 0x000000000041ecc2 in gc_mark_children (objspace=0x9ac990, ptr=86239440, lev=1) at gc.c:1868
#4 0x000000000041f9fc in mark_locations_array (start=0xaef68d0, end=<value optimized out>) at gc.c:1603
#5 gc_mark_locations (start=0xaef68d0, end=<value optimized out>) at gc.c:1616
@octplane
octplane / .gdbinit
Created July 3, 2012 13:29
Dump Stacktrace in ruby 1.9.3 in gdb
define ruby_stack_trace
set $VM_FRAME_MAGIC_METHOD = 0x11
set $VM_FRAME_MAGIC_BLOCK = 0x21
set $VM_FRAME_MAGIC_CLASS = 0x31
set $VM_FRAME_MAGIC_TOP = 0x41
set $VM_FRAME_MAGIC_FINISH = 0x51
set $VM_FRAME_MAGIC_CFUNC = 0x61
set $VM_FRAME_MAGIC_PROC = 0x71
set $VM_FRAME_MAGIC_IFUNC = 0x81
set $VM_FRAME_MAGIC_EVAL = 0x91
@octplane
octplane / hop.py
Created June 20, 2012 21:12
Extend tasks
class SelfableTask(tasks.WrappedCallableTask):
def __init__(self, callable, *args, **kwargs):
super(SelfableTask, self).__init__(callable, *args, **kwargs)
if hasattr(callable, '__module__'):
self.__module__ = callable.__module__
def run(self, *args, **kwargs):
old_module = env.get('current_module', None)
old_task = env.get('current_task', None)
env['current_task'] = self.__name__
@octplane
octplane / cdargs.fush
Created June 6, 2012 13:01
fish function file for cdargs
function ca
command cdargs --add=":$argv:$PWD"
end
function cv
cdargs "$argv"; and cd (cat "$HOME/.cdargsresult")
end
function _cdargs_completion
cat ~/.cdargs | cut -d' ' -f1 | xargs echo
end
@octplane
octplane / gist:2049344
Created March 16, 2012 09:58
Bundler bug report "Could not find gem 'commonthread-flickr_fu (= 0.3.0) ruby' in the gems available on this machine."
# Broken Command:
16/03 10:34 ~/github/bundle.t% bundle install
Fetching gem metadata from http://gemcutter.org/......
Fetching gem metadata from http://gemcutter.org/..
Could not find gem 'commonthread-flickr_fu (= 0.3.0) ruby' in the gems available on this machine.
[1] 83758 exit 7 bundle install
# Look for missing gem:
#!/usr/bin/env ruby
require 'rubygems'
require 'json'
require 'open-uri'
require 'yaml'
critical = false
warn= false
@octplane
octplane / feed.sh
Created December 19, 2011 13:25
One liner feeder from script outputting a value to graphite
while [ 1 ]; do DAT=$(./varnish_elapsed_undirected); echo $DAT; echo "transient.fast.f04.varnish.$DAT `date +'%s'`" | socat - TCP4:graphite_server:2003; done
@octplane
octplane / chef-capistrano-init.rb
Created December 8, 2011 15:56
Add chef search capability when using roles in capistrano Tasks
require 'rubygems'
require 'chef/client'
require 'chef/run_status'
require 'ohai'
require 'chef/mixin/language'
# Override the default role search in capistrano
# can be used to combine chef searches in capistrano land:
# task :master_update, :roles => 'recipes:chef\:\:server' do
# ...
@octplane
octplane / changes.sh
Created December 6, 2011 12:24
Upload changes cookbook / roles
#!/bin/sh
COOKBOOKS_FOLDER=cookbooks
[ -d .git ] && {
git fetch
if [ -f .git/latest_changes ]; then
SRC="$(cat .git/latest_changes).."
else
SRC=""
@octplane
octplane / mapping.json
Created November 28, 2011 13:42
Mapping table
mapper.mappingSource()
{"users":{"_all":{"analyzer":"fuzzy"},"_source":{"enabled":false},"properties":{"album_names":{"type":"string","index_name":"album_name","boost":0.8,"include_in_all":true},"created_at":{"type":"date","store":"yes","format":"dateOptionalTime","include_in_all":false},"description":{"type":"string","boost":0.5,"include_in_all":true},"dversion":{"type":"integer"},"features":{"type":"string","include_in_all":false},"firstname":{"type":"string","boost":0.8,"store":"yes","include_in_all":true},"furtive":{"type":"boolean"},"id":{"type":"string","index":"not_analyzed","store":"yes","include_in_all":false},"img_data":{"type":"binary"},"img_url":{"type":"string","index":"no","store":"yes","include_in_all":false},"lastname":{"type":"multi_field","fields":{"lastname":{"type":"string","boost":0.8,"store":"yes","include_in_all":true},"alphaSort":{"type":"string","index":"not_analyzed","store":"yes","include_in_all":false}}},"location":{"type":"string","store":"yes","include_in_all":true},"name":{"typ