Skip to content

Instantly share code, notes, and snippets.

View kennethkalmer's full-sized avatar

Kenneth Kalmer kennethkalmer

View GitHub Profile
@kennethkalmer
kennethkalmer / scrap-tui.rb
Created April 16, 2009 14:47
Automate scrap testing your Rails app
require 'rubygems'
require 'mechanize'
agent = WWW::Mechanize.new
puts "Memory Usage Delta "
puts "============ ========"
loop do
agent.get('http://172.16.133.100:3000/session/new')
@kennethkalmer
kennethkalmer / usage
Created April 9, 2009 13:44
Experiments in couchdb
{
"_id": "_design/usage",
"_rev": "11-4090663094",
"language": "javascript",
"views": {
"daily": {
"map": "function(doc) {\n if(doc.user && doc.service && doc.time && doc.action) {\n if(doc.action == \"LOGOUT\" && parseInt(doc.retr) > 0) {\n var date = new Date( doc.time );\n var year = date.getFullYear();\n var month = date.getMonth();\n if( month.toString().length == 1 ) month = '0' + month;\n var day = date.getDate();\n if( day.toString().length == 1 ) day = '0' + day;\n var key = year + '-' + month + '-' + day;\n emit(key, {user: doc.user, size: parseInt(doc.retr)});\n }\n }\n}",
"reduce": "function( keys, values, rereduce ) {\n\n var output = {};\n if( !rereduce ) {\n for each( var doc in values ) {\n if( output[doc.user] ){\n output[doc.user]['count'] += 1;\n output[doc.user]['size'] += doc.size;\n }\n else\n {\n output[doc.user] = { 'count': 1, 'size': doc.size };\n
irb(main):001:0> require 'ostruct'
=> true
irb(main):002:0> obj = OpenStruct.new
=> #<OpenStruct>
irb(main):003:0> class << obj
irb(main):004:1> def to_s
irb(main):005:2> "string"
irb(main):006:2> end
irb(main):007:1> end
=> nil
fei = $app.engine.launch(OpenWFE.process_definition(:name => 'four') do
sequence do
_set :field => 'nes.ted', :val => 'val0'
alpha
end
end)
sleep 0.350
assert_process_count 4, nil
#--
# Copyright (c) 2009, Kenneth Kalmer, [email protected]
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# Environment
export RAILS_ENV=test
cp ../database.yml config/
# Re-create
mysql -u root -e "DROP DATABASE powerdns_cruise"
mysql -u root -e "CREATE DATABASE powerdns_cruise"
COMMANDS=(
"rake db:migrate"
@kennethkalmer
kennethkalmer / gist:74844
Created March 6, 2009 09:43
Brainstorming
ruote-kit ramblings
Intro:
A rewrite of the existing ruote-rest project that aims to provide an easy to deploy and maintain ruote instance, accessible using a RESTful interface. Should be a breeze to use for non-Ruby projects and developers (apart from Ruby process definitions).
Architecture:
* Rack based, utilizing rack-mount
* Daemon-kit file system layout, keep ruote & co away from local libs, participants, configuration
#!/bin/bash
#
# Set our bash prompt according to the branch/status of the current git
# repository.
#
# Forked from http://gist.github.com/31934
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
after "deploy:update_code", "deploy:write_sha1"
namespace :deploy do
desc "write sha1 to file"
task :write_sha1 do
run "cd #{latest_release} && git show-ref --hash -- refs/heads/master > #{latest_release}/config/HEAD"
end
end
#!/usr/bin/env ruby
require 'rubygems'
require 'daemons'
require 'rufus/scheduler'
scheduler = File.join(File.dirname(__FILE__), 'scheduler.rb')
options = {
:app_name => 'scheduler',
:ARGV => ARGV,