Skip to content

Instantly share code, notes, and snippets.

View lavoiesl's full-sized avatar

Sébastien Lavoie lavoiesl

View GitHub Profile
@lavoiesl
lavoiesl / gist:9327890
Created March 3, 2014 15:51
SensioLabs Insight suggestion
<?php
/**
* @Sensio\Insight\Ignore("unused_parameter", comment="$k representent the key in the callback")
*/
each([1, 2, 3], function($k, $v) {
echo $v;
});
siege -H 'Accept-Encoding: gzip' -q -b -r 10 -c 10 http://www.wemakecustom.com/js/jquery.min.js
Transactions: 100 hits
Availability: 100.00 %
Elapsed time: 2.59 secs
Data transferred: 2.79 MB
Response time: 0.23 secs
Transaction rate: 38.61 trans/sec
Throughput: 1.08 MB/sec
Concurrency: 8.87
@lavoiesl
lavoiesl / canonical-url.sh
Last active August 29, 2015 14:00
Canonical URL following Location/Redirects
#!/usr/bin/env bash
# @link https://gist.github.com/lavoiesl/11022278
VERBOSE=0
if [ "$1" = "-v" ]; then
VERBOSE=1
shift
fi
@lavoiesl
lavoiesl / imdb-infos.php
Last active August 29, 2015 14:00
Video infos / IMdb API
#!/usr/bin/env php -q
<?php
/**
* @link https://gist.github.com/lavoiesl/11023566
*/
$error = function($msg, $code = 1) {
file_put_contents('php://stderr', $msg . PHP_EOL);
exit($code);
@lavoiesl
lavoiesl / genpasswd.sh
Last active August 29, 2015 14:00
password generator + key-store
#!/bin/bash
# Generates a random password using only non-ambiguous alphanumeric characters
# Usage: genpasswd.sh [length]
#
# @link https://gist.github.com/lavoiesl/11023640
length=16
if [[ -n "$1" ]]; then
length="$1"
@lavoiesl
lavoiesl / remove-crap.sh
Last active August 29, 2015 14:00
remove-crap.sh
#!/bin/bash
#
# Script to remove temporary and junk files from Windows and OS X
# @link https://gist.github.com/lavoiesl/11023700
### Not set up to run as root. Advised not to do this. ###
#### Variables ####
# Files to remove (Add others, just remember to increment the
@lavoiesl
lavoiesl / convert-to-utf8.sh
Last active August 29, 2015 14:00
convert a file to UTF-8 using iconv
#!/bin/bash
# Convert file from iso-8859-* to UTF8 if needed
if [[ $# -lt 1 ]]; then
echo "Usage: $0 input-file" >&2
exit 1
fi
mime_encoding="$(file -b --mime-encoding "$1")"
@lavoiesl
lavoiesl / php-extras.ini
Created May 27, 2014 03:32
PHP dev extra settings
; Extra configuration
; priority=50
allow_url_fopen = On
allow_url_include = Off
auto_detect_line_endings = On
date.timezone = 'America/Montreal'
default_charset = "utf-8"
default_mimetype = "text/html"
default_socket_timeout = 10
<?php
// $pdo = new PDO(...)
$charsets = array('UTF-8', 'ISO-8859-1');
$tables = array(
'events' => array(
'title',
'description',
@lavoiesl
lavoiesl / mysql-drop-tables.sh
Last active August 29, 2015 14:03
Drop all tables of a MySQL database
#!/bin/bash
# Drop all tables of a MySQL database
# https://gist.github.com/lavoiesl/96aa8586b609daac2dad
if [ -z "$@" ]; then
echo "Usage: $0 database_name" >&2
echo " or : $0 -uuser -ppassword -hlocalhost database_name" >&2
exit 1
fi