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 / gist:3735854
Created September 17, 2012 06:37
百度地图坐标与像素互相转换的方法
pixelToPoint = function(point, zoom, center, bounds) {
// 像素到坐标
if (!point) {
return
}
var zoomUnits = getZoomUnits(zoom);
var mercatorLng = center.lng + zoomUnits * (point.x - bounds.width / 2);
var mercatorLat = center.lat - zoomUnits * (point.y - bounds.height / 2);
var mercatorLngLat = {lng: mercatorLng, lat: mercatorLat};
return mercatorToLngLat(mercatorLngLat)
import dis, marshal, struct, sys, time, types
def show_file(fname):
f = open(fname, "rb")
magic = f.read(4)
moddate = f.read(4)
modtime = time.asctime(time.localtime(struct.unpack('L', moddate)[0]))
print "magic %s" % (magic.encode('hex'))
print "moddate %s (%s)" % (moddate.encode('hex'), modtime)
code = marshal.load(f)
@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)))
# 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 # 多一圈,作为最外圈的墙壁
@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 ;
@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 / container.bsk
Last active June 22, 2019 04:56
berserker lang hello world example
using std;
using assert;
func main = ()=> int {
list<int> l = [0, 1, 2, 3, 4, 5];
dict<char*, int> d = {
"one": 1,
"two": 2,
"tree": 3,
};
@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 / example.biu
Last active December 30, 2015 00:09
# buildin functions
# add -> integer -> integer
add 1 2 # => 3
# log -> nothing
log 1
# variable assignment