This file contains hidden or 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 strict" | |
( ($) -> | |
loadImage = ($image, src, callback) -> | |
$image.bind "load", (e) -> | |
$image.unbind "load" | |
callback $image | |
.each -> | |
if $image[0].complete | |
$image.trigger "load" |
This file contains hidden or 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 addListener(self, listener, msgClass): | |
if listener not in self.listeners: | |
self.listeners[listener] = {} | |
amTypes = self.listeners[listener] | |
amTypes[msgClass.get_amType()] = msgClass | |
def dispatchPacket(self, source, packet): | |
... | |
for l in self.listeners: |
This file contains hidden or 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 -*- | |
# 字典法 | |
global counter | |
counter = 0 | |
def gem(a, k): | |
""" | |
k是用来表明这次递归从那个固定的数开始 | |
""" | |
n = len(a) |
This file contains hidden or 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
#include <stdio.h> | |
void print(int a, int b) { | |
printf("a=%d, b=%d\n", a, b); | |
} | |
int v1(int a, int b) { | |
int c; | |
c = a; |
This file contains hidden or 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 | |
def move(origin, dest): | |
print "%s -> %s" % (origin, dest) | |
def hanoi(n, origin, assist, dest): | |
if n is 1: | |
move(origin, dest) | |
else: | |
hanoi(n - 1, 'A', 'C', 'B') |
This file contains hidden or 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
function memorize(f) { | |
var cache = {}; | |
// 这个函数是什么意思呢 | |
// 就是使用闭包的特性,保留了cache的值 | |
// 这值将间接使用上次调用时产生的值。下面例子中会详细讲解。 | |
return function() { | |
console.log(cache); // 打印缓存值 | |
// 这里的key就是一个签名档意思,也就是被缓存函数的参数 | |
var key = Array.prototype.join.call(arguments, ','); | |
// console.log(key) |
This file contains hidden or 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 -*- | |
def create_shift_table(pattern): | |
ascii_table = {} | |
len_pattern = len(pattern) | |
for i in range(0, 128): # 初始化表 | |
ascii_table[chr(i)]=len_pattern | |
for i in range(0, len_pattern-1): # 构造移动表,排除模式的最后一个字符 | |
p = pattern[i:i+1] |
This file contains hidden or 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
ace.require("ace/lib/net").loadScript("https://raw.github.com/ajaxorg/ace-builds/master/src-min-noconflict/keybinding-vim.js", function() { | |
e = document.getElementById("ace-editor").env.editor; | |
e.setKeyboardHandler(ace.require("ace/keyboard/vim").handler); | |
}) | |
// for gist | |
ace.require("ace/lib/net").loadScript("https://rawgithub.com/ajaxorg/ace-builds/master/src-min-noconflict/keybinding-vim.js", | |
function() { | |
e = document.querySelector(".ace_editor.ace-github").env.editor; |
This file contains hidden or 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 | |
__copyright__ = 'Yuanxuan Wang <zellux at gmail dot com>' | |
from calibre.web.feeds.news import BasicNewsRecipe | |
from calibre.ebooks.BeautifulSoup import Tag, NavigableString | |
from collections import OrderedDict | |
from contextlib import nested, closing | |
import json |
This file contains hidden or 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
$smartTable = $("#smart-table") | |
class Table | |
constructor: (option) -> | |
{@templateName, @$wrapper} = option | |
@context = [] #内部存储数据列表 | |
click: (e) -> | |
$li = $(e.target) | |
action = $li.attr('action') | |
switch action | |
when "add" |