Skip to content

Instantly share code, notes, and snippets.

@jlivni
jlivni / gist:2925302
Created June 13, 2012 17:08
binary data for webgl
#appengine python
values = [1,2,3,4]
values = array('f',values)
response.out.write(values.tostring())
//JS loading
var xhr = new XMLHttpRequest();
xhr.open('GET', '/path/to/file', true);
xhr.responseType = 'arraybuffer';
#!/usr/bin/env python
import gdal
import gdalnumeric
import sys
import numpy
# =============================================================================
def Usage():
print('Usage: elev2rgb.py elevation_file blue_file output_file')
@jlivni
jlivni / index.html
Last active December 11, 2015 17:48
topojson on gmaps
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
html, body, #map_canvas { height: 100%; margin: 0;}
</style>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="https://raw.github.com/mbostock/topojson/master/topojson.js"></script>
<script src="https://raw.github.com/JasonSanford/GeoJSON-to-Google-Maps/master/GeoJSON.js"></script>
@jlivni
jlivni / map.geojson
Created August 15, 2013 00:08
via:geojson.io
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jlivni
jlivni / map.geojson
Created August 15, 2013 03:17
via:geojson.io
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
function highlightCorrelations(currentMarker){
// first make all the airports small
$.each(airports, function(id, marker) {
marker.setIcon(getIcon(2, 'black'));
});
// for each airport correlated to the selected airport, set it's icon to red
$.each(currentMarker.correlations, function(i, correlation) {
var marker = airports[correlation[0]];
marker.setIcon(getIcon(correlation[1], 'red')); //getIcon returns a circle symbol
});
@jlivni
jlivni / natural earth vs freebase
Last active December 24, 2015 15:39
Natural Earth vs Freebase - non matching country names (python dict at bottom). Freebase from non dissolved countries in type /location/country that had population >0
Freebase
------------------
Abkhazia
Bonaire
Buganda
Burma
Christmas Island
Cocos (Keeling) Islands
Collectivity of Saint Martin
East Timor
// gmaps js api v2 polygon overlays -> geojson
overlayToGeoJSON = function(o){
var feature={type:'Feature', geometry:{ type:'Polygon', coordinates:[[]]}};
for (var i=0; i < o.latlngs.length; i++){
feature.geometry.coordinates[0].push([o.latlngs[i].lng + o.reflng, o.latlngs[i].lat + o.reflat])
}
feature.properties = {hint:o.hint, html: o.infohtml}
return feature;
}
var results={type: "FeatureCollection", features: []};
def CreateLayer(http, project_id, table_id, title, description, tags):
"""Create a styled polygon Layer from a Table; display a status when complete.
Args:
http: http, authenticated http object.
project_id: string, id of the GME project.
table_id: string, the id of the source table.
title: string, the title of the layer.
description: string, the description of the layer.
tags: list, list,of,tags.
@jlivni
jlivni / index.html
Last active August 29, 2015 14:27 — forked from javisantana/index.html
<!DOCTYPE html>
<html>
<head>
<title>Leaflet multilayer example | CartoDB.js</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link rel="shortcut icon" href="http://cartodb.com/assets/favicon.ico" />
<style>
html, body, #map {
height: 100%;