Skip to content

Instantly share code, notes, and snippets.

View jelmervdl's full-sized avatar

Jelmer jelmervdl

View GitHub Profile
@jelmervdl
jelmervdl / deoosterpoort-to-gcal.user.js
Last active March 12, 2017 23:01
Add 'GCal' link to all the dates in the the programme on the de Oosterpoort website.
// ==UserScript==
// @name GCal links for De Oosterpoort
// @namespace http://ikhoefgeen.nl/userscripts
// @description Create Google Calendar events directly from De Oosterpoort website
// @include http://www.de-oosterpoort.nl/programma/*
// ==/UserScript==
var DeOosterpoort = {}
DeOosterpoort.findData = function(root)
@jelmervdl
jelmervdl / deoosterpoort-to-ical.user.js
Created May 15, 2013 16:11
Add a download link for an iCal file to all the dates in the the programme on the de Oosterpoort website.
// ==UserScript==
// @name iCal links for De Oosterpoort
// @namespace http://ikhoefgeen.nl/userscripts
// @description Create iCal events directly from De Oosterpoort website
// @include http://www.de-oosterpoort.nl/programma/*
// ==/UserScript==
// Credits:
// Base64 encode / decode
// http://www.webtoolkit.info/
//
@jelmervdl
jelmervdl / hipster-facebook.css
Created July 29, 2013 12:16
Hipster Facebook
#chatFriendsOnline {
display: none
;
}
#fbTimelineHeadline .profilePicThumb,
#fbTimelineHeadline .profilePic {
border-radius: 50%;
}
@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)

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 / Example.md
Last active May 25, 2016 17:20
Turing Machine in Python
python ./turing.py ./binaryadd.txt "110110 101011"
@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 / 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 / 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 / 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