Skip to content

Instantly share code, notes, and snippets.

View liluo's full-sized avatar
:octocat:
Hey, there ~

liluo liluo

:octocat:
Hey, there ~
View GitHub Profile
def thrice
yield
yield
yield
end
x = 5
puts "value of x before: #{x}" # 5
thrice { x += 1 }
puts "value of x after: #{x}" #
@liluo
liluo / clients.md
Created February 14, 2013 11:53 — forked from defunkt/clients.md

Gist Clients

Want to create a Gist from your editor, the command line, or the Services menu? Here's how.

Editor Support

#!/bin/sh
git filter-branch --env-filter '
an="$GIT_AUTHOR_NAME"
am="$GIT_AUTHOR_EMAIL"
cn="$GIT_COMMITTER_NAME"
cm="$GIT_COMMITTER_EMAIL"
if [ "$GIT_COMMITTER_EMAIL" = "[email protected]" ]
@liluo
liluo / test.py
Last active December 15, 2015 23:59
me = client.user.me print client.user.following(me['id'])
SCOPE = 'douban_basic_common,shuo_basic_r,shuo_basic_w,community_advanced_doumail_r'
client = DoubanClient(API_KEY, API_SECRET, CALLBACK, SCOPE)
print 'Go to the following link in your browser:'
print client.authorize_url
code = raw_input('Enter the verification code:')
access_token = client.auth_with_code(code)
@liluo
liluo / a.md
Last active December 16, 2015 05:29

name: inverse layout: true class: center, middle, inverse


Python 简介

su27


@liluo
liluo / graph.rb
Last active December 17, 2015 12:29 — forked from SaitoWu/graph.rb
require 'date'
author = "fenbi"
email = "[email protected]"
date = Date.new(2012, 7, 30)
l = %w{
. . . . . . .
. . o . . . .
. . o . . . .
@liluo
liluo / bash.sh
Created July 31, 2013 16:58
在已有 Apache2 的服务器上配置 passenger
passenger-install-apache2-module --auto --apxs2-path=/usr/local/apache2/bin/apxs --apr-config-path=/usr/local/apache2/bin/apr-1-config
@liluo
liluo / python.sh
Last active December 25, 2015 19:19
基本定制型
C.__init__(self[, arg1, ...]) 构造器(带一些可选的参数)
C.__new__(self[, arg1, ...]) 构造器(带一些可选的参数);通常用在设置不变数据类型的子类。
C.__del__(self) 解构器
C.__str__(self) 可打印的字符输出;内建str()及print 语句
C.__repr__(self) 运行时的字符串输出;内建repr() 和‘‘ 操作符
C.__unicode__(self)b Unicode 字符串输出;内建unicode()
C.__call__(self, *args) 表示可调用的实例
C.__nonzero__(self) 为object 定义False 值;内建bool() (从2.2 版开始)
@liluo
liluo / json2object.py
Last active August 29, 2015 14:06
Utils
from collections import namedtuple
def json2object(data):
"""
>>> json2object("a")
'a'
>>> data = {"a": 100, "b": 200}
>>> obj = json2object(data)
>>> obj.a
@liluo
liluo / pp.py
Created November 20, 2014 03:45
import sys
def pp(msg):
sys.stdout.write("\r")
sys.stdout.write(msg)
sys.stdout.flush()