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 / google_reader_toggle_sidebar.user.js
Created February 5, 2011 04:53
Hide sidebar in Google Reader (Old)
// ==UserScript==
// @name Google Reader Toggle Sidebar
// @author Calvin Yu
// @namespace http://blog.codeeg.com/google-reader-enhanced
// @description Enhancements to Google Reader UI
// @license Creative Commons Attribution License
// @version 0.1
// @include http://www.google.com/reader/view/*
// @released 2006-10-01
// @updated 2006-10-01
@cyu
cyu / chg-background.rb
Created February 5, 2011 05:00
Get wallpaper backgrounds from Flickr
#!/usr/bin/env ruby
require 'rubygems'
require 'flickr'
require 'ftools'
require 'yaml'
API_KEY = "flickr_api_key"
SHARED_SECRET = "flickr_shared_secret"