Skip to content

Instantly share code, notes, and snippets.

View gilesc's full-sized avatar

Cory Giles gilesc

  • Oklahoma Medical Research Foundation
  • Oklahoma City, OK
  • X @cbgiles
View GitHub Profile
@gilesc
gilesc / regex_example.py
Created June 22, 2011 14:39
python regex example
import re
print [g.start() for g in re.finditer("AT", "CAAATATGAGACATAGACATAGACAGATACG")]
#to match any base (really, any character), use a dot:
print [g.start() for g in re.finditer("G.G", "CAAATATGAGACATAGACATAGACAGAGACG")]
#to match a subgroup:
print [g.start() for g in re.finditer("[AT][AT]", "CAAATATGAGACATAGACATAGACAGAGACG")]
@gilesc
gilesc / twss.clj
Created April 28, 2011 01:26
twss
(require '[net.cgrand.enlive-html :as html])
(defn fetch-url [url]
(html/html-resource
(java.net.URL. url)))
(defn fetch-twss [n]
(drop-last 2
(map #(second (re-find #"\"(.+?)\"" (html/text %)))
(html/select
from numpy import argmax
from scipy import arange
from scipy.io import wavfile
from scipy.fftpack import fftfreq, rfft, fftshift
import pylab
sample_rate, signal = wavfile.read("goodnight.wav")
N = len(signal)
(defn levenshtein [vec1 vec2]
(cond (empty? vec1) (count vec2)
(empty? vec2) (count vec1)
:else
(let [distance (make-array Integer (count vec1) (count vec2))]
(doseq [i (range (count vec1))]
(aset distance i 0 i))
(doseq [j (range (count vec2))]
(aset distance 0 j j))
(doseq [i (range 1 (count vec1))]