Skip to content

Instantly share code, notes, and snippets.

View eknuth's full-sized avatar

Edwin Knuth eknuth

  • Overjet
  • Portland, Oregon
View GitHub Profile
@eknuth
eknuth / gist:9123743
Created February 20, 2014 21:37
installing elasticsearch with chef
# chef stuff to install elastic search
# based on https://www.digitalocean.com/community/articles/how-to-install-elasticsearch-on-an-ubuntu-vps
# install oracle java (with help from http://jamie.mccrindle.org/2013/07/installing-oracle-java-7-using-chef.html)
execute "add oracle java repo" do
command '/usr/bin/add-apt-repository -y ppa:webupd8team/java && /usr/bin/apt-get update'
not_if "test -x /etc/apt/sources.list.d/webupd8team-java-precise.list"
end
execute "accept-license" do
@eknuth
eknuth / app.js
Created July 29, 2012 22:26
Google FastButtons as knockout.js custom binding
ko.applyBindings({
fastClickResult: ko.observable("Waiting..."),
clickResult: ko.observable("Waiting..."),
handleClick: function(self, event) {
self.clickResult("Clicked!");
},
handleFastClick: function(self, event) {
self.fastClickResult("Fast Clicked!");
}
});
@eknuth
eknuth / map.js
Created July 25, 2012 19:15
Using ESRI's Ocean Basemap with OpenLayers
var map = new OpenLayers.Map('map_container', {
allOverlays: true,
displayProjection: new OpenLayers.Projection("EPSG:4326")}),
esriOcean = new OpenLayers.Layer.XYZ("ESRI Ocean Basemap",
"http://services.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer/tile/${z}/${y}/${x}",
{
sphericalMercator: true,
isBaseLayer: true,
numZoomLevels: 13
@eknuth
eknuth / geolocation.js
Created January 15, 2012 23:36
method refresh the routes
var geo = new Ext.util.GeoLocation({
autoUpdate: false,
listeners: {
locationupdate: function(geo) {
refreshRoutes(geo.latitude, geo.longitude);
},
locationerror: function(geo, bTimeout, bPermissionDenied, bLocationUnavailable, message) {
if (bTimeout) {
alert('Timeout occurred.');
} else {
@eknuth
eknuth / test_trimet.js
Created January 15, 2012 20:48
integration test for trimet module
var trimet = require('../lib/trimet.js'),
should = require('should');
describe('trimet: get nearest routes from coordinate', function() {
describe('getRoutesByPoint', function() {
it('should return some points', function(done) {
var lat = 45.499541,
lon = -122.613639,
expectedRoutes = [{
route: 9,
@eknuth
eknuth / improved.sql
Created January 14, 2012 17:19
seatmate spatial query, route line closest to point
SELECT "RTE" as route, "RTE_DESC" as description,
min(distance(PointFromText('POINT(-122.613639 45.499541)', 4326), the_geom)) as distance
from tm_routes group by route, description
order by distance limit 10;
@eknuth
eknuth / setup.sh
Created December 17, 2011 20:00
set up the environment
# install node
brew install node
# install redis
brew install redis
# install npm
curl http://npmjs.org/install.sh | sh
# install mocha and should for testing
@eknuth
eknuth / setup.sh
Created December 17, 2011 17:31
setting up the environment
# install node
brew install node
# install redis
brew install redis
# install npm
curl http://npmjs.org/install.sh | sh
# install mocha and should for testing
from annoying.decorators import render_to
@render_to('hero.html')
def home(request):
return {}
@eknuth
eknuth / settings.py
Created October 15, 2011 19:04
add this to your settings file
import os
SITE_ROOT = os.path.dirname(os.path.realpath(__file__))
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.join(SITE_ROOT, 'templates')