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 / 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 / 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 / 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 / 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 / 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
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 / theme.css
Last active December 22, 2015 05:29
ink theming
body {
background-color: #333;
}
#servicePane {
background-color: #242424;
}
#picker {
background-color: #333;
@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 / polycorn.md
Last active December 25, 2015 21:08
Life and Death of Unicorns The introduction of our Unicorn management tool, Polycorn. This gists contains the original article about Polycorn plus the source code of Polycorn.

Life and death of Unicorns

The introduction of our Unicorn management tool, Polycorn.

jump into our train!

Photo by Protohiro from Flickr

At Fotopedia, we use Unicorn to serve our main Rails application. Every day, we restart our application several times, spawning and killing hundred of Unicorns. Managing graceful restarts is a complex task, and requires careful monitoring and command. This article introduces our tool Polycorn, a Unicorn management program.

[[MORE]]

diff --git a/src/vendor/angular/angular.js b/src/vendor/angular/angular.js
index d2115fe..e878eae 100644
--- a/src/vendor/angular/angular.js
+++ b/src/vendor/angular/angular.js
@@ -8779,6 +8779,9 @@ function $RootScopeProvider(){
logIdx, logMsg;
beginPhase('$digest');
+ var ccount = 0;
+ console.time("$digest");