Skip to content

Instantly share code, notes, and snippets.

@daniel-perry
daniel-perry / data.npy
Last active July 6, 2017 22:10
mlp l-bfgs maxiter bug
This file has been truncated, but you can view the full file.
#usage: lsprocs [username]
lsprocs(){
uid=`id -u`
if [ -z ${1+x} ];
then
uid=`id -u`
else
uid=`id -u $1`
echo "uid for $1 is $uid"
fi
@daniel-perry
daniel-perry / overfeat_sample.jl
Created October 12, 2015 18:09
sample.py from overfeat library translated into julia
using PyPlot
using PyCall
@pyimport overfeat
@pyimport scipy.ndimage as pyndimage
@pyimport scipy.misc as pymisc
# read image
image = pyndimage.imread("../../samples/bee.jpg")
# resize and crop into a 231x231 image
@daniel-perry
daniel-perry / curve_fitting.jl
Last active October 1, 2015 21:14
curve_fitting.c example from Ceres translated from c to julia
# Conversion of Ceres solver curve fitting example to julia - see http://ceres-solver.org/.
# Copyright (c) Daniel Perry 2015
# MIT License
function init()
ccall((:ceres_init,"libceres"), Void, ())
end
init()
@daniel-perry
daniel-perry / psb2raw.jl
Created April 11, 2015 19:56
rough go at converting .psb (photoshop) image to raw data (block of ints). Assumes .psb is not compressed and uses RGB (easy to change to grayscale).
# converts a .psb (photoshop photo type) to a raw image format.
#
# Raw format:
# height Uint32
# width Uint32
# depth Uint32 (8,16,32)
# data block Uint8, Uint16, Uint32 (depending on depth value = 8, 16, 32)
# using file description Oct 2013 version here:
@daniel-perry
daniel-perry / kd tree
Last active August 29, 2015 14:18
untested kd tree code
#ifndef COMMON_KDTREE_H
#define COMMON_KDTREE_H
/*
* Copyright (c) 2015 Daniel Perry
*
*/
#include <vector>
using std::vector;
# 30D gaussian data set with the following properties:
# anisotropic (covariance not scaled identity)
# non-axis aligned (rotated)
# non-centered (translated)
n = 300
d = 30
Sigma = eye(d)
Sigma[1,1] = 20
#! /usr/bin/env python
"""BIL parser to load elevation info from sites like
http://earthexplorer.usgs.gov/
Mostly based of:
http://stevendkay.wordpress.com/2010/05/29/parsing-usgs-bil-digital-elevation-models-in-python/
Documentation for the format itself:
http://webhelp.esri.com/arcgisdesktop/9.2/index.cfm?TopicName=BIL,_BIP,_and_BSQ_raster_files
@daniel-perry
daniel-perry / pom.xml
Created December 4, 2013 16:23
This mahout example: https://cwiki.apache.org/confluence/display/MAHOUT/Quick+tour+of+text+analysis+using+the+Mahout+command+line assumes you know how to use maven to run apache lucene on some text.. which I didn't. This gist is a pom.xml file that will allow you to run the indicated maven command on the reuters text dataset, cobbled together fr…
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>dataproj.maven</groupId>
<artifactId>running-lucene-with-maven</artifactId>
<packaging>war</packaging>
<version>0.1</version>
<profiles>
<!-- Add profile configuration here -->
</profiles>
# originally from:
# http://groups.google.com/group/ggplot2/attach/6bf632a9718dddd6/ggcorplot.R?part=2
# linked to from here:
# http://www.r-bloggers.com/five-ways-to-visualize-your-pairwise-comparisons/
# I've updated to remove warnings and errors.
library(ggplot2)
#define a helper function (borrowed from the "ez" package)
ezLev=function(x,new_order){