This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.
To capture the video (filesize: 19MB), using the free "QuickTime Player" application:
def find_zero_sum(arr): | |
sums = [0] * len(arr) | |
for i, x in enumerate(arr): | |
for j in range(0, i + 1): | |
sums[j] += arr[i] | |
if sums[j] == 0: | |
return (j, i) | |
arr = [8, 1, 2, 7, -4, -6] | |
zero_sum_index = find_zero_sum(arr) |
#-*- coding:utf-8 -*- | |
def get_f1(standard_answer, user_answer): | |
s_user_answer = set(user_answer) | |
s_standard_answer = set(standard_answer) | |
correct_results_len = len(s_user_answer & s_standard_answer) | |
if correct_results_len > 0: | |
precision = float(correct_results_len) / len(user_answer) | |
recall = float(correct_results_len) / len(standard_answer) | |
f1 = 2 * precision * recall / (precision + recall) |
def __parse_dict_depth(self, d, depth=0): | |
if not isinstance(d, dict) or not d: | |
return depth | |
return max(self.__parse_dict_depth(v, depth+1) for k, v in d.iteritems()) |
{"name":"北京市","zip":"100000","alias":"北京","pinyin":"BeiJing","level":"1","parent_id":"","abbr":"BJ","id":"110000"} | |
{"name":"东城区","zip":"100010","alias":"东城区","pinyin":"DongChengQu","level":"2","parent_id":"110000","abbr":"DCQ","id":"110101"} | |
{"name":"西城区","zip":"100032","alias":"西城区","pinyin":"XiChengQu","level":"2","parent_id":"110000","abbr":"XCQ","id":"110102"} | |
{"name":"朝阳区","zip":"100011","alias":"朝阳区","pinyin":"ChaoYangQu","level":"2","parent_id":"110000","abbr":"CYQ","id":"110105"} | |
{"name":"丰台区","zip":"100071","alias":"丰台区","pinyin":"FengTaiQu","level":"2","parent_id":"110000","abbr":"FTQ","id":"110106"} | |
{"name":"石景山区","zip":"100071","alias":"石景山区","pinyin":"ShiJingShanQu","level":"2","parent_id":"110000","abbr":"SJSQ","id":"110107"} | |
{"name":"海淀区","zip":"100091","alias":"海淀区","pinyin":"HaiDianQu","level":"2","parent_id":"110000","abbr":"HDQ","id":"110108"} | |
{"name":"门头沟区","zip":"102300","alias":"门头沟区","pinyin":"MenTouGouQu","level":"2","parent_id":"110000","abbr":"MTGQ","id":"110109"} | |
{"name":"房山区","zip" |
jq -c 'select(.series|startswith("启辰D50"))' 8.1-12.31_all.json |jq -c 'select(.published_at|startswith("2014-09"))' |wc -l |
flatten = lambda lst: reduce(lambda l, i: l + flatten(i) if isinstance(i, (list, tuple)) else l + [i], lst, []) | |
print flatten([2, [2, [4, 5, [7], [2, [6, 2, 6, [6], 4]], 6]]]) | |
# [2, 2, 4, 5, 7, 2, 6, 2, 6, 6, 4, 6] |
#-*- coding:utf-8 -*- | |
import urllib2 | |
import re | |
def get_lrc(name, singer): | |
xml_url = 'http://box.zhangmen.baidu.com/x?op=12&count=1&title=%s$$%s$$$$'%(name.encode('utf-8'), singer.encode('utf-8')) | |
xml_str = urllib2.urlopen(xml_url).read() | |
lrcid_pattern = re.compile(r'<lrcid>(.+?)</lrcid>') | |
lrcid = int(re.search(lrcid_pattern, xml_str).group(1)) | |
lrc_url = "http://box.zhangmen.baidu.com/bdlrc/%d/%d.lrc"%(lrcid//100, lrcid) |
import stepic | |
from PIL import Image | |
import sys | |
useage = 'useage:\nencode: python hideinfo.py IMG INFO OUTPUT\ndecode: python hideinfo.py IMG' | |
def encode_img(img, info, output): | |
img = Image.open(img) | |
d = open(info) |
# !/usr/bin/env python | |
# -*- coding:utf-8 -*- | |
import urllib2 | |
import cookielib | |
import re | |
import urllib | |
import os | |
import Queue | |
import threading |