Skip to content

Instantly share code, notes, and snippets.

API

Firstly, without any HPI helper functions, the API currently looks like this:

    var map = new ol.Map(document.getElementById('map'));
    var layer = ol.Layer.createOpenStreetMap({opacity: 0.5});
    map.getLayers().push(layer);

Adding a few flexibly-typed helper functions and some combined

@tschaub
tschaub / gist:3091573
Created July 11, 2012 16:32
modify existing issue or pull request
# examples assume username is johndoe and johndoe has a branch named new-features
# these examples work with the openlayers organization and the ol3 repo, could be any other
# say you want to turn issue #5 into a pull request based on new-features branch
# same syntax if issue #5 is already a pull request
curl -d '{"issue": "5", "head": "johndoe:new-features", "base": "master"}' -u 'johndoe' https://api.github.com/repos/openlayers/ol3/pulls
@tschaub
tschaub / gist:2722957
Created May 18, 2012 03:17
Git autocomplete and branch in PS1
# Set git autocompletion and PS1 integration
if [ -f /usr/local/git/contrib/completion/git-completion.bash ]; then
. /usr/local/git/contrib/completion/git-completion.bash
fi
PS1="\h:\W\$(__git_ps1)$ "
@tschaub
tschaub / split.js
Created May 4, 2012 14:21
quick implementation of polygon splitting process
// Execute method for js:split process expects polygon and line geometries as input
run: function(inputs) {
var merger = new LineMerger();
merger.add(inputs.poly._geometry);
merger.add(inputs.line._geometry);
var collection = merger.getMergedLineStrings();
var union = new UnaryUnionOp(collection).union();
var polygonizer = new Polygonizer();
polygonizer.add(union);
@tschaub
tschaub / SlowPaste.workflow
Created August 30, 2011 05:43
Automator Workflow for Slowly Pasting in Terminal
on run {input, parameters}
set clip_text to (the clipboard as text)
set clip_paragraphs to paragraphs of clip_text
if (count of clip_paragraphs) > 0 then
set line_text to item 1 of clip_paragraphs
repeat with n from 1 to count of line_text
set next_char to character n of line_text
tell application "Terminal"
import java.util.Arrays;
import java.util.List;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.commonjs.module.Require;
import org.mozilla.javascript.tools.shell.Global;
@tschaub
tschaub / content.ftl
Created November 11, 2010 21:20
GeoJSON GetFeatureInfo Response Template
<#list features as feature>
{
"type": "Feature",
"geometry": null,
"properties": {
<#list feature.attributes as attribute>
<#if !attribute.isGeometry>
"${attribute.name}": "${attribute.value}"<#if attribute_has_next>,</#if>
</#if>
</#list>
@tschaub
tschaub / compile-test.js
Created November 6, 2010 18:50
failing compile test
var google = Packages.com.google;
var jscomp = google.javascript.jscomp;
var ImmutableList = google.common.collect.ImmutableList;
var compiler = new jscomp.Compiler();
// assemble compiler options
var options = new jscomp.CompilerOptions();
options.setCodingConvention(new jscomp.ClosureCodingConvention());
@tschaub
tschaub / gist:636779
Created October 20, 2010 16:41
simple proxy
var Client = require("ringo/httpclient").Client;
var Request = require("ringo/webapp/request").Request;
var MemoryStream = require("io").MemoryStream;
var merge = require("ringo/utils/objects").merge;
var responseForStatus = require("./util").responseForStatus;
var defer = require("ringo/promise").defer;
var app = exports.app = function(env) {
var response;
var request = new Request(env);
var stream = new Stream(new java.io.PipedInputStream());
var _out = new java.io.PipedOutputStream(stream);
var _runnable = new java.lang.Runnable({
run: function() {
javax.imageio.ImageIO.write(_image, options.imageType, _out);
}
});
var _thread = new java.lang.Thread(_runnable);
_thread.start();