Skip to content

Instantly share code, notes, and snippets.

View lepture's full-sized avatar
💭
I'm working on Typlog.com now

Hsiaoming Yang lepture

💭
I'm working on Typlog.com now
View GitHub Profile
class TestOAuth(object):
def setUp(self):
self.access_token = 'you get it'
def test_func1(self):
do_something_with(self.access_token)
def test_func2(self):
do_another_thing_with(self.access_token)
@lepture
lepture / github.js
Created June 30, 2012 12:13
social - with seajs
define(function(require, exports, module) {
function GitHub(user) {
this.user = user;
}
GitHub.prototype.showRepos = function(options) {
options = options || {};
var limit = options.limit || 10;
var target = options.target || document.getElementById('github-repos');
if (target && target.length) target = target[0];
@lepture
lepture / nginx.rb
Created July 2, 2012 12:52
nginx with http-concat module
require 'formula'
class Nginx < Formula
homepage 'http://nginx.org/'
url 'http://nginx.org/download/nginx-1.2.1.tar.gz'
sha1 '4fb69411f6c3ebb5818005955a085e891e77b2d8'
devel do
url 'http://nginx.org/download/nginx-1.3.2.tar.gz'
sha1 'a3507cb2f13332489804f79885541c717f8f4bf0'
@lepture
lepture / git-help.md
Last active October 7, 2015 03:17
git help

Git Help

git branch calendar-branch
git filter-branch --subdirectory-filter lib/calendar calendar-branch
git tag -d 12345
git push origin :refs/tags/12345
@lepture
lepture / china-dream.md
Last active October 8, 2015 18:48
龍應台:我們的「中國夢」(8月1日北京大學演講講辭)

龍應台:我們的「中國夢」(8月1日北京大學演講講辭)

【明報專訊】第一次接到電話,希望我談談「中國夢」的時候,我的第一個反應是:「一千枚飛彈對準我家,我哪裏還有中國夢啊?」

可是沉靜下來思索,1952年生在台灣的我,還有我前後幾代人,還真的是在「中國夢」裏長大的,我的第一個中國夢是什麼呢?

我們上幼稚園時,就已經穿著軍人的制服、帶著木製的步槍去殺「共匪」了,口裏唱著歌。當年所有的孩子都會唱的那首歌,叫做《反攻大陸去》:

反攻 反攻 反攻大陸去

@lepture
lepture / gevent-flask.py
Last active January 30, 2020 15:29
gevent with werkzeug reload and debug
def runserver(port=5000, profile_log=None):
"""Runs a development server."""
from gevent.wsgi import WSGIServer
from werkzeug.serving import run_with_reloader
from werkzeug.debug import DebuggedApplication
from werkzeug.contrib.profiler import ProfilerMiddleware
port = int(port)
if profile_log:
var data = {
'a': ['a1', 'a2'],
'a1': ['a11'],
'a2': [],
'a11': ['a111', 'a112']
}
/*
* a
* |- a1
@lepture
lepture / nodepath.js
Created March 15, 2013 03:24
check NODE_PATH
if (!process.env.NODE_PATH) {
console.log();
if (process.env.SHELL === '/bin/zsh') {
console.log(' Please set environment variable NODE_PATH in ~/.zshrc:');
} else if (process.env.SHELL === '/bin/bash') {
console.log(' Please set environment variable NODE_PATH in ~/.bashrc:');
} else {
console.log(' Please set environment variable NODE_PATH:');
}
console.log();
@lepture
lepture / manager.py
Last active December 17, 2015 10:39
upgrade python china
@manager.command
def sync():
from june.models import db, Account, Node, Topic, NodeStatus
users = Account.query.all()
nodes = Node.query.all()
for user in users:
print('save %i %s' % (user.id, user))
if not user.username:
username = user.email.split('@')[0]
@lepture
lepture / fix_orientation.py
Created July 1, 2013 10:56
Rotate it right for browser displaying images.
# coding: utf-8
def fix_orientation(img):
orientation = img.metadata.get('exif:Orientation', 1)
if orientation == 1:
# do nothing
return img
elif orientation == 2:
# vertical mirror