Skip to content

Instantly share code, notes, and snippets.

View linyiru's full-sized avatar
🐝

Lawrence Lin linyiru

🐝
View GitHub Profile
@linyiru
linyiru / .gemrc
Created August 28, 2012 08:24 — forked from dlackty/gist:3483170
OS X Rails Setup
---
:verbose: true
:bulk_threshold: 1000
install: --no-ri --no-rdoc --env-shebang
:sources:
- http://gemcutter.org
- http://gems.rubyforge.org/
- http://gems.github.com
:benchmark: false
:backtrace: false
@linyiru
linyiru / gist:3484999
Created August 27, 2012 01:58 — forked from dlackty/gist:3483170
OS X Rails Setup
#! /usr/bin/env bash
# llvm-gcc
if `type -P llvm-gcc &>/dev/null`; then
echo "Command Line Tools found."
else
echo "Command Line Tools not found."
echo "Please go https://developer.apple.com/downloads and install **Command Line Tools for Xcode**" && exit 0;
fi
@linyiru
linyiru / redis_helper.rb
Created February 14, 2012 10:58 — forked from wxmn/redis_helper.rb
How to Build a Fast News Feed in Redis and Rails
module RedisHelper
# decode Redis value back to Ruby object
def self.decode(json)
self.new(ActiveSupport::JSON.decode(json)["#{self.name.downcase}"])
end
# encode Ruby object for Redis
def encoded
self.updated_at = nil
self.to_json
@linyiru
linyiru / redis_helper.rb
Created February 14, 2012 10:58 — forked from wxmn/redis_helper.rb
How to Build a Fast News Feed in Redis and Rails
module RedisHelper
# decode Redis value back to Ruby object
def self.decode(json)
self.new(ActiveSupport::JSON.decode(json)["#{self.name.downcase}"])
end
# encode Ruby object for Redis
def encoded
self.updated_at = nil
self.to_json
require 'rubygems'
require 'aws-sdk'
AWS.config({ :access_key_id => "YOUR KEY", :secret_access_key => "YOUR SECRET KEY",
:s3_endpoint => "s3-ap-northeast-1.amazonaws.com" })
bucket_name = "YOUR BUCKET NAME"
s3 = AWS::S3.new()
bucket = s3.buckets[bucket_name]
You can represent time statements in most western languages where
a prefix and/or suffix is used.
The default case is to use suffix only (as in English), which you
do by providing the `suffixAgo` and `suffixFromNow` settings in
the strings hash (earlier versions of timeago used the deprecated
`ago` and `fromNow` options). If present, they are used.
2 minutes [suffixAgo]
2 minutes [suffixFromNow]
@linyiru
linyiru / README.txt
Created October 30, 2011 08:13 — forked from rmm5t/README.md
Locale override examples for the timeago jQuery plugin (http://timeago.yarp.com)
You can represent time statements in most western languages where
a prefix and/or suffix is used.
The default case is to use suffix only (as in English), which you
do by providing the `suffixAgo` and `suffixFromNow` settings in
the strings hash (earlier versions of timeago used the deprecated
`ago` and `fromNow` options). If present, they are used.
2 minutes [suffixAgo]
2 minutes [suffixFromNow]
@linyiru
linyiru / application.html.erb
Created July 25, 2011 12:47 — forked from rdetert/application.html.erb
How to logout completely from Facebook using Ruby on Rails and Devise + Omniauth. I'm just modifying the Omniauth Railscast http://railscasts.com/episodes/236-omniauth-part-2
<div id="user_nav">
<% if user_signed_in? %>
<img src="<%= user_avatar %>" id="main_avatar"> Signed in as <%= current_user.email %>.<br />
Not you?
<% if session[:fb_token].nil? %>
<%= link_to "Sign out", destroy_user_session_path %>
<% else %>
<%= link_to "Sign out", facebook_logout_path %>
<% end %>
package com.ucont;
import android.content.ContentProvider;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/environment'