Skip to content

Instantly share code, notes, and snippets.

@fallingfree
fallingfree / utility.txt
Created November 12, 2012 09:18 — forked from node/linux tips & hacks
常用命令与工具集
- 下载整站
> wget -r -p -np -k http://xxoo.com
注释: -r 递归, -p 下载网页关联的其他资源,-np 不搜索上层目录, -k 绝对链接转为相对链接
其他参数:
  ◆-b:后台下载,Wget默认的是把文件下载到当前目录。
  ◆-O:将文件下载到指定的目录中。
  ◆-P:保存文件之前先创建指定名称的目录。
  ◆-t:尝试连接次数,当Wget无法与服务器建立连接时,尝试连接多少次。
  ◆-c:断点续传,如果下载中断,那么连接恢复时会从上次断点开始下载。
@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)
@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 / 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 / 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()
# -*- 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
var list = {
// 新增當地時區的時間物件
function DateTimezone(offset) {
// 建立現在時間的物件
d = new Date();
// 取得 UTC time
utc = d.getTime() + (d.getTimezoneOffset() * 60000);
// 新增不同時區的日期資料
@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