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
import functools | |
def timethis(func): | |
"""A profiling function used to record the time consumed on a function call.""" | |
@functools.wraps(func) | |
def _(self, *a, **kw): | |
start = time() | |
ret = func(self, *a, **kw) |
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
# losslessly concat mp4 files | |
ffmpeg -i input1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts | |
ffmpeg -i input2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts | |
ffmpeg -i "concat:intermediate1.ts|intermediate2.ts" -c copy -bsf:a aac_adtstoasc output.mp4 | |
# concat files with the same format | |
# 1. create a file list | |
file '/path/to/file1' | |
file '/path/to/file2' | |
file '/path/to/file3' |
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
// element dimension | |
var w = $(this).width(); | |
var h = $(this).height(); | |
// current window(viewport) dimension | |
var w = $(window).width(); | |
var h = $(window).height(); | |
// document dimension | |
var w = $(document).width(); |
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
var emailValidator = function(s) { | |
s = $.trim(s); | |
var name, addr, p = s.indexOf('<'); | |
if (p >= 0 && s.charAt(s.length - 1) == '>') { | |
name = $.trim(s.substring(0, p)); | |
addr = s.substring(p+1, s.length - 1); | |
} else { | |
addr = s; |
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
patch: | |
schema_list: | |
- schema: luna_pinyin_simp | |
- schema: emoji |
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 | |
import sys | |
from subprocess import call | |
remote = sys.argv[1] | |
if remote == 'origin': | |
for line in sys.stdin.readlines(): | |
local_ref, local_sha, remote_ref, remote_sha = line.split(' ') | |
branch = remote_ref.split('/', 2)[2] |
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 | |
import os | |
import sys | |
import errno | |
from PIL import Image | |
try: | |
filename = sys.argv[1] | |
im = Image.open(filename) |
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
#deprecated | |
def grep_php_const(lines, name): | |
regexp = "^define\(\s*'%s',\s*'(.*)'\s*\);\s*$" % name | |
for line in lines: | |
m = re.match(regexp, line) | |
if m: | |
return m.group(1) | |
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
# scan a network | |
fping -a -r 0 -g 192.168.1.0/24 | |
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
def read_and_decode(filename_queue): | |
"""Read from tfrecords file and decode and normalize the image data.""" | |
reader = tf.TFRecordReader() | |
_, serialized_exmaple = reader.read(filename_queue) | |
features = tf.parse_single_example( | |
serialized_exmaple, | |
features={ | |
'image': tf.FixedLenFeature([], tf.string), | |
'label': tf.FixedLenFeature([], tf.int64), |
OlderNewer