This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Example ncurses program that should print all combinations of foreground | |
| # color on background color but doesn't work. | |
| # Make your terminal 256 characters wide for best view. | |
| require 'rubygems' | |
| require 'ncurses' | |
| screen = Ncurses.initscr | |
| Ncurses.noecho | |
| Ncurses.cbreak |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ sudo apt-get install mencoder | |
| $ mencoder origin.mp4 -o new.mp4 -vf dsize=480:360:2,scale=-8:-8,harddup \ | |
| -oac faac -faacopts mpeg=4:object=2:raw:br=128 \ | |
| -of lavf -lavfopts format=mp4 -ovc x264 -sws 9 \ | |
| -x264encopts nocabac:level_idc=30:bframes=0:bitrate=512:threads=auto:turbo=1:global_header:threads=auto:subq=5:frameref=6:partitions=all:trellis=1:chroma_me:me=umh | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import time | |
| import datetime | |
| import random | |
| import Cookie | |
| import logging | |
| from google.appengine.api import memcache | |
| COOKIE_NAME = 'appengine-session-sid' | |
| DEFAULT_COOKIE_PATH = '/' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import threading | |
| import time | |
| def bug(num): | |
| while 1: | |
| print "bug!^C may not work!thread-%d"%num | |
| time.sleep(1) | |
| threads=[] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from multiprocessing import Pool | |
| import string | |
| import random | |
| def mapFunction(letter): | |
| return (letter, 1) | |
| def partition(tuples): | |
| mapping = {} | |
| for t in tuples: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| """ A response to http://terse-words.blogspot.com/2011/11/mapreduce-in-python.html """ | |
| from __future__ import absolute_import | |
| from __future__ import division | |
| from __future__ import print_function | |
| from __future__ import unicode_literals |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # Bash completion for fabric | |
| # | |
| function _fab_complete() { | |
| local cur | |
| if [[ -f "fabfile.py" || -d "fabfile" ]]; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| # | |
| # Copyright (c) 2012, lepture.com | |
| # | |
| # Redistribution and use in source and binary forms, with or without | |
| # modification, are permitted provided that the following conditions | |
| # are met: | |
| # | |
| # * Redistributions of source code must retain the above copyright |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function cd.() { | |
| # 检查 Finder 是否执行 | |
| if [ "`osascript -e 'tell application "System Events" to "Finder" is in (get name of processes)'`" = "true" ]; then | |
| # 检查当前状态是否可以获取路径 | |
| if [ "`osascript -e 'tell application "Finder" to get collapsed of front window' 2>/dev/null`" != "false" ]; then | |
| if [ "`osascript -e 'tell application "System Events" to "TotalFinderCrashWatcher" is in (get name of processes)'`" = "true" ];then | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # encoding: utf-8 | |
| """ | |
| Usage: | |
| fab deploy:appname | |
| """ | |
| from fabric.api import env, run, cd, local, put | |
| env.hosts = ['myserver.com'] | |
| env.user = 'eric' |
OlderNewer