Skip to content

Instantly share code, notes, and snippets.


Manuel Strehl Boldewyn

View GitHub Profile
View Advanced Django 1.3.x+ Logging
# Advanced Django 1.3.x+ Logging
# Author:
# Jason Giedymin < jasong _[_a-t_]_ apache d-o-t org >
# Description:
# A Django 1.3.x+ snippet with Advanced logging formatters using RFC 2822,
# TimedRotatingFileHandler, and a WatchedFileHandler.
View index.js
function(s,k){k=s.match(/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/);return new Date(Date.UTC(k[1],k[2]-1,k[3],k[4],k[5],k[6]))}

Awesome PHP Libraries

A list of amazingly awesome PHP libraries that you should consider using (and some other shiny extras).

View qsa-polyfill-ie7.js
if (!document.querySelectorAll) {
document.querySelectorAll = function(selector) {
var doc = document,
head = doc.documentElement.firstChild,
styleTag = doc.createElement('STYLE');
doc.__qsaels = [];
styleTag.styleSheet.cssText = selector + "{x:expression(document.__qsaels.push(this))}";
window.scrollBy(0, 0);
View gist:8335997

Track deployments with Piwik's Annotation API

If you use analytics tools to monitor your website, a good metric for determining the effect of changes is the time of a deployment. Does the conversion rate really improve with the latest adjustments? Has the number of 404 errors decreased since we fixed that script?

Like other analytics products, Piwik allows you to annotate your data. Wouldn't it be great if all deployments were noted automatically? With the Annotation API it's actually quite simple.

In your deployment process, just add the following line to your script or post-receive hook and fill in the placeholders:

curl "http://YOUR_PIWIK_DOMAIN/?module=API&amp;\
View search_unicode.bookmarklet.js
var x=''+(function(r){
var n=r.startContainer,
return 0xD800<=v&&v<=0xDB7F?((v&0x3FF)<<10|u.charCodeAt(1)&0x3FF)+0x10000:v;
View ambient.js
var tessel = require('tessel');
var ambientlib = require('ambient-attx4');
var ambient = ambientlib.use(tessel.port['A']);
var rm = 40;
ambient.on('ready', function () {
// Get points of light and sound data.
var int = setInterval( function () {
ambient.getLightLevel( function(err, ldata) {
Boldewyn / post-merge
Created March 2, 2017 08:49 — forked from sindresorhus/post-merge
git hook to run a command after `git pull` if a specified file was changed.In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed.Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
View post-merge
#!/usr/bin/env bash
# MIT © Sindre Sorhus -
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
Boldewyn /
Created June 16, 2017 22:26 — forked from szepeviktor/
Piwik automatic update - bash script
# Start this scipt above the /piwik directory.
# We assume that the webserver runs under www-data.
# download & verify
wget -nv "" || exit 1
wget -nv "" || exit 2
gpg --verify || exit 3
Boldewyn / functions.php
Created July 7, 2020 14:31 — forked from sirbrillig/functions.php
Post file using wp_remote_post in WordPress
View functions.php
$local_file = 'file_path'; //path to a local file on your server
$post_fields = array(
'name' => 'value',
$boundary = wp_generate_password( 24 );
$headers = array(
'content-type' => 'multipart/form-data; boundary=' . $boundary,