Skip to content

Instantly share code, notes, and snippets.

View sritchie's full-sized avatar
🎯
Focusing

Sam Ritchie sritchie

🎯
Focusing
View GitHub Profile
<%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip"
%>
default: <%= std_opts %> features
wip: --tags @wip:3 --wip features
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
@sritchie
sritchie / rcov.rake
Created November 3, 2010 19:58
rake file for rcov
require 'cucumber/rake/task'
require 'rspec/core/rake_task'
namespace :rcov do
Cucumber::Rake::Task.new(:cucumber) do |t|
t.rcov = true
t.rcov_opts = %w{--rails --exclude spec\/,features\/ --aggregate coverage.data}
t.rcov_opts << %[-o "coverage"]
end
@sritchie
sritchie / AdManager.h
Created November 22, 2010 21:58
Ad Manager for iAd
//
// AdManager.h
//
// Created by Samuel Ritchie on 10/11/10.
// Copyright 2010 Threadlock Design. All rights reserved.
//
#import <iAd/iAd.h>
@interface AdManager : NSObject <ADBannerViewDelegate> {
cntryList = ['VNM', 'TWN', 'THA', 'PHL', 'MYS', 'MMR', 'LKA', 'LAO', 'KHM', 'IND', 'IDN', 'CHN', 'BGD']
# new version, using list comprehensions and default values
def messageList(useRange=False, testRange=range(71,126)):
rangedFunc = (lambda country: ['%s %s' % (country, i) for i in testRange])
identityFunc = (lambda country: country)
entryFunc = useRange and rangedFunc or identityFunc
return [entry for country in countryList for entry in entryFunc(country)]
# new version, with in-line lambdas
package world;
import org.gdal.gdal.Band;
//import org.gdal.gdal.ColorTable;
import org.gdal.gdal.Dataset;
import org.gdal.gdal.Driver;
import org.gdal.gdal.GCP;
import org.gdal.gdal.gdal;
import org.gdal.gdalconst.gdalconstConstants;
import org.gdal.osr.CoordinateTransformation;
def prep_hdf(f):
from osgeo import gdal
print "Loading %s" % os.path.split(f.local)[1]
hdf = gdal.Open(f.local)
sdsdict = hdf.GetMetadata('SUBDATASETS')
sdslist = [sdsdict[k] for k in sdsdict.keys() if '_NAME' in k]
f.sds = [gdal.Open(n) for n in sdslist]
return f
(def gdal-bytes
(byte-array (* 1200 1200)))
(.ReadRaster band 0 0 1200 1200 gdal-bytes)
(def *rho* 6371007.181)
(def pixels-at-res
{:250 4800
:500 2400
:1000 1200})
(defn degs-by-rho
"Multiplies the argument by rho and converts the answer to radians."
[arg]
(def
#^{:doc "Type object for a Java primitive float array."}
*float-array-type* (class (make-array Float/TYPE 0)))
(defmulti
#^{:doc "Converts argument into a Java float array. Argument may be
a File, or another byte array. If the argument is already
a float array, returns it."
:arglists '([arg])}
to-float-array type)
(defn all-months
"Returns a seq of the months inside of a rain array."
[^HeapByteBuffer buf]
(map #(take (* 360 720) (float-seqs %))
(for [i (range 12)] (extract-month i buf))))