Skip to content

Instantly share code, notes, and snippets.

View crstn's full-sized avatar
💭
🤓

Carsten Keßler crstn

💭
🤓
View GitHub Profile
@crstn
crstn / rats-dynamic.html
Last active March 15, 2021 10:31
Examples for GeoViz lecture, borrowed from http://maptimeboston.github.io/d3-maptime/
<html>
<head>
<title>A D3 chart</title>
<script src="http://d3js.org/d3.v6.min.js" charset="utf-8"></script>
</head>
<body>
<script>
var map, directionsrenderer1, directionsrenderer2, directionsRenderer3; // introduce the map variable first, otherwise it only shows up inside the initialize() function and is unknown outside of it.
// funcion that creates the map
function initialize() {
// this code here are the functions that make the directions api work
var directionsRenderer1 = new google.maps.DirectionsRenderer();
var directionsRenderer2 = new google.maps.DirectionsRenderer();
var directionsRenderer3 = new google.maps.DirectionsRenderer();
var directionsService = new google.maps.DirectionsService();
map = new google.maps.Map(document.getElementById("map"), {
function calculateAndDisplayRoute1(directionsService, directionsRenderer1) {
var mode = document.getElementById("mode").value;
var start = document.getElementById("ac1").value;
var end = document.getElementById("ac4").value;
directionsService.route({
origin: start,
destination: end,
travelMode: google.maps.TravelMode[mode]
},
var map; // introduce the map variable first, otherwise it only shows up inside the initialize() function and is unknown outside of it.
// funcion that creates the map
function initialize() {
// this code here are the functions that make the directions api work
var directionsRenderer = new google.maps.DirectionsRenderer();
var directionsService = new google.maps.DirectionsService();
map = new google.maps.Map(document.getElementById("map"), {
zoom: 1,
center: { lat: 122.15674, lng: 10.21076 }
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@crstn
crstn / RDF in Turtle to PDF Graph
Last active September 15, 2018 10:11
Create a graph visualization from an RDF file using http://librdf.org/raptor/ and http://www.graphviz.org.
rapper -i turtle -o dot model.ttl | dot -Tpdf -omodel.pdf
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@crstn
crstn / voronoi.r
Created January 17, 2018 09:05
This is a small fix of Carson Farmer's Voronoi Polygons function (http://carsonfarmer.com/2009/09/voronoi-polygons-with-r/) which also copies the input points layer's CRS string over to the output polygons.
voronoipolygons = function(layer) {
require(deldir)
crds = layer@coords
z = deldir(crds[,1], crds[,2])
w = tile.list(z)
polys = vector(mode='list', length=length(w))
require(sp)
for (i in seq(along=polys)) {
pcrds = cbind(w[[i]]$x, w[[i]]$y)
pcrds = rbind(pcrds, pcrds[1,])
@crstn
crstn / README.txt
Created October 2, 2012 14:51 — forked from flaviaza/README.txt
Twitter bootstrap fixed table header using jQuery
Here is a simple jQuery plugin to make a table header fixed on top of a div when this is scrolled.
Using the code from twitter bootstrap documentation page, this code is customized for table header.
Create the table with following layout -
<div class="row fixed-table">
<div class="table-content">
<table class="table table-striped table-fixed-header" id="mytable">
<thead class="header">
<tr>
<th>Email Address</th>
@crstn
crstn / definer.sql
Last active August 31, 2016 04:17
Editing data in a CartoDB table via Leaflet with leaflet.draw plugin. Heavily inspired by http://blog.cartodb.com/read-and-write-to-cartodb-with-the-leaflet-draw-plugin/.
DROP FUNCTION IF EXISTS carsten_upsert_pois(int[], text[]);
-- Returns a set of op,cartodb_id values where op means:
--
-- deleted: -1
-- updated: 0
-- inserted: 1
--
CREATE OR REPLACE FUNCTION carsten_upsert_pois(
cartodb_ids integer[],