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 / 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 / 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
#!/usr/bin/env ruby
require 'rubygems'
require 'json'
require 'open-uri'
require 'yaml'
critical = false
warn= false
@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:
@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 / 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 / .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 / 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 / epir.arduino
Created July 8, 2012 21:22
ePIR arduino sample code
#include <SoftwareSerial.h>
// This is the input and output of the ePIR
#define rxPin 3
#define txPin 2
// we will switch on and off the onboard led.
#define onBoardLed 13
// set up a new serial port
@octplane
octplane / build.sbt
Created February 7, 2013 12:28
Ruby syntax validity checker (JRuby) Javascript syntax validity checker. (Rhino)
libraryDependencies += "org.jruby" % "jruby" % "1.7.2"
libraryDependencies += "org.mozilla" % "rhino" % "1.7R4"