This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// following https://gist.github.com/911094 | |
function amb_run(program, failure_value) { | |
var index = 0, steps = []; | |
while (true) try { | |
return program(amb, fail); | |
} catch(ex) { | |
if (ex !== fail) throw ex; | |
for (var i = steps.length; --i >= 0;) { | |
var a = steps[i]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// run with NodeJS, or load in a browser with console.log | |
////// test | |
with_graph([ | |
["oradea" , "zerind" , 71], | |
["oradea" , "sibiu" , 151], | |
["zerind" , "arad" , 75], | |
["arad" , "sibiu" , 140], | |
["arad" , "timisoara" , 118], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var U = require("uglify-js"); | |
var fs = require("fs"); | |
var sys = require("sys"); | |
var code = fs.readFileSync("/tmp/test.js", "utf8"); | |
// 1. parse | |
var ast = U.parser.parse(code); | |
// 2. UglifyJS compress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defpackage :value-iteration | |
(:use :cl)) | |
(in-package :value-iteration) | |
(defun value-iteration (&key grid is-term actions next-state cost gamma) | |
(loop :with changed = nil | |
:for i :from 0 :to (1- (array-dimension grid 0)) | |
:finally (return changed) | |
:do (loop :for j :from 0 :to (1- (array-dimension grid 1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Explaining https://twitter.com/mcbazon/status/236504096868286464 | |
// I have a simple output stream implementation that keeps track | |
// of current line/col numbers. It accumulates text in the OUTPUT | |
// variable, and at times I needed to know the last character | |
// that was added. I had this function: | |
function last_char() { | |
return OUTPUT.charAt(OUTPUT.length - 1); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
uglifyjs -v -b -nm -ns -nc $1 > /tmp/ugly-diff-1 | |
uglifyjs -v -b -nm -ns -nc $2 > /tmp/ugly-diff-2 | |
diff /tmp/ugly-diff-1 /tmp/ugly-diff-2 | colordiff | less -R |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/local/bin/node | |
var esprima = require("esprima"); | |
var acorn = require("acorn"); | |
var u2 = require("uglify-js2"); | |
var fs = require("fs"); | |
var file = process.argv[2]; | |
var code = fs.readFileSync(file, "utf8"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.pf1(@prop, @value) { | |
we: ~`"suck; " + | |
" -webkit-@{prop}: @{value};" + | |
" -moz-@{prop}: @{value};" + | |
" -o-@{prop}: @{value};" + | |
" -ms-@{prop}: @{value};" + | |
" @{prop}: @{value}"`; | |
} | |
.pf2(@prop, @value) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; -*- lexical-binding: t -*- | |
;;; qq-highlight.el | |
;;; Provides a function that temporarily highlights Lisp code | |
;;; templates (quasi-quotations) to make them easier to follow. | |
;;; | |
;;; Author: Mihai Bazon <[email protected]>, 2013. | |
;;; This file is public domain. | |
;;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; stupid-indent-mode.el --- Plain stupid indentation minor mode | |
;; Copyright (C) 2013 Mihai Bazon | |
;; Author: Mihai Bazon <[email protected]> | |
;; Keywords: | |
;; This program is free software; you can redistribute it and/or modify | |
;; it under the terms of the GNU General Public License as published by | |
;; the Free Software Foundation, either version 3 of the License, or |
OlderNewer