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
/* | |
No jQuery necessary. | |
Thanks to Dan's StackOverflow answer for this: | |
http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport | |
*/ | |
function isElementInViewport(el) { | |
var rect = el.getBoundingClientRect(); | |
return ( | |
rect.top >= 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
const fs = require('fs'); | |
const Canvas = require('canvas'); | |
function compress(buff) { | |
// 将文件绘制成图片对象 | |
let image = new Canvas.Image; | |
image.src = buff; | |
// 获取原始图片宽高 | |
let drawWidth=image.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
import tasks | |
import logging | |
import tornado.web | |
import functools | |
import threading | |
from tornado import gen | |
from tornado.concurrent import Future | |
from tornado.web import asynchronous |
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 urllib2 | |
request = urllib2.Request(uri, data=data) | |
request.get_method = lambda: 'PUT' # or 'DELETE' | |
response = urllib2.urlopen(request) |
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 getSearchKey = function(key){ | |
if (!location.search) return null; | |
var list = location.search.split("?")[1].split("&"); | |
for (var i=0; i < list.length; ++i){ | |
if (!list[i]) continue; | |
var dict = list[i].split("="); | |
if (key == dict[0]){ | |
return dict[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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
@File Name: time.py | |
@Author: kehr | |
@Mail: kehr.china@gmail.com | |
@Created Time: 日, 07/12/2015, 01时27分08秒 | |
@Copyright: GPL 2.0 | |
@Description: | |
""" |
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 umysql | |
from functools import wraps | |
class Configuraion: | |
def __init__(self, env): | |
if env == "Prod": | |
self.host = "coolshell.cn" | |
self.port = 3306 | |
self.db = "coolshell" | |
self.user = "coolshell" |
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
# unzip zip file of current directory | |
for i in `ls` | |
do | |
name=`echo $i | awk -F'.' '{print $1}'` | |
unzip $i -d $name | |
done |