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 / cloud.js
Created October 11, 2016 09:56
LeanCloud WeApp Integration
AV.Cloud.define('loginWeApp', function(request, response) {
var WX_APP_ID = 'WX_APP_ID'
var WX_SECRET = 'WX_SECRET';
var code = request.params.code;
var signature = request.params.signture;
var rawData = request.params.rawData;
var userInfo = JSON.parse(rawData);
var openid, user;
var fs = require('fs');
var router = require('express').Router();
var heapdump = require('heapdump');
var AV = require('leanengine');
router.post('/snapshot', function(req, res, next) {
var name = 'dump_' + Date.now() + '.heapsnapshot';
heapdump.writeSnapshot('/tmp/' + name, function(err, filename) {
if(err) {
return next(err);
@aisk
aisk / 0_reuse_code.js
Created February 12, 2016 14:29
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
@aisk
aisk / de2.py
Created February 2, 2016 09:38
import ast
def menu(*args, **kwargs):
def inner(f):
pass
return inner
a = ast.parse('''
@menu('xxx', parent='xxx')
class Xxx(object):
@aisk
aisk / de.py
Created February 2, 2016 08:58
def menu(name, parent_name):
do_some_thing_with_params(name, parent_name)
def inner_func(f):
do_some_thing()
return f()
return inner_func
@aisk
aisk / example.biu
Last active December 30, 2015 00:09
# buildin functions
# add -> integer -> integer
add 1 2 # => 3
# log -> nothing
log 1
# variable assignment
@aisk
aisk / brainfuck.go
Created August 22, 2013 07:46
Go brainfuck hello world
package main
const (
MEMORY_SIZE = 100
)
type State struct {
Instructions string
Memory []byte
Ip int
@aisk
aisk / app.scm
Created April 10, 2013 12:30
bottle and lizpop
(define bt (import "bottle"))
(define route (attr bt "route"))
(define (index) "Hello")
((route "/")
(@callable (lambda ()
"Hello")))
((attr bt "run"))
@aisk
aisk / json.cf
Last active December 15, 2015 13:39
json parser rules for bnfc
VObject. Value ::= "{" [Item] "}" ;
ObjItem. Item ::= String ":" Value ;
separator Item "," ;
terminator Item "" ;
VArray. Value ::= "[" [Value] "]" ;
separator Value "," ;
terminator Value "" ;
VInt. Value ::= Integer ;
# coding: utf-8
from pprint import pprint
RIGHT, DOWN, LEFT, UP = 1, 2, 3, 4
class MatrixWalker(object):
def __init__(self, width):
self.width = width
x = width + 2 # 多一圈,作为最外圈的墙壁