Skip to content

Instantly share code, notes, and snippets.

View mdonkers's full-sized avatar
🏍️

Miel Donkers mdonkers

🏍️
View GitHub Profile
@mdonkers
mdonkers / sed-replace-markdown-links
Created July 28, 2017 19:28
sed command to replace Markdown style links with HTML links, opening in separate tab
@mdonkers
mdonkers / server.py
Last active June 10, 2024 18:44
Simple Python 3 HTTP server for logging all GET and POST requests
#!/usr/bin/env python3
"""
License: MIT License
Copyright (c) 2023 Miel Donkers
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
@mdonkers
mdonkers / setup-vpn.sh
Created January 6, 2017 07:34
Run as root user. Needs openconnect installed. Connect to Juniper / Pulse VPN automatically, parsing password from a GPG encrypted file so it doen't have to be entered manually. Note this will have security implications!
#!/bin/bash
# encrypt (leave one empty line after password)
#gpg -e -a -r <user-id> your_password_file
set -e
# Must be a valid filename
NAME=my-vpn
PIDFILE=/var/run/$NAME.pid
@mdonkers
mdonkers / keybase.md
Created July 21, 2016 11:28
keybase.md

Keybase proof

I hereby claim:

  • I am mdonkers on github.
  • I am mdonkers (https://keybase.io/mdonkers) on keybase.
  • I have a public key whose fingerprint is 9AEF 5150 9C3C F6F5 5970 3C24 A957 88A1 2404 6A96

To claim this, I am signing this object:

@mdonkers
mdonkers / README.md
Last active March 2, 2016 20:17
Meteor setup for TypeScript and Angular 2

Intro

This document and related files show how a basic working setup for Meteor is created with TypeScript and Angular 2.

The following preconditions apply:

  • Meteor 1.2 installed
  • NodeJS installed (I used 5.7)

Steps

  1. Create a new Meteor project
  2. Install / remove the following packages for Meteor:
@mdonkers
mdonkers / activate_environment.sh
Created January 8, 2016 13:34
Activates Python virtualenv. Use as "$ source activate_environment.sh <virtualenv_directory>". Will also update the prompt, to show which virtualenv environment is active, and reset the prompt when no longer active. Assumes command-prompt is already created with git-prompt; https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh
#!/bin/bash
## Call with 'source activate_environment.sh <env>'
function check_sourced {
local last_elem=${#FUNCNAME[@]}-1
if [[ "main" == ${FUNCNAME[$last_elem]} ]] ; then
echo "Being executed from a sub-shell, which won't set the environment correctly"
echo "Execute as 'source activate_environment <env>' or '. activate_environment <env>'"
@mdonkers
mdonkers / python_server.py
Created November 11, 2015 22:28
Extreme Startup Game implementation in Python, up and until round 3
from flask import Flask, session, redirect, url_for, escape, request
import math
import re
app = Flask(__name__)
def get_name(question): return "Miel"
@mdonkers
mdonkers / directive.js
Created January 5, 2014 16:45
AngularJS Directives - Using value in HTML attribute directly instead of needing to store on $scope.
myApp.directive('statsList', function () {
return {
restrict: 'E',
scope: {
items: '=listType',
orderBy: '@'
},
templateUrl: 'partials/partial1.html'
};
});
@mdonkers
mdonkers / service.js
Created January 5, 2014 16:08
Extending one AngularJS service by another service, modifying input parameters and response.
myApp.factory('couchService', function (basicCouchService) {
return {
get: function(listType, response) {
// Convert the input parameters to the schema-names used inside CouchDB
var couchSchema = (listType.listType === 'latest') ? 'by_submit' : 'by_duration';
basicCouchService.get({listType: couchSchema}, function (localResponse) {
// Get the top-10, assume the array is already ordered wrong way around.
var rowList = localResponse.rows;
rowList = rowList.slice(rowList.length - 10, rowList.length);
localResponse.rows = rowList;
@mdonkers
mdonkers / Application.scala
Last active December 17, 2015 20:29
Provided combination of 'routes' and Application does not seem to work. Problem loading Angular JavaScript, the commented line (fetching from googleapis) works, but the routes.Assets include does not work. Results in syntax error on '<'
object Application extends Controller {
def index(path: String) = Action {
Ok(views.html.main())
}
}