Skip to content

Instantly share code, notes, and snippets.

View wouterds's full-sized avatar
:octocat:
Hello world!

Wouter De Schuyter wouterds

:octocat:
Hello world!
View GitHub Profile
@wouterds
wouterds / UtilityService.php
Last active August 29, 2015 13:56
Fix datatype associative array
<?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 November 27, 2014 14:49
Fancy git log -> `git lg`
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 December 2, 2014 22:03
Recursively deletion of .DS_Store files from current folder.
find . -name '*.DS_Store' -type f -delete
#!/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
<?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)));
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);
var Checkbox = function($el) {
var _this = this;
var init = function() {
};
var nogEenPrivateFunction = function() {
};
@wouterds
wouterds / postalCodeMapping.php
Last active August 29, 2015 14:22
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 June 28, 2015 09:24
Personal Gulpfile barebone
/**
* Gulpfile
*/
var Gulpfile = function() {
// Paths
var paths = {
dest: 'public/**/',
scripts: {
src: 'resources/scripts/',
@wouterds
wouterds / slow-downloader.php
Last active August 29, 2015 14:24
Simulate slow downloads. Usage: slow-downloader.php?path=static/videos/intro.mp4
<?php
// 128KB/100ms
$ms = 100;
$size = 128;
$path = $_GET['path'];
if (empty($path)) {
return;
}