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
Element.Properties.jsonrpc = { | |
set: function(options){ | |
var jsonrpc = this.retrieve('jsonrpc'); | |
if (jsonrpc) jsonrpc.cancel(); | |
return this.eliminate('jsonrpc').store('jsonrpc:options', $extend( | |
{ | |
data: this, | |
link: 'cancel', | |
method: this.get('method') || 'post', | |
url: this.get('action') |
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 Combo(callback) { | |
this.callback = callback; | |
this.items = 0; | |
this.results = []; | |
} | |
Combo.prototype = { | |
add: function () { | |
var self = this; | |
this.items++; | |
return function () { |
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 time | |
def tracktime(f): | |
import time | |
def x(*a, **kw): | |
start = time.time() | |
res = f(*a, **kw) | |
print 'code work %d ms time'%((time.time()-start)*10**3) | |
return res | |
return x | |
@tracktime |
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
consonant = set(['q', 'w', 'r', 't', 'p', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'z', 'x', 'c', 'v', 'b', 'n', 'm']) | |
vowel = set(['e', 'y', 'u', 'i', 'o', 'a']) | |
def to_nouns(word): | |
if word[-1] in consonant and (word[-2:] in ['sh', 'ss', 'ch'] or word[-1] == 's'): | |
return word+'es' | |
elif word[-1] == 'y' and word[-2] in consonant: | |
return word[:-1]+'ies' | |
return word+'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
from itertools import izip, chain | |
from functools import * | |
from inspect import * | |
import sys | |
def accepts(**test_kwargs): | |
def check(param, cls): | |
if type(cls) not in (list, set, tuple): | |
cls = (cls,) | |
values = filter(lambda el: type(el).__name__ not in ('type', 'classobj'), cls) |
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
#include <stdio.h> | |
#include <string.h> | |
char raw[] = "\x0d\x0a\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa\xbb\xcc\xdd\xee\xff"; | |
void hexdump(char *ptr, int len, int width) { | |
int count = 1; | |
printf("--------------------\n"); | |
for(;len>0;len--,ptr++,count++) { |
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 requests | |
from M2Crypto import BIO, RSA, EVP, X509 | |
def verify_message(pem, msg, sig): | |
cert = X509.load_cert_string(pem) | |
pubkey = cert.get_pubkey() | |
sig = sig.decode('base64') | |
# Write a few files to disk for debugging purposes | |
f = open("sig", "wb") |
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
def mod(x, y, z): | |
number = 1 | |
while y: | |
if y & 1: | |
number = number * x % z | |
y >>= 1 | |
x = x * x % z | |
return number | |
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 | |
import signal | |
import ctypes | |
import sys | |
import ctypes.util | |
import os | |
from ctypes import ( | |
cast, | |
c_int, | |
c_int32, |
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 |
OlderNewer