This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Converts an image in a multi-resolution favicon | |
| # Requires Imagemagick | |
| # | |
| # @link https://gist.github.com/lavoiesl/a7ccb4affe869d0a0bca | |
| if [[ "$#" != "2" ]]; then | |
| echo "Usage: $0 input.png output.ico" >&2 | |
| exit 1 | |
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # OSX script to fire up a SSH connection and tunnel all traffic to it using a SOCKS proxy. | |
| # @link https://gist.github.com/lavoiesl/3bd6a07af04a7979a814 | |
| # | |
| # Features: | |
| # - Network detection (wi-fi/Ethernet) | |
| # - SSH crash detection | |
| # - Graceful interrupt | |
| # - Automatic proxy deconfiguration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // gcc -O2 -Wall -pedantic process-mysqldump.c -o process-mysqldump | |
| // Usage: cat dump.sql | process-mysqldump | |
| // Or : process-mysqldump dump.sql | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <stdbool.h> | |
| #include <string.h> | |
| #define BUFFER 100000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // $pdo = new PDO(...) | |
| $charsets = array('UTF-8', 'ISO-8859-1'); | |
| $tables = array( | |
| 'events' => array( | |
| 'title', | |
| 'description', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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")" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # @link https://gist.github.com/lavoiesl/11024316 | |
| folder="${1:-.}" | |
| find -E "$folder" -regex '.*/\.(git|svn)' -prune -o -type f -print \ | |
| | grep -oiE '\.[a-z0-9_]+$' \ | |
| | tr '[:upper:]' '[:lower:]' \ | |
| | sort \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # @link https://gist.github.com/lavoiesl/11024067 | |
| find . -type f \( -name '*.jpg' -or -name '*.jpeg' \) -exec jpegoptim --strip-all "{}" \; | |
| find . -type f -name '*.png' -exec optipng -o8 -strip all '{}' \; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # @link https://gist.github.com/lavoiesl/11023856 | |
| ioreg="$(ioreg -c AppleSmartBattery)" | |
| current="$(echo "$ioreg" | grep CurrentCapacity | grep -oE "[0-9]+" | head -n1)" | |
| max="$(echo "$ioreg" | grep MaxCapacity | grep -oE "[0-9]+" | head -n1)" | |
| battery="$(( current * 100 / max ))" | |
| echo -ne '|' |