Skip to content

Instantly share code, notes, and snippets.

View cyanglee's full-sized avatar

Kenneth Lee cyanglee

View GitHub Profile
@cyanglee
cyanglee / gist:1063869
Created July 4, 2011 20:11
Unicode in Rails
# coding: utf-8
module ApplicationHelper
def cities_helper
[
['基隆市', '基隆市'],
['台北市', '台北市'],
['新北市', '新北市'],
['桃園縣', '桃園縣'],
['新竹市', '新竹市'],
['新竹縣', '新竹縣'],
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :find_user
#before_filter :set_locale
# redirect to the root page if the user doesn't have the permission to acccess that section of the site
rescue_from CanCan::AccessDenied do |exception|
# don't provide any information for users who access to the admin section
if exception.subject == :rails_admin
redirect_to "/"
$(document).ready ->
# $("div#[id^='flash_']").fadeOut(4000)
$("input[type='submit']").addClass("primary btn");
$(document).ready ->
# $("div#[id^='flash_']").fadeOut(4000)
$("input[type='submit']").addClass("primary btn")
@cyanglee
cyanglee / hack.sh
Created March 31, 2012 14:58 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@cyanglee
cyanglee / gist:5617141
Created May 21, 2013 02:25
There are different ways to create recursive hash in ruby. I found two tricks from here: http://metaskills.net/2012/03/12/store-configurable-a-lesson-in-recursion-in-ruby/
# ruby recursive hash examples
# http://metaskills.net/2012/03/12/store-configurable-a-lesson-in-recursion-in-ruby/
# trick 1
class RecursiveHash < Hash
Recursive = lambda { |h,k| h[k] = h.class.new }
def initialize
super(&Recursive)
end
end
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
zh-TW:
errors:
messages:
expired: "已經過期,請重新申請一個"
not_found: "找不到"
already_confirmed: "已經驗證,請直接登入"
not_locked: "被鎖定了"
not_saved:
@cyanglee
cyanglee / gist:5660276
Created May 28, 2013 03:02
lograge logs
11:00:31,840 INFO [wordsentry] (http-/0.0.0.0:8080-1) method=GET path=/admin/app_configs format=html controller=app_configs action=index status=200 duration=338.00 view=282.00
11:00:40,459 INFO [wordsentry] (http-/0.0.0.0:8080-2) method=GET path=/admin/users format=html controller=users action=index status=200 duration=579.00 view=491.00
11:00:54,061 INFO [wordsentry] (http-/0.0.0.0:8080-2) method=GET path=/admin/orgs format=html controller=orgs action=index status=200 duration=174.00 view=141.00
11:00:59,046 INFO [wordsentry] (http-/0.0.0.0:8080-1) method=GET path=/admin/reports format=html controller=reports action=index status=200 duration=301.00 view=299.00
@cyanglee
cyanglee / ruby_chef_install.sh
Last active December 20, 2015 02:09 — forked from codemis/ruby_chef_install.sh
ruby 2.0 on Ubuntu 12.10 x64
#!/usr/bin/env bash
sudo apt-get -y update
sudo apt-get -y install build-essential libyaml-dev zlib1g-dev openssl libssl-dev libreadline6-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz
tar -xvzf ruby-2.0.0-p0.tar.gz
cd ruby-2.0.0-p0
sudo ./configure --prefix=/usr/local
sudo make
sudo make install
function render_result(queryText) {
// Test if the broswer supports geolocation
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
// Get geolocation from the browser's location
latitude = position.coords.latitude;
longitude = position.coords.longitude;