Skip to content

Instantly share code, notes, and snippets.

View jelmervdl's full-sized avatar

Jelmer jelmervdl

View GitHub Profile
@jelmervdl
jelmervdl / seed-cache.html
Created April 15, 2017 14:05
Geoserver Tile Cache seeding tool
<!DOCTYPE html>
<html>
<head>
<title>Seed tool</title>
<style>
.seed-status {
display: inline-block;
padding; 2px;
background: #ccc;
}
@jelmervdl
jelmervdl / README.md
Last active March 22, 2017 16:42
ibood announcer

iBOOD Hunt Announcer

Na de bel hoor je voortaan wat de volgende hunt is!

Installeren

  1. Installeer eerst de Tampermonkey plugin in Chrome.
  2. Ga daarna naar deze pagina (hey!) en klink op het 'RAW' knopje bij het script hierboven.
  3. Als het goed is opent Tampermonkey nu en installeert hij het script
  4. Ga naar http://iboodhunt.1dagskoopjes.nl/ en laat de pagina open staan. Direct na de bel hoor je wat de nieuwe hunt is :)
@jelmervdl
jelmervdl / getlayeratpoint.js
Created March 12, 2017 23:00
Leaflet function to get a layer at a certain point. Supports polygons and multipolygons with holes.
function pointInRing(point, vs)
{
var x = point[0], y = point[1];
var inside = false;
for (var i = 0, j = vs.length - 1; i < vs.length; j = i++) {
var xi = vs[i][0], yi = vs[i][1];
var xj = vs[j][0], yj = vs[j][1];
var intersect = ((yi > y) != (yj > y))
@jelmervdl
jelmervdl / import.sh
Created February 21, 2017 10:02
Import BAG into local postgres/postgis database
#!/bin/sh
brew install postgresql postgis
# Download the latest results from NLExtract (monthly updates)
wget "http://data.nlextract.nl/bag/postgis/bag-laatst.backup"
# Create a database and initialize postgis extension
createdb --encoding=UTF8 --template=template0 bag
echo "CREATE EXTENSION postgis;" | psql bag
@jelmervdl
jelmervdl / index.html
Created December 1, 2016 11:03
Pure Python & Flask server-side event source
<script>
var stream = new EventSource('/api/stream');
stream.onmessage = function(e) {
console.info(e.data);
};
</script>
@jelmervdl
jelmervdl / Agent.java
Last active September 28, 2016 10:35
Agent-based simulation example in Java
class Agent
{
// Like a struct, every agent object has a credits and a reference to the simulation
private String name; // Name of the agent
private int credits; // Number of credits the agent has
private Simulation sim; // Simulation the agent lives in
@jelmervdl
jelmervdl / request_as_curl_command.py
Last active February 21, 2017 10:05
Turns a requests' request object into something you can paste in your terminal.
def request_as_curl_command(request):
'''
Turns a requests' request object into something you can pase in your terminal.
Usage:
response = requests.request(...)
print(request_as_curl_command(response.request))
'''
return "curl -X {method} -H {headers} -d '{data}' '{uri}'".format(
method=request.method,
headers=" -H ".join(["'{}'".format('{0}: {1}'.format(k, v).replace('\\', '\\\\').replace("'", "\\'")) for k, v in request.headers.items()]),
@jelmervdl
jelmervdl / Example.md
Last active May 25, 2016 17:20
Turing Machine in Python
python ./turing.py ./binaryadd.txt "110110 101011"

Keybase proof

I hereby claim:

  • I am jelmervdl on github.
  • I am jelmervdl (https://keybase.io/jelmervdl) on keybase.
  • I have a public key ASDlvfhRb9fmwrCVFH8xULpQEDrpkmSvASUyffQvJoxL-wo

To claim this, I am signing this object:

@jelmervdl
jelmervdl / send_mail.php
Created November 11, 2015 11:42
PHP streaming email
<?php
function send_mail_with_attachment($to, $subject, $message, $additional_headers, $file_handle, $file_name)
{
if (!$file_handle)
throw new InvalidArgumentException("The provided file handle is not working");
$fout = popen('sendmail ' . escapeshellarg($to), 'w');
if (!$fout)