Skip to content

Instantly share code, notes, and snippets.

// 获得窗口宽高
function getWindowWidthAndHeight() {
var width = window.innerWidth,
height = window.innerHeight;
if (width && typeof(width) == "number" &&
height && typeof(height) == "number") {
return [width, height];
}
if (document.body && document.body.offsetWidth) {
@kaichen
kaichen / gist:4152013
Created November 27, 2012 02:26
Rails Developer JD

Rails Developer JD

杭州简阅科技 http://easyread.ly 招聘Rails程序员一名。

职责:

主要是产品的开发

  • 开发Web财经阅读平台(超过50w UV的日访问量)
  • 开发CMS和CRM
@kaichen
kaichen / provinces_and_cities.yml
Created October 11, 2012 10:02
中国省市数据
-
province: 北京市
cities:
- 北京市
-
province: 天津市
cities:
- 天津市
-
province: 上海市
{
"status":"success",
"lang":"",
"title":"\u5916\u4ea4\u90e8\u56de\u5e94\u65e5\u9a7b\u534e\u5927
\u4f7f\u5750\u8f66\u60ac\u6302\u7684\u56fd\u65d7\u88ab\u62a2\uff1a\u4e2d\u65b9\u6b63\u5728
\u8ba4\u771f\u8c03\u67e5[\u770b\u4e1c\u65b9]",
"weburl":"http://v.youku.com/v_show/id_XNDQ0MDQzMTgw.html",
"videoid":"XNDQ0MDQzMTgw",
"results":{
"3gphd":[
@kaichen
kaichen / chef_solo_bootstrap.sh
Created August 30, 2012 01:47 — forked from ryanb/chef_solo_bootstrap.sh
Bootstrap Chef Solo
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline5-dev libyaml-dev
cd /tmp
wget http://ruby.taobao.org/mirrors/ruby/1.9/ruby-1.9.3-p194.tar.gz
tar -xvzf ruby-1.9.3-p194.tar.gz
cd ruby-1.9.3-p194/
./configure --prefix=/usr/local --disable-install-rdoc
make
@kaichen
kaichen / machine_gun.rb
Created July 19, 2012 04:08
Yet a cache generator for rubyonrails
# encoding: utf-8
require 'fileutils'
class MachineGun
class_attribute :page_cache_extension
self.page_cache_extension ||= '.html'
class_attribute :page_cache_directory
self.page_cache_directory ||= File.join(Rails.root, "public")
# -*- encoding : utf-8 -*-
set :assets_dependencies, %w(app/assets lib/assets vendor/assets Gemfile.lock config/routes.rb)
namespace :deploy do
namespace :assets do
desc <<-DESC
Run the asset precompilation rake task. You can specify the full path \
to the rake executable by setting the rake variable. You can also \
@kaichen
kaichen / .tmux.conf
Created July 5, 2012 02:27
tmux config file
# use mouse on copy mode
setw -g mode-mouse on
# use mouse to select pane
set -g mouse-select-pane on
# scrollback buffer n lines
set -g history-limit 8000
# listen for activity on all windows
set -g bell-action any
@kaichen
kaichen / Gemfile
Created January 9, 2012 03:35
play-with-em
source :rubygems
gem "eventmachine", "0.12.10"
gem "rack"
@kaichen
kaichen / kaichen.zsh-theme
Created October 11, 2011 06:24
my zsh theme
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
local current_dir='%{$terminfo[bold]$fg[blue]%} %~%{$reset_color%}'
local current_path='%{$terminfo[bold]$fg[blue]%}%c%{$reset_color%}'
local rvm_ruby='%{$fg[red]%}‹$(rvm-prompt i v g)›%{$reset_color%}'
local git_branch='$(git_prompt_info)%{$reset_color%}'
local current_time='%{$fg[yellow]%}%D{[%I:%M:%S]}%{$reset_color%}'
local arrow="%{$fg_bold[red]%}>%{$reset_color%}"
PROMPT="${current_dir} ${git_branch}${arrow} "