Skip to content

Instantly share code, notes, and snippets.

View kalloc's full-sized avatar
🌋

kalloc kalloc

🌋
View GitHub Profile
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')
@kalloc
kalloc / node_stress.js
Created May 31, 2011 15:59
nodejs: stress tools
function Combo(callback) {
this.callback = callback;
this.items = 0;
this.results = [];
}
Combo.prototype = {
add: function () {
var self = this;
this.items++;
return function () {
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
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'
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)
@kalloc
kalloc / hexdump.c
Last active September 30, 2015 18:48
#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++) {
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")
def mod(x, y, z):
number = 1
while y:
if y & 1:
number = number * x % z
y >>= 1
x = x * x % z
return number
#!/usr/bin/env python
import signal
import ctypes
import sys
import ctypes.util
import os
from ctypes import (
cast,
c_int,
c_int32,
@kalloc
kalloc / 0_reuse_code.js
Created December 13, 2013 14:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console