This file contains 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
# using libfaac on Mac OS X 10.6.8 | |
# -vn : not copying video | |
# -acodec : specify codec used in flv file | |
# -ac : channels. 1 is for mono, 2 is for stereo | |
# -ab : specify bitrate for output file (note that rate is not kbps but bps) | |
# -ar : sampling frequency (Hz) | |
# -threads: number of threads for encoding | |
# "-strict experimental" is necessary to use libfaac | |
ffmpeg -y -i xxxxxxxxxxx.flv -vn -acodec aac -ac 2 -ab 128000 -ar 44100 -threads 4 -strict experimental xxxxx.m4a |
This file contains 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
class Heap(object): | |
def __init__(self, test_func): | |
self._data = [] | |
self._pos = 0 | |
self.test_func = test_func | |
def size(self): | |
return self._pos | |
def add(self, val): |
This file contains 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
# TODO: this program too slow, got be some nice solution. :( | |
# some graph related knownledge | |
def f(node, x): | |
return node[0] * x + node[1] | |
paths = {} | |
def cache(fn): | |
def _(u, v, *args, **kwargs): |
This file contains 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 | |
from type_checked_entities import entity_factory | |
Giraffe = entity_factory( # let's define what is a giraffe! | |
"giraffe", | |
name=str, # my name is a string | |
age=float, # my age is an int | |
eats=object, # I eat pretty much everything. | |
) |
This file contains 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
""" | |
A mutlimethod decorator, dispatch based on the input types. | |
""" | |
registry = {} | |
def multimethod(*types): | |
def wrapper(fn): | |
# registry key=>func | |
_types = tuple(t for t in types) | |
registry[_types] = fn |
This file contains 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
flatten = function (a, b) { | |
if (!Array.isArray(a)) { | |
a = [a]; | |
} | |
return a.concat(b); | |
} | |
// usage | |
var aa = [[1], [2, 3], [4, 5]]; |
This file contains 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
# server.py | |
# fib microservice | |
from socket import * | |
# from threading import Thread | |
from collections import deque | |
from select import select | |
from concurrent.futures import ThreadPoolExecutor as Pool | |
from concurrent.futures import ProcessPoolExecutor as Pool |
This file contains 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
%{ | |
int nchar, nword, nline; | |
%} | |
%% | |
\n { nline++; nchar++ ;} | |
[^ \t\n]+ { nword++; nchar += yyleng; } | |
. { nchar++; } | |
%% |
This file contains 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
#-*- encoding: utf8 -*- | |
from sre_parse import Pattern, SubPattern, parse | |
from sre_compile import compile as sre_compile | |
from sre_constants import BRANCH, SUBPATTERN | |
class Scanner(object): | |
def __init__(self, rules, flags=0): |
This file contains 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
#-*- encoding: utf8 -*- | |
import pickle | |
import sys | |
from threading import Thread | |
PY2 = sys.version_info[0] == 2 | |
if PY2: | |
from Queue import Queue |