#package
- package control
- All Autocomplete
- TypeScript
- sublimeLinter
- HTML-CSS-JS Prettify
- Emmet
- Markdown Preview
import hashlib | |
import re | |
import time | |
import uuid | |
from requests.adapters import HTTPAdapter | |
from streamlink.plugin import Plugin | |
from streamlink.plugin.api import http, validate, useragents | |
from streamlink.stream import HTTPStream, HLSStream, RTMPStream |
#package
def binarySearch(l, t): | |
low, high = 0, len(l) - 1 | |
while low < high: | |
print low, high | |
mid = (low + high) / 2 | |
if l[mid] > t: | |
high = mid | |
elif l[mid] < t: | |
low = mid + 1 | |
else: |
function imgToBase64(img){ | |
var canvas = document.createElement('canvas'); | |
var ctx = canvas.getContext('2d'); | |
canvas.height=img.height; | |
canvas.width=img.width; | |
ctx.drawImage(img,0,0); | |
var base64=canvas.toDataURL('image/jpeg'); | |
canvas=null; | |
return base64; | |
} |
//list [{id:id,name:name,parent_id:pid},] | |
function doCatalogList(list, callback) { | |
//init {id:path} obj {id:name} | |
var id_path = {}; | |
var id_name = {}; | |
for (var i = 0; i < list.length; i++) { | |
id_path[list[i].id] = []; | |
id_path[list[i].id].push(list[i]['parent_id']); |
//from http://es6.ruanyifeng.com/#docs/arraybuffer | |
// ArrayBuffer转为字符串,参数为ArrayBuffer对象 | |
function ab2str(buf) { | |
return String.fromCharCode.apply(null, new Uint16Array(buf)); | |
} | |
// 字符串转为ArrayBuffer对象,参数为字符串 | |
function str2ab(str) { | |
var buf = new ArrayBuffer(str.length * 2); // 每个字符占用2个字节 |
from functools import wraps | |
from flask import make_response | |
def allow_cross_domain(fun): | |
@wraps(fun) | |
def wrapper_fun(*args, **kwargs): | |
rst = make_response(fun(*args, **kwargs)) | |
rst.headers['Access-Control-Allow-Origin'] = '*' | |
rst.headers['Access-Control-Allow-Methods'] = 'PUT,GET,POST,DELETE' |