Skip to content

Instantly share code, notes, and snippets.

View vincentchu's full-sized avatar

Vincent Chu vincentchu

View GitHub Profile
if Rails.env.test?
RAILS_DEFAULT_LOGGER.debug "VBC patching"
class Mixpanel
def track!
RAILS_DEFAULT_LOGGER.debug "VBC RETURNING"
end
end
LIKELY_TEMP_ERRORS = [AWS::S3::NoSuchKey, ActiveRecord::RecordNotFound]
## => [AWS::S3::NoSuchKey, ActiveRecord::RecordNotFound]
error = AWS::S3::NoSuchKey.new("foo", "bar")
## => #<AWS::S3::NoSuchKey: foo>
LIKELY_TEMP_ERRORS.include?(error.class)
## => true
FB.provide('UIServer.Methods', {
'permissions.request': {
size : { width: 575, height: 240 },
url : 'connect/uiserver.php',
transform : function(call) {
if (call.params.display == 'dialog') {
call.params.display = 'iframe';
call.params.channel = FB.UIServer._xdChannelHandler(
call.id,
'parent.parent'
data = 1000.times.inject([]) { |m, k| m << rand }
sparkline = Sparkline.new( data, :height => 100, :width => 500 )
puts sparkline.google_img_url
# => "http://chart.apis.google.com/chart?chxt=r,x,y&chd=t:41.5,34.3,63.4,45.0,50.5,35.7,40.6,54.9,62.0,60.6,53.2,44.9,62.4,61.8,53.5,58.5,60.4,64.6,64.5,49.8,49.3,61.4,46.4,50.8,36.1,46.5,52.8,39.7,44.4,42.3,57.6,45.6,34.1,49.0,64.1,61.4,59.9,34.0,43.9,44.8,40.4,34.0,60.3,36.8,56.1,63.1,52.7,39.6,51.9,39.0&chxs=0,990000,11,0,_|1,990000,1,0,_|2,990000,1,0,_&chm=o,990000,0,50,5&cht=lc&chxl=0:|0.17|1:||2:||&chco=336699&chxp=0,38.9904542844803&chls=1,1,0&chs=500x100"
#!/bin/bash
# This is the process for installing Thrift, Scribed and the php extension on Ubuntu
# lachlan@99designs.com
set -e
# install dependancies
aptitude install libboost1.40-dev libboost-filesystem1.40-dev libevent-dev build-essential flex bison libtool libevent-dev php5-dev pkg-config
# install thrift from source
cd /usr/local/src
@vincentchu
vincentchu / thifrt_scribe_install.sh
Created September 13, 2010 16:24
thrift_scribe_install.sh
### Installation Notes for Thrift / Scribe on Ubuntu Lucid (v10.04)
### Step 1: Install required tools
sudo apt-get install libboost-dev libevent-dev python-dev automake pkg-config libtool flex bison
sudo apt-get install php5-dev
sudo apt-get install ant
sudo apt-get install openjdk-6-jdk
sudo apt-get install bjam
sudo apt-get install libboost-all-dev
require 'rubygems'
require 'active_record'
`/usr/local/mysql/bin/mysql -u root unicode_test < create_test_db.sql`
ar_confs = {
"mysql" => {
"adapter" => "mysql2",
"database" => "unicode_test",
"username" => "root",
@vincentchu
vincentchu / redis_thread_safe.rb
Created March 9, 2011 19:31
thread safety issues
require 'rubygems'
require 'redis'
def random_redis
100.times do
rand_key = "key_#{rand(100)}"
rand_val = rand
if (rand_val < 0.33)
@vincentchu
vincentchu / redis.conf
Created March 19, 2011 19:59
Redis Conf
daemonize yes
pidfile /var/run/redis.pid
port 6379
timeout 30
loglevel notice
logfile /var/log/redis/redis-server.log
databases 16
################################ SNAPSHOTTING #################################
save 300 1000
--------------- objects --------------- ------ pages ------ ----- memory -----
load-in swap-out swapped delta used delta used delta
28 0 3742556 -43 10977293 -117 3.45G +101.54K
28 0 3742517 -39 10977207 -86 3.45G +56.30K
37 0 3742473 -44 10977107 -100 3.45G +65.12K
29 0 3742433 -40 10976982 -125 3.45G +116.73K
31 0 3742391 -42 10976850 -132 3.45G +78.88K
30 0 3742351 -40 10976779 -71 3.45G +50.25K
29 0 3742315 -36 10976673 -106 3.45G +426.68K
30 0 3742271 -44 10976552 -121 3.45G +183.50K