Skip to content

Instantly share code, notes, and snippets.

@gloryofrobots
gloryofrobots / nano_lisp.js
Last active December 29, 2015 01:48
Simple lisp interpreter written on js. It supports js numbers, "lambda", "define", "if", "set!"
function _make_function(args, body) {
return new Function(args, body);
}
// helpers
var $ = _make_function("id" ,"return document.getElementById(id)")
var _isarray = _make_function("obj","return obj instanceof Array;")
var _error = _make_function("txt", "throw new Error(txt)")
var _is_undefined = _make_function("obj","return obj == undefined")
function _add_repr_to_object (o, r) {
@gloryofrobots
gloryofrobots / gist:8851750
Created February 6, 2014 20:16
Python metaclass example
class QueryBook(object):
def __init__(self, tableName):
self.tableName = tableName
def add(self, queryName, query):
#setattr(self, queryName, query)
def execute(*args):
self.__execute(query, args)
@gloryofrobots
gloryofrobots / gist:2bb631e6d73634395394
Last active February 28, 2019 18:15
ego-motion compensation
import cv2
import sys
import numpy as np
lk_params = dict(winSize=(15, 15), maxLevel=5,
criteria=(cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT, 10, 0.03),
)
feature_params = dict(maxCorners=1000,
qualityLevel=0.01,
@gloryofrobots
gloryofrobots / *.php
Last active August 29, 2015 14:25
dijkstra hash in php
function myhash($str) {
$result = 5381;
for($i=0; $i<strlen($str); $i++) {
$c = (int) $str[$i];
$result = (($result << 5) + $result) + $c;
}
return $result;
}
$str = "aabbcc";
echo "Hash for ".$str." = ". myhash($str);
import argparse
class Value(object):
def __init__(self, alias, name):
super(Value, self).__init__()
self.alias = alias
self.name = name
class Converter(object):
def __init__(self, first, second, multiplier):
package draft;
public class GenericValue {
enum Type {INT, DOUBLE};
interface Val {
public String str();
public Type type();
Operations ops();
package draft;
public class GenericValue2 {
enum Type {INT, DOUBLE};
interface Val {
public String str();
public Type type();
}
;;; Nameses enables named sessions.
;; Nameses is largely based on my-desktop.el by Scott Frazer
;; Modification by Jannis Teunissen
;; Version 0.02 - 21 Nov 2014 (added extra check)
;;; *** Usage ***
;; Note: if 'name' is not given, you'll be asked for a name
;;
;; (nameses-load prefix &optional name) -> without prefix: load session
;; (nameses-load prefix &optional name) -> with prefix: save session