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
""" | |
Elias Omega code in Python | |
http://en.wikipedia.org/wiki/Elias_omega_coding | |
Peter Elias, "Universal codeword sets and representations of the integers", IEEE Trans. Information Theory 21(2):194-203, Mar 1975. | |
Also known as the log* (or "logstar") code in Rohan Baxter's 1996 PhD thesis. | |
Type 'python EliasOmega.py' to run the tests. | |
""" |
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
import Data.Word | |
import qualified Data.ByteString as B | |
type ByteString = B.ByteString | |
data Tree = Leaf [Word8] | Branch Tree Tree deriving (Eq,Show) | |
parse :: ByteString -> Tree | |
parse xs = case view xs of | |
Cons 0 xs -> case view xs of | |
Cons length xs -> Leaf . B.unpack $ B.take (fromIntegral . toInteger $ length) xs |
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
/** @jsx React.DOM */ | |
var MyComponent = React.createClass({ | |
getInitialState: function() { | |
// set up the initial state. used for "logical" initialization code | |
return {perMinute: '-', perDay: '-'}; | |
}, | |
componentDidMount: function() { | |
// fired only once, when the component is added to the DOM | |
// used for initialization code that has "side effects" i.e. i/o, jquery plugins, etc | |
var socket = io.connect(this.props.url); |
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
/** @jsx React.DOM */ | |
var MyRootComponent = React.createClass({ | |
getInitialState: function() { | |
return {perMinute: '-', perDay: '-'}; | |
}, | |
componentDidMount: function() { | |
var socket = io.connect(this.props.url); | |
socket.on('business.clickout', this.setState.bind(this)); | |
}, | |
render: function() { |
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
/* | |
* call-seq: | |
* Rugged::Repository.new(name, options = {}) -> repository | |
* | |
* Open a Git repository with the given +name+ and return a +Repository+ object | |
* representing it. | |
* | |
*/ | |
static VALUE rb_git_repo_new(int argc, VALUE *argv, VALUE klass) | |
{ |
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
// A streaming byte oriented JSON parser. Feed it a single byte at a time and | |
// it will emit complete objects as it comes across them. Whitespace within and | |
// between objects is ignored. This means it can parse newline delimited JSON. | |
function jsonMachine(emit, next) { | |
next = next || $value; | |
return $value; | |
function $value(byte) { | |
if (!byte) return; | |
if (byte === 0x09 || byte === 0x0a || byte === 0x0d || byte === 0x20) { |
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
\Umathcharnumdef\aleph="2135 \Umathcharnumdef\hbar="210F | |
\Umathcharnumdef\imath="1D6A4 \Umathcharnumdef\jmath="1D6A5 | |
\Umathcharnumdef\ell="2113 \Umathcharnumdef\wp="2118 \Umathcharnumdef\Re="211C | |
\Umathcharnumdef\Im="2111 \Umathcharnumdef\infty="221E | |
\Umathcharnumdef\prime="2032 \Umathcharnumdef\emptyset="2205 | |
\Umathcharnumdef\surd="221A \Umathcharnumdef\top="22A4 | |
\Umathcharnumdef\bot="22A5 \Umathcharnumdef\|="2016 | |
\Umathcharnumdef\angle="2220 \Umathcharnumdef\triangle="2206 | |
\Umathcharnumdef\backslash="005C \Umathcharnumdef\forall="2200 | |
\Umathcharnumdef\exists="2203 \Umathcharnumdef\neg="00AC |
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
import System.Directory | |
import System.Environment | |
import System.FilePath | |
import Control.Applicative ((<$>)) | |
import Control.Arrow (first, second) | |
import Control.Monad (void) | |
import Data.Either (rights) | |
import Data.List (isSuffixOf) | |
import Data.Set (Set, (\\), empty, fromList, insert, singleton, toList, union) | |
import Text.Parsec |
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/bash | |
# Automatically configure a VM download Coursera courses. | |
# This script works as a user data file for use with a cloud VM. | |
# This script will resume downloading if the VM is restarted. | |
# This script works with Debian jessie (or possibly Ubuntu with systemd). | |
# You must enroll in each course and accept the Honor of Code of each course | |
# before you can download them. |
OlderNewer