Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View fogus's full-sized avatar
💭
attempting to learn how to better learn

Fogus fogus

💭
attempting to learn how to better learn
View GitHub Profile
@fogus
fogus / twicl
Created November 9, 2008 23:24 — forked from leahneukirchen/twicl
#!/usr/bin/env ruby
# -*- ruby -*-
# twitter command line client
# That's What I Call Lame
# 09nov2008 +chris+
require 'json'
require 'open-uri'
/* merge sort in js */
function sort(a) {
var mid = a.length>>1;
if (mid==0) return a;
var less = sort(a.slice(0,mid));
var more = sort(a.slice(mid));
var merged = [];
do {
if (more[0] < less[0]) { var t=less; less=more; more=t; }
merged.push(less.shift());
@fogus
fogus / gist:42087
Created December 31, 2008 19:05
prolog in python
"""
This modules implements a rudimentary prolog engine. Its
purpose is to illustrate the use of continuations to program
a search engine with backtracking and cut.
"""
def bind(var,term,alist):
"""bind var to term in environment alist. return the updated
environment. we make a copy so that we don't have to undo on
backtracking (in essence: we always trail)."""
@fogus
fogus / zombies.lisp
Created December 31, 2008 19:08
zombies cl
(comment
Features:
- One monster type: Zombies!
- Teleporters
- Artificial Unintelligence technology for realistic zombie horde
behavior
- Full in-game documentation
- Trees
- Gold (because really, what's a roguelike without gold?)
- Each game is guaranteed to end in death by zombie
'''Digital image steganography based on the Python Imaging Library (PIL)
from http://wordaligned.org/articles/steganography
Any message can be hidden, provided the image is large enough. The message is
packed into the least significant bits of the pixel colour bands. A 4 byte
header (packed in the same way) carries the message payload length.
'''
import Image
import itertools as its
def n_at_a_time(items, n, fillvalue):
#!/bin/sh
# to post `cat file | gist.sh`
# or `gist.sh < file`
# to get `gist.sh 1234`
log ()
{
echo "$@" >&2
}
// Totally stolen from http://logand.com/sw/jmultimethod/
// Multi.java
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Multi {
public String value();
}
// Example for http://gist.github.com/51089
public class CarTest {
interface CarElement {}
class Wheel implements CarElement {
private String name;
Wheel(String name) {
this.name = name;
// Example for http://gist.github.com/51089
public class AsteroidTest {
class Asteroid {}
class Spaceship {}
@Multi("collide")
public void collideOO(Object X, Object Y) {
;; a bit faster flatten
(defn flatten [x]
(if (seq? x)
(lazy-seq (apply #(lazy-cat %&) (map flatten x)))
(list x)))