Skip to content

Instantly share code, notes, and snippets.

@gboddin
gboddin / gist:5719739
Created Jun 6, 2013
refactor a string in a whole project :
View gist:5719739
find lib www -type f|grep php$|while read file; do sed -i 's/\$_Request/\$_R/g' $file ; done
View 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 Aug 29, 2015
Http JSON client class for REST API (like elasticsearch)
View HttpJsonClient.php
<?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 Aug 29, 2015
git subtree subdirectory without index clashes
View init.sh
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 Dec 24, 2014
Some time routine ... I got bored :)
View time
<?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 Aug 29, 2015
Install a configured mysql community edition server directly from mysql repos on Debian Stable
View mysql_community_latest_debian_salt.sls
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 Aug 29, 2015
net corruption test
View nce.sh
#!/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 Aug 29, 2015
An comfortable shell is a good beginning :) ...
View happy_shell.sh
# 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
View reprepro-distributions
Origin: Vagrant mirror repo
Label: Same
Codename: deb
Architectures: i386 amd64
Components: main
Description: Apt repository for project vagrant
#SignWith: 5269DE62