Skip to content

Instantly share code, notes, and snippets.

View cyu's full-sized avatar

Calvin Yu cyu

View GitHub Profile
/^([\d.]+) (\S+) (\S+) \[([\w:\/]+\s[+\-]\d{4})\] "(.+?)" (\d{3}) (\d+) "([^"]+)" "([^"]+)"/
cat access_logs.20090319_1000.log | ./access_log_parser.rb | sed 's/19\/Mar\/2009:\(10:[0-9]*\).*/\1/' | sort -k 2,1| uniq -c | egrep -v '\s*1 ' | less
@cyu
cyu / fluid_campfire_chat_viewport_width_fix.user.js
Created April 6, 2009 14:28
Fixes a clipping issue when running Campfire in Fluid
// ==UserScript==
// @name Fix Chat ViewPort width
// @namespace http://blog.codeeg.com
// @description Fix clipping of campfire chats
// @include *
// @author Calvin Yu
// ==/UserScript==
(function () {
if (window.fluid) {
map.reports 'report/:year/:month/:day', :controller => 'report', :action => 'show',
:year => nil, :month => nil, :day => nil
class ReportController < ApplicationController
after_filter :cache_weekly_report, :only => :show
def show
if params[:year]
@year = params[:year]
@month = params[:month]
@day = params[:day]
if File.exist?("#{Rails.root}/public/report/#{@year}/#{@month}/#{@day}.html")
redirect_to reports_path(:year => @year, :month => @month, :day => @day)
task :symlink_reports do
run "mkdir -p #{shared_path}/report; ln -nfs #{shared_path}/report #{release_path}/public/report"
end
after 'deploy:update_code', 'deploy:symlink_reports'
@cyu
cyu / gist:182153
Created September 7, 2009 04:34
An example of how to add a custom library path to the runtime linker of a native ruby gem
sudo env PATH="/opt/curl/bin:$PATH" gem install toland-patron -v "0.4.1" --source http://gems.github.com -- --with-ldflags="-Wl,-R/opt/curl/lib"
@cyu
cyu / local_storage_persister.js
Created June 22, 2010 02:49
Bespin Plugin that Saves Settings to HTML5 localStorage
"define metadata";
({
"dependencies": {
"settings": "0.0.0"
}
});
"end";
var console = require('bespin:console').console;
var Trace = require('bespin:util/stacktrace').Trace;
@cyu
cyu / loader.js
Created July 27, 2010 11:55
Load view/update functions from .js files and loads them to CouchDB.
var fs = require('fs');
var http = require('http');
var path = require('path');
var console = require('sys');
var url = require('url');
var Script = process.binding('evals').Script;
var couchURL = url.parse(process.argv[2]);
var couch = http.createClient(couchURL.port, couchURL.hostname);
@cyu
cyu / subversion_twitter.rb
Created February 5, 2011 04:41
Twittering Subversion Updates
begin
require 'rubygems'
require 'twitter'
rescue LoadError
%x{echo "repo:#{ARGV[0]} rev: #{ARGV[1]}" > /tmp/svn-hooks.log}
%x{echo "Error: #{$!} trace:#{caller}" >> /tmp/svn-hooks.log}
end
def gather_and_post(repo_path, revision)
svnlook = '/usr/bin/svnlook'