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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
/v2/post_check | |
============= | |
```json | |
{ | |
"try_split": false, | |
"kind": "1000", | |
"group_order": false, | |
"line_items": [{ | |
"quote_line_item_id": "147183895782223", | |
"quantity": 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
{ | |
/* Keybindings for emacs emulation. Compiled by Jacob Rus. | |
* | |
* This is a pretty good set, especially considering that many emacs bindings | |
* such as C-o, C-a, C-e, C-k, C-y, C-v, C-f, C-b, C-p, C-n, C-t, and | |
* perhaps a few more, are already built into the system. | |
* | |
* BEWARE: | |
* This file uses the Option key as a meta key. This has the side-effect | |
* of overriding Mac OS keybindings for the option key, which generally |
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
package main | |
import ( | |
"fmt" | |
"runtime" | |
) | |
func say(s string) { | |
for i := 0; i < 2; i++ { | |
runtime.Gosched() |
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
package main | |
import ( | |
"fmt" | |
"github.com/paulmach/go.geo" | |
) | |
func main() { | |
// django.geo: 1143 m (result from django geo) | |
// go.geo: 1142.81 m (Mercator.Project + DistanceFrom) |
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 times = function() { | |
var timing = performance.timing; | |
var loadTime = timing.loadEventEnd - timing.navigationStart;//过早获取时,loadEventEnd有时会是0 | |
if(loadTime <= 0) { | |
// 未加载完,延迟200ms后继续times方法,直到成功 | |
setTimeout(function(){ | |
times(); | |
}, 200); | |
return; | |
} |
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
# coding: utf-8 | |
""" | |
这是一个装饰器 可以检测函数调用中的各种性能参数 | |
使用方法: @iprofile("cumulative", 20) | |
""" | |
import cProfile | |
import pstats | |
import StringIO | |
import functools |
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
// jQuery version | |
$("input[type='number']").each(function(i, el) { | |
el.type = "text"; | |
el.onfocus = function(){this.type="number";}; | |
el.onblur = function(){this.type="text";}; | |
}); | |
// Stand-alone version | |
(function(){ var elms = document.querySelectorAll("input"), i=elms.length; | |
while(i--) { |
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 logging | |
logging.basicConfig(filename='testlogging.log', level=logging.DEBUG) | |
logger = logging.getLogger(__name__) | |
def foo(): | |
try: | |
some_code() | |
except Exception: | |
logger.info('hihi', exc_info=True) |
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
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
from random import SystemRandom | |
import sys | |
import re | |
system_random = SystemRandom() | |
def base36_to_int(s): |
NewerOlder