Skip to content

Instantly share code, notes, and snippets.

View jameskeane's full-sized avatar
🏠
Working from home

James Keane jameskeane

🏠
Working from home
View GitHub Profile
@jameskeane
jameskeane / vmx
Last active July 17, 2022 08:20
VMWare Fusion Mac -> Linux horizontal scroll fix
mouse.vusb.enable = "TRUE"
mouse.vusb.useBasicMouse = "FALSE"
mks.mouse.pixelScrollSensitivity = "1"
@jameskeane
jameskeane / parser.js
Created November 9, 2018 23:40
Learn you parsing
// 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.)
@jameskeane
jameskeane / ghetto-tco.js
Created March 6, 2018 19:13
Stack unwinder
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 April 5, 2016 15:40
document.location.hash
border: no
@jameskeane
jameskeane / .block
Last active April 1, 2016 20:46
Small example to demonstrate safari bug.
border: no
<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;
<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 July 20, 2014 03:31
closure library for ternjs
(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 April 17, 2013 18:45
Postgres stored procedures in python.
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 December 15, 2015 05:19
Simple DFA based HTTP dispatch
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"