Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
attempting to learn how to better learn

Fogus fogus

💭
attempting to learn how to better learn
View GitHub Profile
View twicl
#!/usr/bin/env ruby
# -*- ruby -*-
# twitter command line client
# That's What I Call Lame
# 09nov2008 +chris+
require 'json'
require 'open-uri'
View gist:24606
/* 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 Dec 31, 2008
prolog in python
View gist:42087
"""
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)."""
View zombies.lisp
(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
View steganography.py
'''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):
View gist.sh
#!/bin/sh
# to post `cat file | gist.sh`
# or `gist.sh < file`
# to get `gist.sh 1234`
log ()
{
echo "$@" >&2
}
View Multimethods.java
// Totally stolen from http://logand.com/sw/jmultimethod/
// Multi.java
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Multi {
public String value();
}
View gist:51091
// 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;
View gist:51092
// Example for http://gist.github.com/51089
public class AsteroidTest {
class Asteroid {}
class Spaceship {}
@Multi("collide")
public void collideOO(Object X, Object Y) {
View flatten.clj
;; a bit faster flatten
(defn flatten [x]
(if (seq? x)
(lazy-seq (apply #(lazy-cat %&) (map flatten x)))
(list x)))
You can’t perform that action at this time.