Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby -w
# This should be run through './script/runner'
options = YAML.load($stdin.read)
demo = Demo.find(options[:demo])
runner = Outback::Runner.new
runner.manager = demo.manager
#!/usr/bin/env ruby -w
# This should be run through './script/runner'
options = YAML.load($stdin.read)
demo = Demo.find(options[:demo])
runner = Outback::Runner.new
runner.manager = demo.manager
require 'stringio'
require 'irb/ruby-lex'
# Tell the ruby interpreter to load code lines of required files
# into this filename -> lines Hash. This behaviour seems to be
# very undocumented and therefore shouldn't really be relied on.
SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
module ProcSource
def get_lines(filename, start_line = 0)
class Manager < ActiveRecord::Base
belongs_to :demo
serialize :state
serialize :cache
def after_initialize
@observers = []
end
Loading development environment (Rails 2.1.0)
>> m = Manager.new
=> #<Manager id: nil, state: nil, cache: nil, kind: nil, demo_id: nil, created_at: nil, updated_at: nil>
>> m.cache
Restoring state:---
cache:
state:
=> {}
>> m.cache[:name] = "Mike"
>> m.read_attribute(:cache)
=> {:monkey=>321}
>> m.save
=> true
>> m.read_attribute(:cache)
=> {:monkey=>321}
>> m = Manager.find(m.id)
=> #<Manager....>
>> m.read_attribute(:cache)
=> {:monkey=>123}
@nickstenning
nickstenning / bitly.rb
Created August 14, 2008 23:18
A dead-simple wrapper for the bit.ly API. Made possible by jnunemaker's httparty.
require 'rubygems'
require 'httparty'
class Bitly
URL = 'http://bit.ly'
include HTTParty
base_uri URL
def initialize(url)
case url
#!/usr/bin/env ruby
#
# ./script/demodblogger
#
# Designed to assist with running a command in the background and capturing
# its output as it runs, this script takes a demo id, and calls
# @demo.job_log(line) for each line given it on stdin. Run without arguments for a
# brief summary of usage.
#
#import "planet.h"
#include <iostream>
using namespace std;
const double G = 1;
const double m_sun = 1;
const double m_earth = 1;
Traceback (most recent call last):
File "/usr/local/python26/bin/paster", line 8, in <module>
load_entry_point('PasteScript==1.7.3', 'console_scripts', 'paster')()
File "/usr/local/python26/lib/python2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/command.py", line 84, in run
invoke(command, command_name, options, args[1:])
File "/usr/local/python26/lib/python2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/command.py", line 123, in invoke
exit_code = runner.run(args)
File "/usr/local/python26/lib/python2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/appinstall.py", line 68, in run
return super(AbstractInstallCommand, self).run(new_args)
File "/usr/local/python26/lib/python2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/command.py", line 218, in run