Skip to content

Instantly share code, notes, and snippets.

View ratazzi's full-sized avatar

Ratazzi ratazzi

View GitHub Profile
# 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
@huacnlee
huacnlee / mencoder covert video for iOS and Android
Created October 20, 2010 03:36
使用 Mencoder 将视频转换为支持iOS和Android的H.264视频格式
$ 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
@jie
jie / session.py
Created May 24, 2011 07:56
a gae session
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 = '/'
anonymous
anonymous / t.py
Created September 15, 2011 15:13
import threading
import time
def bug(num):
while 1:
print "bug!^C may not work!thread-%d"%num
time.sleep(1)
threads=[]
@colwilson
colwilson / pymr.py
Created November 6, 2011 20:58
MapReduce in Python
from multiprocessing import Pool
import string
import random
def mapFunction(letter):
return (letter, 1)
def partition(tuples):
mapping = {}
for t in tuples:
@ambv
ambv / map_reduce.py
Created November 29, 2011 21:16
Proper MapReduce in Python
#!/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
@exhuma
exhuma / gist:2136677
Created March 20, 2012 15:06
Bash completion for fabric
#
# Bash completion for fabric
#
function _fab_complete() {
local cur
if [[ -f "fabfile.py" || -d "fabfile" ]]; then
@lepture
lepture / instance_cache.py
Created March 23, 2012 07:08
instance cache
#!/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
@leecade
leecade / cd_finder_path.bashrc
Created June 5, 2012 22:51
bash:cd_finder_path
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
#!/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'