Skip to content

Instantly share code, notes, and snippets.

faster(X,Y) :- faster(X,Z), faster(Z,Y).
eat(X,Y) :- faster(X,Y), carnivore(X).
eat(lion, zebra).
faster(zebra, dog).
carnivore(dog).
% then I try
eat(lion, X). % and I only get zebra
function BF (code, get, print) {
eval("var i=0,d={0:0};"+code.replace(/[^\[\]\-\+\,\.\<\>]/g, "").replace(/\]/g, "}").replace(/\[/g, "while(d[i]) {").replace(/\-/g, "d[i]--;").replace(/\+/g, "d[i]++;").replace(/\</g, "i--;d[i]=d[i]?d[i]:0;").replace(/\>/g, "i++;d[i]=d[i]?d[i]:0;").replace(/\,/g, "d[i]=get();").replace(/\./g, "print(d[i]);"));
}
import urllib
import re
import os
path = "./"
i = 1
content = True
while content:
dir = os.listdir(path)
for file in dir:
@matthewfl
matthewfl / chat.index.html
Created November 24, 2010 06:22
A really basic chat server on http://chat.jsapp.us
<html>
<head>
<title>Chat</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script>
$(function () {
function check () {
$("#output").load('/update', function () {
setTimeout(check, 1);
});
@matthewfl
matthewfl / async.js
Created November 28, 2010 05:01
A async function that I wrote as everything else seemed too complex for what I needed
function async (fun, args) {
if(!fun.length) return;
args = args || [];
var call=fun.shift();
if(typeof call == "function") call = [ call ];
var count=call.length;
var n=0;
var ret=[];
while(call.length) {
call.shift().apply((function (num){
@matthewfl
matthewfl / mac load apps from Applications.sh
Created December 31, 2010 07:14
An attempt to load application from the Applications folder into the command line
for a in /Applications/*; do
base=`echo $a | sed 's/\/Applications\/\(.*\)\.app/\1/'`
if [ $base != $a ]; then
name=`echo ${base:l} | sed 's/[^a-z0-9_]/\-/g'`
alias $name="\"/Applications/$base.app/Contents/MacOS/$base\""
fi
done
@matthewfl
matthewfl / mac load apps from Applications.sh
Created December 31, 2010 07:14
An attempt to load application from the Applications folder into the command line
for a in /Applications/*; do
base=`echo $a | sed 's/\/Applications\/\(.*\)\.app/\1/'`
if [ $base != $a ]; then
name=`echo ${base:l} | sed 's/[^a-z0-9_]/\-/g'`
alias $name="open -a \"$base\" --args"
fi
done
@matthewfl
matthewfl / gist:1062801
Created July 4, 2011 01:44
npm safe attempt
npm.load({}, function (err) {
//npm.commands.build = console.log; // failed because no setter was set
//npm.commands['run-script'] = console.log;
//Object.defineProperty(npm.commands, "build", { get: function () { return console.log; }}); // could not redefine the property
//Object.defineProperty(npm.commands, "run-script", { value: console.log });
// seems to work, but crashes after some point in the process
var original_npm = npm.commands;
npm.commands = {}; // more hacks, to make npm safe
for(var c in original_npm) {
(function (c) {
@matthewfl
matthewfl / cmucam_test.pde
Created February 13, 2012 06:17
display the image for a cmucam that is directly connected
import processing.serial.*;
Serial cmucam;
void setup () {
cmucam = new Serial(this, "/dev/tty.usbserial-A400C1Q8", 115200);
size(200, 200);
delay(1500);
cmucam.write("RS\r");
delay(150);
@matthewfl
matthewfl / Makefile
Last active October 10, 2015 11:18
Simple makefile for generating all the pdfs based off latex files in a dir and sub dir
Latex = $(wildcard **/*.tex) $(wildcard *.tex)
Pdfs = $(Latex:.tex=.pdf)
all: $(Pdfs)
%.pdf: %.tex
rm -f $@
latex --output-format=pdf -output-directory=$(dir $@) $<
p: