Skip to content

Instantly share code, notes, and snippets.

#
# 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
@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)
#
# 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)
## /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
@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
@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
require 'tokyotyrant'
module Rack
module Session
class Tyrant < Abstract::ID
include TokyoTyrant
attr_reader :mutex, :pool
DEFAULT_OPTIONS = Abstract::ID::DEFAULT_OPTIONS.merge :tyrant_server => "localhost:1978"
def initialize(app, options = {})
super
--- PKGBUILD 2009-07-02 13:17:27.000000000 -0300
+++ PKGBUILD 2009-12-21 16:31:34.000000000 -0200
@@ -1,6 +1,6 @@
# Contributor: p2k <[email protected]>
pkgname=rabbitmq
-pkgver=1.6.0
+pkgver=1.7.0
pkgrel=1
pkgdesc="Highly reliable and performant enterprise messaging implementation of AMQP written in Erlang/OTP"
arch=(i686 x86_64)
#
# Nanite Initializer
#
def load_mapper_opts
YAML.load(File.read(RAILS_ROOT + "/config/rabbitmq.yml"))#.result) #[ENV["RAILS_ENV"] || "development"]
end
if ENV["NO_NM"].nil? && RAILS_ENV != "test"
if defined?(PhusionPassenger)
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;