Skip to content

Instantly share code, notes, and snippets.

require 'digest/md5'
def gfm(text)
# Extract pre blocks
extractions = {}
text.gsub!(%r{<pre>.*?</pre>}m) do |match|
md5 = Digest::MD5.hexdigest(match)
extractions[md5] = match
"{gfm-extraction-#{md5}}"
end
@jacobian
jacobian / unicorn.py
Created October 6, 2009 22:39
Simple preforking echo server in Python.
"""
Simple preforking echo server in Python.
Python port of http://tomayko.com/writings/unicorn-is-unix.
"""
import os
import sys
import socket
@jacobian
jacobian / unicorn-socketserver.py
Created October 7, 2009 13:45
A simple preforking echo server using SocketServer.
"""
Simple forking echo server built with Python's SocketServer library. A more
Pythonic version of http://gist.github.com/203520, which itself was inspired
by http://tomayko.com/writings/unicorn-is-unix.
"""
import os
import SocketServer
class EchoHandler(SocketServer.StreamRequestHandler):
"""
Simple preforking echo server in Python.
Python port of http://tomayko.com/writings/unicorn-is-unix.
"""
import os
import sys
import socket
@paulsmith
paulsmith / echo.c
Created October 7, 2009 18:40
Unix is C—a preforking echo server inspired by tomayko.com and jacobian.org’s recent “* is Unix” posts
/**
* A simple preforking echo server in C.
*
* Building:
*
* $ gcc -Wall -o echo echo.c
*
* Usage:
*
* $ ./echo
@jacobian
jacobian / unicorn.php
Created October 8, 2009 15:10
This was written by Russell Beattie; I copied it here from a pastebin to give it a permanent home.
<?
/*
Simple preforking echo server in PHP.
Russell Beattie (russellbeattie.com)
PHP port of http://tomayko.com/writings/unicorn-is-unix
*/
/* Allow the script to hang around waiting for connections. */
set_time_limit(0);
# Newbie programmer
$input=<>;
sub factorial {
$s=1;
$r=1;
while ($s <= $input) {
$r *= $s;
$s++;
}
if($input == 0)
@banthar
banthar / xkcd_hell.user.js
Created June 14, 2010 18:30
hell tetris
// ==UserScript==
// @name XKCD Hell playable game
// @namespace http://example.com/
// @description Turns XKCD comic #724 into playable game
// @include http://xkcd.com/724/
// @version 1.0
// ==/UserScript==
/*
* Physaxe (http://code.google.com/p/physaxe/) copyright notice:
@Nemo157
Nemo157 / Makefile
Created August 19, 2010 23:43
A simple Makefile for LaTeX projects.
# Author:
# Wim Looman
# Copyright:
# Copyright (c) 2010 Wim Looman
# License:
# GNU General Public License (see http://www.gnu.org/licenses/gpl-3.0.txt)
## User interface, just set the main filename and it will do everything for you
# If you have any extra code or images included list them in EXTRA_FILES
# This should work as long as you have all the .tex, .sty and .bib files in
/* The world's smallest Brainfuck interpreter in C, by Kang Seonghoon
* http://j.mearie.org/post/1181041789/brainfuck-interpreter-in-2-lines-of-c */
s[99],*r=s,*d,c;main(a,b){char*v=1[d=b];for(;c=*v++%93;)for(b=c&2,b=c%7?a&&(c&17
?c&1?(*r+=b-1):(r+=b-1):syscall(4-!b,b,r,1),0):v;b&&c|a**r;v=d)main(!c,&a);d=v;}