Skip to content

Instantly share code, notes, and snippets.

View aisk's full-sized avatar
🍺
Drunk

AN Long aisk

🍺
Drunk
View GitHub Profile
@aisk
aisk / example.lua
Created June 22, 2014 17:21
deadly simple ngx_openresty router
local inspect = require "inspect"
local web = require "web"
app = web.Application:new()
app:handle('GET', '^/?$', function(req, res)
res.print('this is index')
end)
app:handle('GET', '^/about/?$', function(req, res)
@aisk
aisk / block.c
Last active August 29, 2015 14:03
#include <stdio.h>
#include <stdlib.h>
struct Person {
char* name;
void (^say)(void);
};
struct Person *PersonNew(char *name) {
struct Person *self = malloc(sizeof(struct Person));
var assert = require("assert");
var activities = {
"Aqua aerobics": 4,
"Athletics, high jump, long jump, triple jump, javelin, pole vault": 6,
"Athletics, shot, discus, hammer": 4,
"Athletics, steeplechase, hurdles": 10,
"Badminton, competitive": 7,
"Badminton, social": 4.5,
"Baseball": 5,
var p1 = new Promise(function(resolve, reject) {
setTimeout(function() {
resolve(1);
}, 2);
});
var p2 = new Promise(function(resolve, reject) {
setTimeout(function() {
reject(1);
}, 1);
'use strict';
var async = require('async');
var let_it_bug = true;
var ioFunc = function(cb) {
if (! let_it_bug) {
var result = 42; // do something to get the result
cb(undefined, 42);
@aisk
aisk / xxx.py
Created September 7, 2015 02:47
import os import sys
# make stdout and stderr without buffer
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
sys.stderr = os.fdopen(sys.stderr.fileno(), 'w', 0)
// generated by asdl_pyston.py
#include <algorithm>
#include <cmath>
#include <langinfo.h>
#include <sstream>
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "codegen/unwinding.h"
@aisk
aisk / make_bytecode.py
Created October 26, 2012 06:57
generate a pyc file by hand. the bytecode's content is something like test.py content.
import marshal
import struct
import time
import imp
from opcode import opmap
def f(): return
code = type(f.__code__) # the code object type
code_list = (
@aisk
aisk / sexpr2pyc.py
Created October 28, 2012 12:50
compile simple s-expressions to python bytecode file.
import marshal
import struct
import time
import imp
from opcode import opmap
SEXPR = ('+', 1,
('-', 3,
('+', 1 , 1)))
@aisk
aisk / x.py
Created October 14, 2015 05:34
d = {'a': 1, 'b': 2}
keys = d.keys()
for k in keys:
v = d[k]
d['xxx'] = 'ooo'