Skip to content

Instantly share code, notes, and snippets.

View lxneng's full-sized avatar
🎯
Focusing

Eric Luo lxneng

🎯
Focusing
View GitHub Profile
from pyramid_chameleon_genshi import renderer_factory
config.add_renderer(".html", renderer_factory)
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script type="text/javascript">
if (typeof jQuery == 'undefined')
{
document.write(unescape("%3Cscript src='/path/to/your/jquery' type='text/javascript'%3E%3C/script%3E"));
}
</script>
>>> import random
>>> ''.join(random.sample('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', 4))
'eKq1'
>>> # 62!/(62-4)! = 13 388 280
>>> # (62 !) / ((62 - 3) !) = 226 920
>>> # (62 !) / ((62 - 4) !) = 13 388 280
>>> def factorial(n):
... return reduce(lambda x,y: x*y, range(1,n+1))
...
...
@lxneng
lxneng / yupoo_backup.rb
Created June 8, 2011 07:02 — forked from huacnlee/yupoo_backup.rb
Yupoo 图片备份工具
# coding: UTF-8
#
# Yupoo 照片备份工具
# 此工具不需要API,直接就能备份你的照片信息,下载后以图片 + 一个文本文件的方式存放
# 备份包括内容:
# 原图,标题,说明,Tag,当然有 Exif 信息
#
# Jason Lee <[email protected]>
# http://huacnlee.com
# 2011-01-28

Hide A File Or Directory On Mac Os X

To hide a file or directory

chflags hidden ~/path
@lxneng
lxneng / fabfile.py
Created June 7, 2011 08:01 — forked from onyxfish/fabfile.py
Chicago Tribune News Applications fabric deployment script
from fabric.api import *
"""
Base configuration
"""
env.project_name = '$(project)'
env.database_password = '$(db_password)'
env.site_media_prefix = "site_media"
env.admin_media_prefix = "admin_media"
env.newsapps_media_prefix = "na_media"
@lxneng
lxneng / gist:1005730
Created June 3, 2011 02:13
natty 163 mirror
deb http://mirrors.163.com/ubuntu/ natty main universe restricted multiverse
deb-src http://mirrors.163.com/ubuntu/ natty main universe restricted multiverse
deb http://mirrors.163.com/ubuntu/ natty-security universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ natty-security universe main multiverse restricted
deb http://mirrors.163.com/ubuntu/ natty-updates universe main multiverse restricted
deb http://mirrors.163.com/ubuntu/ natty-proposed universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ natty-proposed universe main multiverse restricted
deb http://mirrors.163.com/ubuntu/ natty-backports universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ natty-backports universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ natty-updates universe main multiverse restricted
@lxneng
lxneng / gist:1003869
Created June 2, 2011 03:25
How to do a “git export” (like “svn export”)

How to do a “git export” (like “svn export”)

Probably the simplest way to achieve this is with git archive. If you really need just the expanded tree you can do something like this.

git archive master | tar -x -C /somewhere/else

Most of the time that I need to 'export' something from git, I want a compressed archive in any case so I do something like this.

tig

While inside a git repo, type 'tig', to view an interactive log, hit 'enter' on any log to see more information about it. h for help, which lists the basic functionality.

On Mac OSX

~/project $ git init
~/project $ git add .
~/project $ git commit -m "first commit"
~/project $ cd ~/Dropbox/git
~/Dropbox/git $ mkdir project.git
~/Dropbox/git $ cd project.git
~/Dropbox/git $ git init --bare
~/Dropbox/git $ cd ~/project