Skip to content

Instantly share code, notes, and snippets.

@jameskeane
jameskeane / vmx
Last active Apr 15, 2021
VMWare Fusion Mac -> Linux horizontal scroll fix
View vmx
mouse.vusb.enable = "TRUE"
mouse.vusb.useBasicMouse = "FALSE"
mks.mouse.pixelScrollSensitivity = "1"
@jameskeane
jameskeane / parser.js
Created Nov 9, 2018
Learn you parsing
View parser.js
// This code will teach you how to write a simple recursive descent parser.
// Corners will be cut, but by the end you will have the basis of most
// programming languages out there: strings, numbers, identifiers, and
// infix arithmetic expressions with precendence.
// At under 100 lines, I promise it won't take long. Happy Hacking!
// -- James Keane
//
// First the source code has to be tokenized, for the parser.
// Let's do five tokens, and ignore whitespace:
// 1. operators (+, -, *, etc.)
View ghetto-tco.js
function tco(f) {
let isin = false;
return function() {
if (isin) throw [this, arguments];
isin = true;
let args = [this, arguments];
while(true) {
try {
const ret = f.apply(args[0], args[1]);
isIn = false;
@jameskeane
jameskeane / .block
Created Apr 5, 2016
document.location.hash
View .block
border: no
@jameskeane
jameskeane / .block
Last active Apr 1, 2016
Small example to demonstrate safari bug.
View .block
border: no
View designer.html
<link rel="import" href="../topeka-elements/theme.html">
<link rel="import" href="../topeka-elements/topeka-resources.html">
<link rel="import" href="../topeka-elements/topeka-app.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
View designer.html
<link rel="import" href="../polymer/polymer.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
@jameskeane
jameskeane / closure.js
Created Jul 20, 2014
closure library for ternjs
View closure.js
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
return mod(require("../lib/infer"), require("../lib/tern"));
if (typeof define == "function" && define.amd) // AMD
return define(["../lib/infer", "../lib/tern"], mod);
mod(tern, tern);
})(function(infer, tern) {
"use strict";
var WG_TEMP_OBJ = 40;
@jameskeane
jameskeane / dbgod.py
Created Apr 17, 2013
Postgres stored procedures in python.
View dbgod.py
from inspect import getfullargspec, getsourcelines
type_map = {
int: 'integer'
}
tmpl = """
CREATE FUNCTION {func_name} ({args})
RETURNS {return_t}
AS $$
@jameskeane
jameskeane / HelloWorld.py
Last active Dec 15, 2015
Simple DFA based HTTP dispatch
View HelloWorld.py
import nails
class IndexController(nails.Controller):
def index(self, request):
return "Hello World from controller!"
def proof(self, request):
return "Proof that routing is working"