Skip to content

Instantly share code, notes, and snippets.

@mgiacomini
mgiacomini / sync-file.sh
Created November 5, 2014 16:29
Sync files
#!/bin/bash
echo "Sync files"
echo "------------------------------------"
if [ "$1" = "" || $2 = "" ]; then
echo "Source/Dest path can not be null"
exit
fi
@mgiacomini
mgiacomini / example.c
Last active August 29, 2015 14:08
c-cli-getopt
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int
main (int argc, char **argv)
{
int aflag = 0;
int bflag = 0;
@mgiacomini
mgiacomini / uninstall_homebrew.sh
Created October 8, 2014 03:00
Uninstalling homebrew
#!/bin/bash
cd `brew --prefix`
git checkout master
git ls-files -z | pbcopy
rm -rf Cellar
bin/brew prune
pbpaste | xargs -0 rm
rm -r Library/Homebrew Library/Aliases Library/Formula Library/Contributions
test -d Library/LinkedKegs && rm -r Library/LinkedKegs
rmdir -p bin Library share/man/man1 2> /dev/null
@mgiacomini
mgiacomini / gearman_install.sh
Created August 27, 2014 13:56
Gearman and your php extension installation in debian dist
#!/bin/bash
# install libs
apt-get install apache2 php5 libapache2-mod-php5 php5-dev
apt-get install gearman-job-server libgearman-dev
apt-get install php-pear
pecl install gearman-1.0.3
# activate Gearman extension for Apache2
echo "extension=gearman.so" > /etc/php5/conf.d/gearman.ini
typedef struct node {
int key;
struct node *left;
struct node *right;
} node;
int is_odd(node *n){
// verify the root key
if (n->key % 2 != 0)
return 1;
$str = "key1=value1&key2=value2&key2=value3&key3=value4";
$params = explode("&", $str);
$output = array();
foreach ($params as $param){
$param = explode("=", $param);
$key = $param[0];