Skip to content

Instantly share code, notes, and snippets.

@cornet
cornet / gist:1240001
Created September 24, 2011 23:37
Youtube Embed
<object width="425" height="344">
<param name="movie" value="http://www.youtube.com/v/avs9j-254G4&hl=en&fs=1&color1=0x3a3a3a&color2=0x999999"></param>
<param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/avs9j-254G4&hl=en&fs=1&color1=0x3a3a3a&color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344">
</embed>
</object>
@cornet
cornet / munin-graphite.rb
Created November 11, 2011 16:29
munin -> ampq -> graphite
#!/usr/bin/env ruby
#
# munin-graphite.rb
#
# A Munin-Node to Graphite bridge
#
# Author:: Adam Jacob (<adam@hjksolutions.com>)
# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
# License:: GNU General Public License version 2 or later
#
@cornet
cornet / producer.rb
Created December 11, 2011 13:16
Bunny + Graphite
#!/usr/bin/ruby
#
# Quick rewrite of producer.rb from @ripienaar's excellent article here:
# http://www.devco.net/archives/2011/12/11/common-messaging-patterns-using-stomp-%E2%80%93-part-2.php
#
# This assumes you have the following grapite's carbon.conf:
#
# AMQP_HOST = localhost
# AMQP_PORT = 5672
@cornet
cornet / munin-graphite.rb
Created December 11, 2011 23:36
Munin + Graphite + Bunny
#!/usr/bin/env ruby
require 'rubygems'
require 'munin-ruby'
require 'bunny'
munin = Munin::Node.new
metric_base = "servers"
@cornet
cornet / Rakefile
Created February 13, 2012 22:06
Rakefile to generate Graphite Packages
#
# Rakefile for building graphite <http://graphite.wikidot.com/>
#
# Outputs the following .debs
# * python-txamqp
# * python-whisper
# * python-carbon
# * python-grapite-web
#
# Requires:
@cornet
cornet / Rakefile
Created February 14, 2012 14:24
Node.js Build
#
# Rakefile for building node.js for Debian Squeeze
#
# This needs to be run on a squeeze box with the following in place:
#
# * /etc/apt/sources.list.d/unstable.list
#
# deb http://ftp.uk.debian.org/debian unstable main contrib non-free
# deb-src http://ftp.uk.debian.org/debian unstable main contrib non-free
#
@cornet
cornet / gist:1877458
Created February 21, 2012 17:07 — forked from chrisa/gist:1877183
diff -urN carbon-0.9.9/lib/carbon/protocols.py carbon-0.9.9-logpatch/lib/carbon/protocols.py
--- carbon-0.9.9/lib/carbon/protocols.py 2011-10-05 10:28:41.000000000 +0100
+++ carbon-0.9.9-logpatch/lib/carbon/protocols.py 2012-02-20 09:40:37.058970858 +0000
@@ -13,7 +13,6 @@
"""
def connectionMade(self):
self.peerName = self.getPeerName()
- log.listener("%s connection with %s established" % (self.__class__.__name__, self.peerName))
if state.metricReceiversPaused:
@cornet
cornet / gsm_packing.rb
Created March 22, 2012 16:41
gsm packing
def encode_gsm_gsm7(payload)
input = []
# Remove MSB of each 8bit octet
payload.unpack('b*').first.split(//).each_slice(8) do |chunk|
chunk[0..6].each {|c| input << c}
end
# Pad out with 0 to 8bit boundary
while input.length.modulo(8) != 0
@cornet
cornet / gist:2968912
Created June 21, 2012 22:13
Relatively Prime
#!/usr/bin/env ruby
def gcd(a, b)
b == 0 ? a : gcd(b, a % b)
end
def is_rp?(a, b)
gcd(a, b) == 1
end
@cornet
cornet / wolfram.rb
Created July 24, 2012 19:38
Cinch Wolfram Alpha plugin
require 'cinch'
require 'wolfram-alpha'
require 'cgi'
class Wolfram
include Cinch::Plugin
plugin "wolfram"
match /((what|how) .+)/