Skip to content

Instantly share code, notes, and snippets.

@tschaub
tschaub / master.js
Created November 26, 2013 15:50
Highlight a feature on the map based on user interaction with a feature table. The two examples below provide a "highlight" function. In both cases, the application would be responsible for getting a feature based on user interaction with a feature table. The highlight function just shows the code necessary to highlight the feature on the map.
/**
* Layer with a style that provides symbolizers for
* the "selected" render intent defined elsewhere.
*/
function highlight(feature) {
feature.setRenderIntent('selected');
}
@tschaub
tschaub / serve.js
Last active December 22, 2015 21:29
Using closure-util package instead of Plovr for ol3
var path = require('path');
var url = require('url');
var log = require('npmlog');
var closure = require('closure-util');
log.info('serve', 'Parsing dependencies ...');
var root = '.'; // assumes you're running this from ol3 repo
@tschaub
tschaub / sbt
Created August 27, 2013 03:14
OSX sbt launcher. Download sbt-launch.jar, put this script next to it, and create a symbolic link to this script on your path.
CWD=`pwd`
SELF=$0
cd `dirname $SELF`
SELF=`basename $SELF`
# Iterate down a (possible) chain of symlinks
while [ -L "$SELF" ]
do
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tschaub
tschaub / synthetic-data.js
Created May 21, 2013 05:20
Rendering synthetic data with the canvas renderer.
goog.require('ol.Feature');
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
goog.require('ol.geom.Point');
goog.require('ol.layer.TileLayer');
goog.require('ol.layer.Vector');
goog.require('ol.parser.GeoJSON');
goog.require('ol.projection');
goog.require('ol.source.MapQuestOpenAerial');
@tschaub
tschaub / mongo-mr.js
Created January 16, 2013 04:40
Mongo map-reduce experiments
function mapFunc() {
var i, ii, key, doc, service;
for (i = 0, ii = this.resources.length; i < ii; ++i) {
key = this.resources[i];
doc = {
services: {}
};
service = this.service || '';
doc.services[service] = 1;
emit(key, doc);
@tschaub
tschaub / time-series.sql
Created December 4, 2012 06:23
Time series generator in psql
/**
Time series generator. This generates a series of times (as seconds since
the epoch) between any two start and end time values (also seconds since
the epoch). The $1 value can be 'second', 'minute', 'hour', 'day', 'week', or
'month'. The $2 and $3 values are start and end time respectively (in seconds
since the epoch.
*/
select date_part('epoch', date_trunc($1, to_timestamp($2)) + concat(tmp.index, $1)::interval) as time from generate_series(
0,
case
@tschaub
tschaub / fly.js
Created November 8, 2012 16:35
example using animation-frame branch
var layer = new ol.layer.TileLayer({
source: new ol.source.MapQuestOpenAerial()
});
var map = new ol.Map({
center: new ol.Coordinate(0, 0),
layers: new ol.Collection([layer]),
renderer: ol.RendererHint.DOM,
target: 'map',
zoom: 2
@tschaub
tschaub / make-pull.sh
Created October 24, 2012 17:23
Use httpie to turn a GitHub issue into a pull request
http -a <your-username> POST https://api.github.com/repos/<remote-user>/<repo-name>/pulls issue=<issue-number> head=<your-username>:<your-branch> base=master
@tschaub
tschaub / Range.java
Created August 8, 2012 02:05
Example of a JavaScript iterator created with Rhino.
/**
* Demonstrates how a JavaScript iterator can be created with Rhino. This
* simple Range class can be defined as a JavaScript constructor.
*
* Example use:
*
* >> // set up Range constructor and prototype
* >> defineClass(Packages.com.example.Range)
*
* >> var range = new Range(3, 5)