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 / gist:6780404
Created October 1, 2013 15:37
Hack of the day. Modify a chef node and remove some attributes by using this script as EDITOR
#!/bin/sh
echo $1.x
jshon -e normal -e log_locations -n array -i picor -p -p < $1 > $1.x
mv $1.x $1
@octplane
octplane / theme.css
Last active December 22, 2015 05:29
ink theming
body {
background-color: #333;
}
#servicePane {
background-color: #242424;
}
#picker {
background-color: #333;
require 'rubygems'
require 'murder'
set :remote_murder_path, '/etc/bundler.chef/vendor/bundle/ruby/1.9.1/gems/murder-0.1.2/dist/' # or some other directory
s = []
pee = s[0..(ENV['COUNT'].to_i || -1)]
@octplane
octplane / meteobot.rb
Created July 23, 2013 11:49
Les sources de FotonautsBot
require 'mechanize'
require 'chatterbot'
require 'htmlentities'
BASE_URL = "http://meteo.orange.fr/Php/getPrevPluies.php"
ARG = "code=0751080"
def get_weather
agent = Mechanize.new
@octplane
octplane / fb_to_nginx.sh
Last active December 18, 2015 19:09
Expand list of ipv4 hosts for all the source of the facebook crawler into a set of nginx Allow directives
whois -h whois.radb.net -- '-i origin AS32934' | grep ^route: | sed -e "s/route: /allow/;s/$/;/"
# https://dev.twitter.com/discussions/6545
whois -h whois.radb.net -- '-i origin AS13414' | grep ^route | sed -e "s/route: /allow/;s/$/;/"
@octplane
octplane / newrelic.rb
Last active December 17, 2015 17:09
Initializer for rails if you use newrelic outside Heroku or without Mongrel. Will speed up all instrumented request by about 100%
module NewRelic
module Agent
module Instrumentation
# == NewRelic instrumentation for controller actions and tasks
#
# This instrumentation is applied to the action controller to collect
# metrics for every web request.
#
# It can also be used to capture performance information for
# background tasks and other non-web transactions, including
@octplane
octplane / plop.rb
Created March 12, 2013 09:55
How to talk to graphite.
send_graphite("munin5.mysql.slow_count %.5f %d" % [@slow_count.to_f/@interval, Time.now.to_i])
def send_graphite(message)
hostname = 'graphite'
port = 2003
begin
s = TCPSocket.open(hostname, port)
s.puts(message)
s.close
@octplane
octplane / v8_memory_stress.rb
Created February 22, 2013 10:33
Stress Test V8 to exhibit memory usage. Uncomment line 5 to demonstrate that SetFlagsFromString has actual impact on the V8 runtime.
require 'rubygems'
require 'handlebars'
require 'v8'
# V8::C::V8.SetFlagsFromString("--max-old-space-size=200")
@heap_stats_methods = [:total_heap_size, :total_heap_size_executable, :used_heap_size, :heap_size_limit]
@st = V8::C::HeapStatistics.new
def dump_stats
@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"
@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