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
class SwitchSign(Exception): | |
pass | |
class BreakOut(Exception): | |
pass | |
def inner(): | |
coef = 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
#!/bin/bash | |
function get_new_names() { | |
local input_names=$1 | |
sed 's/[ \t]\+/:/g' $input_names | |
} | |
function gen_subst_func() { | |
local from=$1 | |
local to=$2 |
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 | |
from pelican import signals | |
from pelican import contents | |
logger = logging.getLogger(__name__) | |
def initialized(pelican): | |
from pelican.settings import DEFAULT_CONFIG |
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 asyncdispatch, math | |
randomize() | |
proc r1() {.async.} = | |
echo("r1 going to sleep....") | |
await sleepAsync(random(1000) + 500) | |
if true: | |
raise newException(ValueError, "Oops!") | |
echo("r1 is awake.") |
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
javascript:void(function(){var%20s=document.createElement('script');s.src='http://code.jquery.com/jquery.js';document.getElementsByTagName('head')[0].appendChild(s);}()) |
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
(function() { | |
var body = document.getElementsByTagName("body")[0]; | |
var target_x = 10; | |
var target_y = 10; | |
var img_list = Array.prototype.slice.call(document.getElementsByTagName("img"), 0, 9); | |
function img_iter(f) { | |
for (var i in img_list) { | |
if (img_list[i].style) { |
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
" Setting up Vundle | |
set nocp | |
filetype off | |
set rtp+=~/.vim/bundle/vundle/ | |
call vundle#rc() | |
" Let Vundle manage Vundle | |
" Required by Vundle doc. | |
Bundle "gmarik/vundle" |
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
-ifndef(__GEN_CALLBACK_SERVER_HRL__). | |
-define(__GEN_CALLBACK_SERVER_HRL__, 1). | |
-type process_ref() :: pid() | {atom(), node()}. | |
-type server_ref() :: pid() | {{local, atom()} | {global, term()} | {via, module(), term()}, node()}. | |
-define(RECEIVE_CB, (fun gen_callback_server:receive_cb/2)). | |
-define(REPLY_CB, (fun gen_callback_server:reply_cb/1)). | |
-define(CLIENT_REPLY_CB, (fun gen_callback_server:client_reply_cb/1)). | |
-define(MIXED_REPLY_CB, (fun gen_callback_server:mixed_reply_cb/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
-module(gen_callback_server). | |
-behaviour(gen_server). | |
-include("gen_callback_server.hrl"). | |
-export([behaviour_info/1]). | |
-export([ | |
start_link/4, |
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
%% | |
%% 一个支持多键值记录的库 | |
%% | |
%% 底层其实是1个gb_tree() + N个dict(),N是键值的数量。 | |
%% 由于最初做世界聊天记录的时候要求按时间排序,所以用了gb_tree(), | |
%% 所以插入和删除会慢一点(大概几十微秒),但是查找会比较快(几微秒) | |
%% | |
%% 如果不在意顺序,完全可以把gb_tree()和dict()换成ets,插入/删除应该能快很~多倍 | |
%% | |
%% 用法: |
OlderNewer