Skip to content

Instantly share code, notes, and snippets.

from random import getrandbits
#Quick UUID: rand(128)
def rand(bits):
return hex(getrandbits(bits))[2:-1]
#This isn't stored efficiently, as each hex digit represents 4 bits, but takes up 8 or 16 bits (depending on if we are using ASCII or Unicode)
@Meyermagic
Meyermagic / rle2samples.c
Created August 1, 2011 20:54
Expand run-length-encoded data and translate from ASCII 0 and 1 to 0x0 and 0x1.
//expand | map
//By Meyer S. Jacobs
#include <stdio.h>
#include <errno.h>
#include <stdint.h>
#include <stdlib.h>
#include <fcntl.h>
static unsigned char table[256] = {
@Meyermagic
Meyermagic / ffstderr.txt
Created August 31, 2011 01:34
Ouput of "firefox -console 2>ffstderr.txt" on Ubuntu 11.04 64-bit
OpenGL Warning: XGetVisualInfo returned 0 visuals for 0x7ff1a1c4bf60
OpenGL Warning: Retry with 0x8002 returned 0 visuals
Loading: /home/ifx/.mozilla/firefox/q7clgb0g.default/extensions/convergence@extension.thoughtcrime.org/chrome/content/ctypes/NSPR.js
Loaded!
Loading: /home/ifx/.mozilla/firefox/q7clgb0g.default/extensions/convergence@extension.thoughtcrime.org/chrome/content/ctypes/NSS.js
Loaded!
Loading: /home/ifx/.mozilla/firefox/q7clgb0g.default/extensions/convergence@extension.thoughtcrime.org/chrome/content/ctypes/SSL.js
Loaded!
Loading: /home/ifx/.mozilla/firefox/q7clgb0g.default/extensions/convergence@extension.thoughtcrime.org/chrome/content/ctypes/SQLITE.js
Loaded!
/*
* iprompt.cpp
*
* Created on: May 6, 2011
* Author: ifx
*/
#include "iprompt.h"
#include <map>
#include <string>
@Meyermagic
Meyermagic / gist:3206005
Created July 30, 2012 10:13
Moving window iteration
from itertools import izip, tee, izip_longest, islice, chain
def setwise(iterable, size=2):
return izip(*[islice(it, i, None) for i, it in enumerate(tee(iterable, size))])
def setwise_pad(iterable, padding=None, size=2):
return izip_longest(*[islice(chain(it, [padding]*i), i, None) for i, it in enumerate(tee(iterable, size))], fillvalue=padding)
@Meyermagic
Meyermagic / game_pred.py
Created July 30, 2012 11:01
Text Prediction
from __future__ import with_statement, division
from itertools import izip, tee, izip_longest, islice, chain
from collections import defaultdict
def setwise(iterable, size=2):
return izip(*[islice(it, i, None) for i, it in enumerate(tee(iterable, size))])
def setwise_pad(iterable, padding=None, size=2):
return izip_longest(*[islice(chain(it, [padding]*i), i, None) for i, it in enumerate(tee(iterable, size))], fillvalue=padding)
from __future__ import with_statement, division
from itertools import izip, tee, islice, chain
from weighted_choice import WeightedChoice
from collections import defaultdict
def setwise(iterable, size=2):
return izip(*[islice(it, i, None) for i, it in enumerate(tee(iterable, size))])
def setwise_pad(iterable, padding=None, size=2):
package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"net/http"
)
-fcase-merge
Enable case-merging. Implied by -O.
-fcse
Turn on common sub-expression elimination. Implied by -O.
-fdo-eta-reduction
Enable eta-reduction. Implied by -O
-fcase-merge
Enable case-merging. Implied by -O.
-fcse
Turn on common sub-expression elimination. Implied by -O.
-fdo-eta-reduction
Enable eta-reduction. Implied by -O
-fenable-rewrite-rules