Skip to content

Instantly share code, notes, and snippets.

View brentp's full-sized avatar

Brent Pedersen brentp

View GitHub Profile
import numpy as np
import sys
# abuse saved to store read lines.
def get_cw_pair(fh, saved=[]):
c = fh.readline().rstrip() if len(saved) == 0 else saved.pop()
if not c: return c, c
c = c.split(' ')
if c[1] != 'C':
w = c[:]
#!/usr/bin/python
import sys
sys.stdout = sys.stderr
from cgi import parse_qsl
import os
os.environ[ 'HOME' ] = '/tmp/'
import matplotlib
matplotlib.interactive(0)
matplotlib.rcParams['path.simplify'] = True
@brentp
brentp / conkyrc
Created June 15, 2009 18:48
conkyrc
# THIS CONFIG RELIES ON 2 SCRIPTS, CPUSPEED AND CPUTEMP
# YOUR SYSTEM MAY NOT REQUIRE THEM, REPLACE AS DESIRED
# maintain spacing between certain elements
use_spacer yes
# set to yes if you want conky to be forked in the background
background yes
use_xft yes
# mostly from:http://haxe.org/doc/build/haxe_ubuntu_build
sudo apt-get install ocaml camlp5 cvs zlib1g-dev
wget http://haxe.org/file/install.ml
sudo ocaml install.ml
# clean old install
sudo rm -rf /usr/local/haxe
sudo rm -rf /usr/local/bin/haxe*
# install haxe in /usr/local
sudo mkdir /usr/local/haxe
// build with: haxe swf9 fex.swf -main FlashExample
import flash.display.Sprite;
import flash.events.MouseEvent;
class FlashExample extends Sprite {
static function main(){
flash.Lib.current.addChild(new FlashExample());
}
class Image extends Sprite {
public var path:String;
public var bitmap:Bitmap;
public var onLoaded:Bitmap->Void;
private var _loader:Loader;
/* take a path and a callback to be called when the image is loaded:
var i = new Image('/some/image.png', function(b:Bitmap){
// do something with b or b.bitmapData...
trace('image is loaded');
#!/bin/sh
BREAK_CHARS="(){}[],^%$#@\"\";:''|\\"
CLOJURE_DIR=/usr/local/src/clojure/
CLOJURE_JAR=$CLOJURE_DIR/clojure.jar
CLOJURE_CONTRIB_JAR=$CLOJURE_DIR/clojure-contrib/clojure-contrib.jar
CP=$PWD:$CLOJURE_JAR:$CLOJURE_CONTRIB_JAR
# directory to vimclojure checkout
cimport stdlib
ctypedef struct foo:
int a
float b
cdef foo* make_foo(int a, float b):
cdef foo* f = <foo *>stdlib.malloc(sizeof(foo))
f.a = a
f.b = b
from sys import stdin
from collections import defaultdict
def gen_freq(seq, frame, frequences):
ns = len(seq) + 1 - frame
frequences.clear()
for ii in xrange(ns):
nucleo = seq[ii:ii + frame]
frequences[nucleo] += 1
return ns, frequences
import array
cimport array
cdef extern from 'vec.h':
ctypedef struct vec_int "std::vector<int>":
void (* push_back)(int i)
int (* at)(int i)
vec_int new_vec_int "std::vector<int>"()
vec_int new_vec_int_length "std::vector<int>"(unsigned int length)