Skip to content

Instantly share code, notes, and snippets.

@fallingfree
fallingfree / osx_install.sh
Created October 21, 2015 10:08 — forked from t-io/osx_install.sh
Install most of my Apps with homebrew & cask
#!/bin/sh
echo Install all AppStore Apps at first!
# no solution to automate AppStore installs
read -p "Press any key to continue... " -n1 -s
echo '\n'
echo Install and Set San Francisco as System Font
ruby -e "$(curl -fsSL https://raw.github.com/wellsriley/YosemiteSanFranciscoFont/master/install)"
echo Install Homebrew, Postgres, wget and cask
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
@fallingfree
fallingfree / 0_reuse_code.js
Last active September 10, 2015 01:58
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
// 新增當地時區的時間物件
function DateTimezone(offset) {
// 建立現在時間的物件
d = new Date();
// 取得 UTC time
utc = d.getTime() + (d.getTimezoneOffset() * 60000);
// 新增不同時區的日期資料
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
var list = {
# -*- coding: utf-8 -*-
import textwrap
msg = """
《诗经》中最早的作品大约成于西周初期,根据《尚書》上所说,《豳风·鸱鸮》为周公旦所作。2008年入藏清华大学的一批战国竹简(简称清华简)中的《耆夜》篇中,叙述武王等在战胜黎国后庆功饮酒,其间周公旦即席所作的诗《蟋蟀》,内容与现存《诗经·唐风》中的《蟋蟀》一篇有密切关系[4][5]。最晚的作品成于春秋时期中叶《诗经》中最早的作品大约成于西周初期,根据《尚書》上所说,《豳风·鸱鸮》为周公旦所作。2008年入藏清华大学的一批战国竹简(简称清华简)中的《耆夜》篇中,叙述武王等在战胜黎国后庆功饮酒,其间周公旦即席所作的诗《蟋蟀》,内容与现存《诗经·唐风》中的《蟋蟀》一篇有密切关系[4][5]。The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren’t special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-and preferably only one - obvious way to do it. Although that way may not be obvious at first unless you’re Dutch. Now is better than never. Although never is often better than *right* now. If the imp
@fallingfree
fallingfree / douban_api.py
Last active December 14, 2015 22:39
douban api with requests
# -*- coding:utf-8 -*-
import reuqests
def douban_api(subject_id):
# subject_id = 5308265
r = requests.get('http://api.douban.com/v2/movie/%d', subject_id)
#r = requests.get('http://api.douban.com/v2/movie/5308265')
d = r.json()
@fallingfree
fallingfree / gist:4500564
Created January 10, 2013 08:51
解决 PyQuery 中文乱码的方法
# -*- coding: utf-8 -*-
# 2.如遇到 UnicodeEncodeError: 'ascii' codec can't encode characters in position 22-25: ordinal not in range(128)
# 增加如下3行
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
from pyquery import PyQuery as pq
@fallingfree
fallingfree / gist:4201424
Created December 4, 2012 07:05 — forked from ocean90/gist:1544377
Compiling Compass.app on Mac OS X
Tutorial for compiling the Compass.app (http://compass.handlino.com/)
=====================================================================
Java installed?
java -version
Load jRuby (for example JRuby 1.6.5.1 Binary .zip)
http://jruby.org/download
Unzip jRuby to `/usr/local/`
@fallingfree
fallingfree / overwrite_init_method.py
Created November 13, 2012 06:41
Cleanest way to override __init__ where an optional kwarg must be used after the super() call?
#http://stackoverflow.com/questions/5031711/python-cleanest-way-to-override-init-where-an-optional-kwarg-must-be-used
def __init__(self, *args, **kwargs):
user = kwargs.pop('user', None)
super(BaseCheckoutForm, self).__init__(*args, **kwargs)
if user is not None:
self.prefill_from_user(user)