Skip to content

Instantly share code, notes, and snippets.

Avatar
🏍️

Miel Donkers mdonkers

🏍️
View GitHub Profile
@mdonkers
mdonkers / sed-replace-markdown-links
Created Jul 28, 2017
sed command to replace Markdown style links with HTML links, opening in separate tab
View sed-replace-markdown-links
@mdonkers
mdonkers / server.py
Created Mar 29, 2017
Simple Python 3 HTTP server for logging all GET and POST requests
View server.py
#!/usr/bin/env python3
"""
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
import logging
class S(BaseHTTPRequestHandler):
@mdonkers
mdonkers / setup-vpn.sh
Created Jan 6, 2017
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!
View setup-vpn.sh
#!/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
View 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 Mar 2, 2016
Meteor setup for TypeScript and Angular 2
View README.md

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 Jan 8, 2016
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
View activate_environment.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 Nov 11, 2015
Extreme Startup Game implementation in Python, up and until round 3
View python_server.py
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 Jan 5, 2014
AngularJS Directives - Using value in HTML attribute directly instead of needing to store on $scope.
View directive.js
myApp.directive('statsList', function () {
return {
restrict: 'E',
scope: {
items: '=listType',
orderBy: '@'
},
templateUrl: 'partials/partial1.html'
};
});
@mdonkers
mdonkers / service.js
Created Jan 5, 2014
Extending one AngularJS service by another service, modifying input parameters and response.
View service.js
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 Dec 17, 2015
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 '<'
View Application.scala
object Application extends Controller {
def index(path: String) = Action {
Ok(views.html.main())
}
}