Skip to content

Instantly share code, notes, and snippets.

View lavoiesl's full-sized avatar

Sébastien Lavoie lavoiesl

View GitHub Profile
@lavoiesl
lavoiesl / AbstractFixtureMigration.php
Last active October 18, 2023 19:23
Load Doctrine Fixtures when using Migrations in Symfony: AbstractFixtureMigration
<?php
use Doctrine\Common\DataFixtures\Executor\ORMExecutor;
use Doctrine\Common\DataFixtures\Purger\ORMPurger;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader as Loader;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@lavoiesl
lavoiesl / composer-latest.py
Created November 19, 2014 20:02
Checking latest version of Composer using Python and GitHub API
#!/usr/bin/python
import urllib2
import json
request = urllib2.urlopen('https://api.github.com/repos/composer/composer/git/refs/heads/master')
obj = json.load(request)
print obj["object"]["sha"]
@lavoiesl
lavoiesl / brew_installed.sh
Created November 11, 2014 19:29
BASH utility functions collection
##
# Determine if a brew is installed.
#
# @uses brew
# @param string brew name
# @returns success code
#
function brew_installed() {
local brew="${1}"
@lavoiesl
lavoiesl / subl.sh
Last active August 29, 2015 14:08
Starting a text editor from inside a Virtual Machine
#!/bin/bash
# Starting Sublime Text from inside a Virtual Machine
# @link https://gist.github.com/lavoiesl/c01b16b5f875906a6d82
# You may require to install realpath
path="$(realpath "$1")"
if echo "${path}" | grep -q "^/media/data/projects"; then
#!/bin/bash
# @link https://gist.github.com/lavoiesl/eac60efde00c1df49c73
function usage() {
echo "Homebrew manager"
echo "Use dump-merge to save a list of installed brews to Dropbox"
echo "Use install to install missing brews"
echo "Usage: ${0} [--cask] [--directory directory] [--hostname hostname] dump|merge|dump-merge|diff|install" >&2
exit 255
}
#!/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
#!/bin/bash
##
# https://pushover.net/ CLI tool
#
# @license MIT
# @author http://blog.lavoie.sl/
# @link https://gist.github.com/lavoiesl/e0d1d9173e25bccb63a3
#
# Supports APP bookmarks, example:
#!/bin/bash
# Convert file from iso-8859-* to UTF8 if needed
#
# @link https://gist.github.com/lavoiesl/432827990d78c3764f50
if [[ $# -lt 1 ]]; then
echo "Usage: $0 input-file" >&2
exit 1
fi
#!/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
@lavoiesl
lavoiesl / osx-socks-proxy.sh
Last active March 21, 2019 14:34
OSX script to fire up a SSH connection and tunnel all traffic to it using a SOCKS proxy.
#!/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