Skip to content

Instantly share code, notes, and snippets.

class Statistic
include MongoMapper::Document
key :format, String, :index => true, :required => true
key :ip, String, :index => true, :required => true
key :path, String, :index => true, :required => true
end
module Rack
class RequestStatisticTracker
def initialize(app)
@app = app
end
def call(env)
status, headers, response = @app.call(env)
path = env['REQUEST_PATH'] || env['PATH_INFO']
@tpitale
tpitale / gist:206856
Created October 10, 2009 14:18
LaunchDaemon config for Mongodb
We couldn’t find that file to show.
# tpitale_rails_template.rb
file 'config/routes.rb', <<-CODE
ActionController::Routing::Routes.draw do |map|
end
CODE
run "rm public/index.html"
run "rm public/images/rails.png"
run "rm public/favicon.ico"
if ($request_uri ~* "\.(ico|css|js|gif|jpe?g|png)\?[0-9]+$") {
expires max;
break;
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.redis.server</string>
<key>ProgramArguments</key>
<array>
<string>/opt/local/sbin/redis-server</string>
@tpitale
tpitale / gist:315446
Created February 26, 2010 05:19
example .gemrc
---
:benchmark: false
gem: --no-ri --no-rdoc
:update_sources: true
:verbose: true
:bulk_threshold: 1000
:sources:
- http://gems.github.com
:backtrace: false
<script type="text/javascript">
function current_top_domain() {
var domain_parts = window.location.hostname.split('.');
var part_count = domain_parts.length;
return "." + domain_parts[part_count-2] + "." + domain_parts[part_count-1];
}
var _gaq = _gaq || [];
_gaq.push(
# 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
#
alias gst='git status'
alias gco='git checkout'
alias gmg='git merge'
alias grm='git rm'
alias gcm='git commit'
alias gtg='git tag'
alias gpl='git pull'
alias gps='git push'
alias gcl='git clone'
alias gad='git add .'