Skip to content

Instantly share code, notes, and snippets.

@nofxx
nofxx / xmapper
Created September 12, 2009 10:01
#!/usr/bin/env ruby
require "rubygems"
require "nanite"
puts "[XMAPPER] Starting mapper!"
pid = fork do
# $stdin.close
# $stdout.close
# $stderr.close
@nofxx
nofxx / my.god
Created September 7, 2009 23:51
#
# God please,
#
# Generic Monitor
#
def generic_monitoring(w, options = {})
w.interval = 30.seconds # default
w.start_if do |start|
start.condition(:process_running) do |c|
c.interval = 10.seconds
## /etc/rc.d/rabbitmq [shell-unix-generic]
#!/bin/bash
daemon_name=rabbitmq-multi
node_count=1
. /etc/rc.conf
. /etc/rc.d/functions
case "$1" in
#
# Nanite rake tasks [start, stop, stat]
#
namespace :nanites do
NANITES = Dir.glob("nanite/*").map {|d| d.split("/")[1] }
SLEEP_TIME = RAILS_ENV == 'production' ? 1 : 3
desc "Start nanites"
task :start, [:nanite] do |t, nanite|
#raise RuntimeError, "Nanite is already running." if nanite_running?
for nanite in get_nanites(nanite)
@nofxx
nofxx / api.rb
Created September 1, 2009 09:08
#
# AuthPunkInterface
#
# This module is responsible for allowing login via
# HTTP Auth using an API Key (single_access_token)
#
module AuthPunkInterface
module HttpBasicApiKey
def self.included(klass)
#
# Lunar/Moon phases ruby class
#
# Code is based upon Bradley E. Schaefer''s moon phase algorithm.
# Ruby version based on JavaScript Phase Calculator by Stephen R. Schmitt
class Moon
attr_reader :epoch, :phase, :days, :icon, :dist, :ll
# Return the current (or input a date) moon.
# Moon.new
#!/usr/bin/env ruby
#
# Simple script to rename all columns/index/seq on rails app postgresql db
#
# Usage: pg_rename foo bar
#
require 'rubygems'
require 'activerecord'
require 'annotate/annotate_models'
require 'config/boot'
@nofxx
nofxx / nginx
Created August 23, 2009 00:05
nginx rc.d script archlinux
#!/bin/bash
# NGINX RC.D SCRIPT
# Archlinux
NGINX_CONFIG="/opt/nginx/conf/nginx.conf"
NGINX_BIN="/opt/nginx/sbin/"
#. /etc/conf.d/nginx
. /etc/rc.conf
. /etc/rc.d/functions
@nofxx
nofxx / tyrant.rake
Created July 15, 2009 03:10
Tokyo Tyrant rake tasks
#
# Tokyo Tyrant rake tasks
#
# rake tyrant:restart # Restart Tyrant server
# rake tyrant:start # Start Tyrant server
# rake tyrant:stop # Stop Tyrant server
#
namespace :tyrant do
desc "Start Tyrant server"
class LogApp
def initialize(m, c, text, req)
HoptoadNotifier.notify(
:error_class => m.to_s.capitalize,
:error_message => text,
:request => req,
:backtrace => c)
end