Skip to content

Instantly share code, notes, and snippets.

@myazdani
myazdani / index.html
Created April 1, 2014 17:23
Scatterplot
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<script src='http://ramnathv.github.io/rCharts/libraries/widgets/polycharts/js/polychart2.standalone.js' type='text/javascript'></script>
<style>
.rChart {
display: block;
@myazdani
myazdani / index.html
Created April 1, 2014 17:23
Scatterplot
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<script src='http://ramnathv.github.io/rCharts/libraries/widgets/polycharts/js/polychart2.standalone.js' type='text/javascript'></script>
<style>
.rChart {
display: block;
It is a rite of passage to post one's successful build instructions for OpenCV on a Mac
after you've tried all the other conflicting instructions out there and still failed.
brew failed for me (was this because I could never get a happy brew doctor situation?
I'll never know). macports? nope. build-from-source recipes? I didn't find one that
worked for me.
Here's what did work to build OpenCV 2.4.8 from the distribution tarball using cmake,
on Mac OSX 10.9.2, linked to an anaconda installation rather than the system python.
It is a mashup of various bits of advice out there. If you're already comfortable with
build/install from source, all you need to read is the cmake invocation in step 3 and
@myazdani
myazdani / merge_left.R
Last active August 29, 2015 13:58
used to merge a meta data CSV (generated from SQL) with QTIP measurements CSV.
options = commandArgs(trailingOnly = TRUE)
file1 = options[1] #QTIP file
file2 = options[2] #SQL query file
field_name = options[3] #not used - replace with what column name to use
outpath = options[4] #name of output file
file1.df = read.csv(file1, header = TRUE, stringsAsFactors = FALSE)
file2.df = read.csv(file2, header = TRUE, stringsAsFactors = FALSE)
get.filename = function(x) {
@myazdani
myazdani / addHSVtoQTIP.R
Created April 10, 2014 19:01
Adds an HSV proxy to QTIP CSV
#addHSVtoQTIP.R
#
#adds HSV (as defined on wikipedia) to mean RGB as computed by QTIP
#Mehrdad Yazdani, Feb 2014
in_file = "~/Desktop/kiev_merged.csv"
out_file = "~/Desktop/kiev_HSV_added.csv"
qtip.features = read.csv(in_file, header = TRUE, stringsAsFactors = FALSE)
@myazdani
myazdani / myFileCopier.py
Created April 11, 2014 00:56
file copying short cuts
import os
import shutil
def copyFromListToPath(src_paths, dest_path):
for i in range(len(src_paths)): shutil.copy2(src_paths[i], dest_path)
def getFilesWithPath(path, filetype = ""):
return [os.path.join(path,f) for f in os.listdir(path) if f.endswith(filetype)]
@myazdani
myazdani / get filename from URL or dir
Last active August 29, 2015 14:01
get the filename after the last "/"
get.filename = function(x) {
splitted = strsplit(x, split = "/")[[1]]
return(splitted[length(splitted)])
}
@myazdani
myazdani / readCSV
Created May 9, 2014 14:48
my function for reading CSV files
import csv
def return_rows(filename, file_encoding = 'rU'):
with open(filename, file_encoding) as f:
reader = csv.reader(f)
rowsInData = [row for row in reader]
return rowsInData
@myazdani
myazdani / derivativeMatrix.py
Created May 18, 2014 05:50
returns the difference matrix
import numpy
from scipy.linalg import toeplitz
def pascal_row(n):
row = [1]
for col in range(1, n): row.append(row[-1] * (n - col) / col)
return numpy.array(row)
@myazdani
myazdani / readFiles.py
Last active August 29, 2015 14:01
Read jpg files from path and return list of paths
import os
image_src_path = "src_path"
image_paths = [os.path.join(image_src_path,f) for f in os.listdir(image_src_path) if f.endswith('.jpg')]