Skip to content

Instantly share code, notes, and snippets.

@gerbenjacobs
gerbenjacobs / habbo_giffer.sh
Created Jul 11, 2018
cURL request for animating a Habbo
View habbo_giffer.sh
curl -X POST \
https://www.habbo.com/giffer/animate \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d code=user%20%22koeientemmer%22%2C%20%22com%22%0Agesture%20%22none%22%0Awalk%206%2C%20%22southwest%22%0Astand%200.4%0Aturn%20%22south%22%0Await%200.3%0Agesture%20%22smile%22%0Await%200.4%0Awave%203%0Await%200.8%0Astand%200.4
@gerbenjacobs
gerbenjacobs / laravel-mysql-with-pma.sh
Last active Dec 7, 2017
Starts MySQL and PHPMyAdmin as containers, linked and executes `php artisan migrate --seed` when they're ready
View laravel-mysql-with-pma.sh
#!/usr/bin/env bash
# WARNING: This is ephemeral storage
export MSYS_NO_PATHCONV=1 # Windows: prevents path expansion in 'git bash' for volume mounting
NAME=project
NAME_DB=${NAME}-database
NAME_PMA=${NAME}-pma
@gerbenjacobs
gerbenjacobs / timeout.go
Created Apr 18, 2016
Golang Timeout with channels
View timeout.go
package main
import (
"fmt"
"time"
)
var (
ch chan bool
timeoutSecs uint = 3
@gerbenjacobs
gerbenjacobs / getIPRangeByCIDR.php
Last active Dec 4, 2018
Get the start and end IP from an IP Range by a CIDR (Classless Inter-Domain Routing) notation, complete or incomplete. As discussed here: https://blog.gerbenjacobs.nl/get-ip-range-by-cidr-notation.html
View getIPRangeByCIDR.php
<?php
function getIPRangeByCIDR($cidr) {
// Making sure IPs are valid
$ipdata = explode('/', ltrim($cidr, '0'));
$dotcount = substr_count($ipdata[0], '.');
if ($dotcount != 3) {
$ipdata[0] .= str_repeat('.0', (3-$dotcount));
}
$cidr_address = sprintf('%s/%s', $ipdata[0], $ipdata[1]);
@gerbenjacobs
gerbenjacobs / zeropad.js
Last active Dec 7, 2017
A javascript function to zeropad (or prefill a number with any character) and return a padded string.
View zeropad.js
function zeropad(number, amount) {
if (number >= Math.pow(10, amount)) {
return number;
}
return (Array(amount).join(0) + number).slice(-amount);
}
zeropad(2); // 2
zeropad(2, 1); // 2
@gerbenjacobs
gerbenjacobs / empty-stdclass.php
Created May 6, 2013
Create an empty StdClass object
View empty-stdclass.php
<?php
$person = (object) array_fill_keys(array('firstname', 'lastname', 'email', 'photo'), '');
?>