Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am scw on github.
  • I am scw (https://keybase.io/scw) on keybase.
  • I have a public key whose fingerprint is DC95 4D84 4B97 617D 62FC 4498 F3E7 6E7C 03E8 FB6A

To claim this, I am signing this object:

@scw
scw / pipx.sh
Last active August 29, 2015 13:58
wrap calls to pip to force usage of the GCC environment over Clang
# I've added this to my ~/.bash_profile to use it, you could also create a stand-alone shell script.
# Usage: pipx install cython
function pipx() {
# Many Python packages don't install correctly with clang, as mentioned here:
# https://gist.github.com/goldsmith/7262122
# This wrapper forces gcc for pip installations:
export CFLAGS="-arch i386 -arch x86_64"
export FFLAGS="-m32 -m64"
@scw
scw / break-out-table.py
Created May 22, 2014 19:54
break out times into a large time table
def time_in_min(time_string):
# assumes 24h times
(hour, minutes) = [int(t) for t in time_string.split(":")]
return hour * 60 + minutes
def min_to_time(time_min):
minutes = time_min % 60
hours = (time_min - minutes) / 60
# return hour:minutes with leading zero
return "{0}:{1:02d}".format(hours,minutes)
@scw
scw / vessel-scoring-logic.py
Created May 23, 2014 03:20
Logic for vessel validation scores
def jaro_cost(inputs, weight=1):
min_score = 1.0
for a,b in list(itertools.combinations(inputs, 2)):
jaro_score = jellyfish.jaro_distance(a, b)
if jaro_score < min_score:
min_score = jaro_score
return (1 - min_score)*weight
def attr_score(attribute):
@scw
scw / example-spagedi-result.txt
Created June 16, 2014 20:22
An example SPAGeDi result file
SPAGeDi 1.4c (build 17-07-2013) - a program for Spatial Pattern Analysis of Genetic Diversity
Written by Olivier Hardy & Xavier Vekemans
Contributions by Reed Cartwright
Input file : "C:\Users\shau7031\AppData\Roaming\geneGIS\spagedi_data.txt"
Results file : "Z:\data\arcgis\addins\genegis\tests\data\tmxr.txt"
1318 individuals
2 categories: CA-OR, Cent_Am
Latitude-longitude coordinates (assumed to be in degrees; used to compute distances in km), Latitude, Longitude
@scw
scw / package-commands.md
Last active September 15, 2015 01:32
Comparison of package commands
brew install
brew uninstall

apt-get install
apt-get remove

pkg install
pkg delete
@scw
scw / gist:1829955
Created February 14, 2012 20:22
example shell loop
#!/usr/bin/env bash
for file in `find . -name "*.env"`; do
# we want the name without the '.env' bit
base=`basename $file .env`
echo $base
done
@scw
scw / sailwx-to-postgres.sh
Created April 8, 2012 08:39
Approximate steps for performing a MySQL to PostgreSQL conversion and PostGIS set up
# Configure Postgres
#
# create a postgres database for the records
createdb sailwx
# make the new database PostGIS compatible (here, against Postgres 8.4)
git clone https://github.com/straup/postgis-tools
cd postgis-tools
sh ./createdb-8.4.sh sailwx sailwx
@scw
scw / gist:2374373
Created April 13, 2012 06:27
Check raster dimensions match expectation
checkRaster <- function(raster) {
if (raster@nrows * raster@ncols == 220106) {
message <- paste("Raster size checks out for layer:", raster@layernames, sep="")
}
else {
message <- paste( "invalid raster dimensions; nrows:", raster@nrows, " ncols:", raster@ncols, sep="")
}
print(message)
}
@scw
scw / gist:3231008
Created August 1, 2012 21:42
compare BTM broad & fine scale code
# fine scale inner block
outFocalStatistics = FocalStatistics(Bathy, NbrAnnulus(FineInnerRadius, FineOuterRadius, "CELL"), "MEAN")
outRaster = Int(Plus(Minus(Bathy, outFocalStatistics), 0.5))
# broad scale inner block
outFocalStatistics = FocalStatistics(Bathy, NbrAnnulus(BroadInnerRadius, BroadOuterRadius, "CELL"), "MEAN")
outRaster = Int(Plus(Minus(Bathy, outFocalStatistics), 0.5))