Skip to content

Instantly share code, notes, and snippets.

@gboddin
gboddin / udp2ws.js
Last active August 29, 2015 14:00
udp2ws.js
// Bridging upd datagrams to websockets using a nodejs app
// Listening on udp://0.0.0.0:41234
// Broadcasting on ws://0.0.0.0:8080
// -> https://github.com/einaros/ws
var WebSocketServer = require('ws').Server;
var dgram = require("dgram");
var ServerWS = new WebSocketServer({port: 8080});
@gboddin
gboddin / HttpJsonClient.php
Last active August 29, 2015 14:08
Http JSON client class for REST API (like elasticsearch)
<?php
class HttpJsonClient {
static function GET($url,$body=null) {
return self::request('GET',$url,$body);
}
static function PUT($url,$body=null) {
return self::request('PUT',$url,$body);
}
static function DELETE($url,$body=null) {
@gboddin
gboddin / init.sh
Last active August 29, 2015 14:10
git subtree subdirectory without index clashes
git remote add -f upstream_lib1 /repo.source.git
git fetch upstream_lib1
git remote add -f upstream_lib2 /repo.source.git
git fetch upstream_lib2
git remote add -f upstream_sites /repo.source.git
git fetch upstream_sites
git checkout -b upstream_lib1 upstream_lib1/master # now on upstream branch
git subtree split --prefix=lib1 --annotate="[lib1]" --rejoin -b subtrees/lib1
@gboddin
gboddin / time
Created December 24, 2014 12:16
Some time routine ... I got bored :)
<?php
date_default_timezone_set('Europe/Brussels');
$year = 0;
$month = 1;
$day = 0;
while(true) {
$day++;
$year = str_pad($year,4,"0",STR_PAD_LEFT);
$date = $year.'-'.$month.'-'.$day;
echo $date.' '.date('r',strtotime($date)).PHP_EOL;
@gboddin
gboddin / mysql_community_latest_debian_salt.sls
Last active August 29, 2015 14:12
Install a configured mysql community edition server directly from mysql repos on Debian Stable
mysql-apt-config-debconf:
debconf.set:
- name: mysql-apt-config
- data:
'mysql-apt-config/select-server': {'type': 'string', 'value': 'mysql-5.6'}
'mysql-apt-config/select-utilities': {'type': 'string', 'value': 'utilities-1.5'}
'mysql-apt-config/select-connector-python': {'type': 'string', 'value': 'connector-python-2.0'}
mysql-apt-config:
pkg.installed:
- require:
@gboddin
gboddin / nce.sh
Last active August 29, 2015 14:13
net corruption test
#!/bin/bash
#quick nt wrapper thanks V****** Franck
[ -z "$1" ] && echo "First arg is <server/client>"&&exit 1
if [ "$1" = "server" ]; then
[ -z "$2" ] && echo "Second arg is listening port"&&exit 1
while /bin/true; do
nc -lp $2 2>/dev/null > /tmp/tcptest || nc -l $2 2> /dev/null > /tmp/tcptest
md5sum /tmp/tcptest
sleep 1
done
@gboddin
gboddin / happy_shell.sh
Last active August 29, 2015 14:14
An comfortable shell is a good beginning :) ...
# from the work of :
git clone https://github.com/revans/bash-it.git ~/.bash_it
~/.bash_it/install.sh
# say n none none none
. ~/.bash_it/bash_it.sh
for e in bash-it defaults drush git git_flow ssh virtualbox ; do bash-it enable completion $e; done
for e in base battery browser dirs extract fasd git history python ssh tmux ; do bash-it enable plugin $e; done
for e in general git vim ; do bash-it enable alias $e; done
#logout/login now
Origin: Vagrant mirror repo
Label: Same
Codename: deb
Architectures: i386 amd64
Components: main
Description: Apt repository for project vagrant
#SignWith: 5269DE62
@gboddin
gboddin / README.md
Last active August 29, 2015 14:16
Install an Ubuntu Vivid container :
@gboddin
gboddin / -etc-tor-torrc
Created March 10, 2015 19:39
Avoid silent block from stupid ISPs with tor
VirtualAddrNetworkIPv4 10.192.0.0/10
AutomapHostsOnResolve 1
TransPort 9040
DNSPort 53535