Ubuntu 12.10 setup (rbenv/RVM, Janus, PostgreSQL)
- Some utilities:
sudo apt-get install vim tmux git curl
- Copy/paste from the command line:
find ~ -name '*.log' -print0 | xargs -0 -L1 stat -f'%z %N' | sort -rn | tee fat-logfiles.txt | head | |
awk '{ total += $1 } END { printf "total: %5.2f MiB\n", total/1024/1024 }' < fat-logfiles.txt |
sudo apt-get install vim tmux git curl
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com | |
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below) | |
module Player | |
describe MovieList, "with optional description" do | |
it "is pending example, so that you can write ones quickly" | |
it "is already working example that we want to suspend from failing temporarily" do | |
pending("working on another feature that temporarily breaks this one") |
// Document Model | |
dc.model.Document = Backbone.Model.extend({ | |
constructor : function(attrs, options) { | |
attrs.selected = false; | |
attrs.selectable = true; | |
if (attrs.annotation_count == null) attrs.annotation_count = 0; | |
Backbone.Model.call(this, attrs, options); | |
var id = this.id; |
require 'rubygems' | |
require 'mongo' | |
module MongoPubSub | |
QUEUES_COLLECTION = 'queues' | |
class EndSubscriptionException < Exception; end | |
class Publisher | |
def initialize(queue_name, mongo_connection) | |
# Initialize queue collection as a capped collection | |
if not mongo_connection[QUEUES_COLLECTION].collection_names.include?(queue_name) |
With Facebook's Graph API and the creation of the Open Graph protocol, it is now easier then ever before to read and write data from and to the "social graph". Here's a few of the possibilities:
#!/bin/sh | |
source `dirname $0`/ci-env | |
if [[ -x script/ci ]]; then | |
script/ci | |
else | |
test -f Gemfile.lock | |
if [ `head -n1 Gemfile.lock` == "GEM" ]; then | |
gem install bundler --no-rdoc --no-ri |
# delayed job priority ranges. Higher values represent lower priority. | |
PRIORITY_RANGES = [(0..9), (10..19)] | |
2.times do |num| | |
God.watch do |w| | |
w.name = "dj-#{num}" | |
w.group = 'dj' | |
w.interval = 30.seconds | |
w.start = "rake -f #{RAILS_ROOT}/Rakefile RAILS_ENV=production MIN_PRIORITY=#{PRIORITY_RANGES[num].first} MAX_PRIORITY=#{PRIORITY_RANGES[num].last} jobs:work" | |
w.log = "/var/log/god/god.log" |
module Authenticable | |
def self.included(model) | |
model.class_eval do | |
extend ClassMethods | |
include InstanceMethods | |
field :username | |
field :email | |
field :crypted_password | |
field :password_salt |
# Author: Pieter Noordhuis | |
# Description: Simple demo to showcase Redis PubSub with EventMachine | |
# | |
# Requirements: | |
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby | |
# - a browser with WebSocket support | |
# | |
# Usage: | |
# ruby redis_pubsub_demo.rb | |
# |