Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Hello world!

Wouter wouterds

:octocat:
Hello world!
View GitHub Profile
@wouterds
wouterds / UtilityService.php
Last active Aug 29, 2015
Fix datatype associative array
View UtilityService.php
<?php
public static function correctTypes($arr) {
foreach ($arr as $key => $value) {
if(is_numeric($value))
$arr[$key] = (int) $value;
elseif(is_array($value))
$arr[$key] = self::correctTypes($value);
}
@wouterds
wouterds / gist:d6b68deed9cc41be6b05
Created Nov 27, 2014
Fancy git log -> `git lg`
View gist:d6b68deed9cc41be6b05
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(cyan)<%an>%Creset' --abbrev-commit"
@wouterds
wouterds / gist:70dc6ff582c799a79e30
Created Dec 2, 2014
Recursively deletion of .DS_Store files from current folder.
View gist:70dc6ff582c799a79e30
find . -name '*.DS_Store' -type f -delete
View a2mksite.sh
#!/bin/bash
VHOST_CONF=/etc/apache2/sites-available/
ROOT_UID=0
NOTROOT=87
WWW_ROOT=/var/www/
# owner of the site directory
WEBUSER=www-data
View upload-imgur.php
<?php
$client_id = "";
$image = file_get_contents("tmp.png");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.imgur.com/3/image.json');
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Client-ID ' . $client_id));
curl_setopt($ch, CURLOPT_POSTFIELDS, array('image' => base64_encode($image)));
View point-in-polygon.js
var pointInPolygon = function(point, polygon) {
var x = point[0], y = point[1];
var inside = false;
for (var i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
var xi = polygon[i][0], yi = polygon[i][1];
var xj = polygon[j][0], yj = polygon[j][1];
var intersect = ((yi > y) != (yj > y)) && (x < (xj - xi) * (y - yi) / (yj - yi) + xi);
View gist:69ee6c5d3394873c66eb
var Checkbox = function($el) {
var _this = this;
var init = function() {
};
var nogEenPrivateFunction = function() {
};
@wouterds
wouterds / postalCodeMapping.php
Last active Aug 29, 2015
postalCodeMapping.php
View postalCodeMapping.php
<?php
public function provinceByPostalCode($postalCode)
{
$province = null;
if ($postalCode >= 1000 && $postalCode < 1300) {
$province = 'brussels';
} else if ($postalCode < 1500) {
$province = 'walloon-brabant';
@wouterds
wouterds / Gulpfile.js
Created Jun 28, 2015
Personal Gulpfile barebone
View Gulpfile.js
/**
* Gulpfile
*/
var Gulpfile = function() {
// Paths
var paths = {
dest: 'public/**/',
scripts: {
src: 'resources/scripts/',
@wouterds
wouterds / slow-downloader.php
Last active Aug 29, 2015
Simulate slow downloads. Usage: slow-downloader.php?path=static/videos/intro.mp4
View slow-downloader.php
<?php
// 128KB/100ms
$ms = 100;
$size = 128;
$path = $_GET['path'];
if (empty($path)) {
return;
}