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
(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))]
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)
@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
@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 / Rakefile
Created July 25, 2011 15:59
Octopress deploy patch
--- a/Rakefile
+++ b/Rakefile
@@ -163,7 +163,7 @@ desc "deploy public directory to github pages"
task :push do
puts "## Deploying branch to Github Pages "
(Dir["#{deploy_dir}/*"]).each { |f| rm_rf(f) }
- system "cp -R #{public_dir}/ #{deploy_dir}"
+ system "cp -R #{public_dir}/* #{deploy_dir}"
puts "\n## copying #{public_dir} to #{deploy_dir}"
Religiosity negatively correlated with:
- IQ [1]
- Societal health (homicide, suicide, life expectancy) [2]
- hippocampus (part of the brain involved in memory) size [7]
and positively correlated with:
- abortion rates (!) [2]
- poverty [3]
- teen pregnancy [4]
@gilesc
gilesc / strtest.rs
Created May 27, 2013 02:06
Troubles with Rust
extern mod std;
fn main() {
let s = @"foo bar baz";
// similar results with ~"foo bar baz"
// These work
s.substr(1, 5);
s.slice(1,5);
@gilesc
gilesc / app1.d
Created July 26, 2013 15:20
Dub subpackage woes
module app1;
import std.stdio;
import lib1;
void main() {
add(2,3).println;
}
#!/usr/bin/env bash
cat <<EOF | ftp
open hgdownload.cse.ucsc.edu
anonymous
[email protected]
cd goldenPath/mm9/database
prompt
mget chr*rmsk.txt.gz
bye
@gilesc
gilesc / sklearn_memory_leak.py
Created November 28, 2016 20:53
Sklearn PCA potential memory leak
import os
import psutil
import numpy as np
import sklearn.decomposition
def memory_usage():
return psutil.Process(os.getpid()).memory_info().rss / 1024 ** 2
def pca(X):