Skip to content

Instantly share code, notes, and snippets.

View lavoiesl's full-sized avatar

Sébastien Lavoie lavoiesl

View GitHub Profile
composer update --profile -vvv --ignore-platform-reqs 9:22:59 ∞
[8.0MB/0.18s] Reading ./composer.json
[8.0MB/0.23s] Loading config file /home/vagrant/.composer/config.json
[8.0MB/0.24s] Loading config file /home/vagrant/.composer/auth.json
[8.0MB/0.25s] Loading config file ./composer.json
[8.0MB/0.31s] Executing command (CWD): git describe --exact-match --tags
[8.0MB/0.39s] Executing command (CWD): git branch --no-color --no-abbrev -v
[8.0MB/0.64s] Failed to initialize global composer: Composer could not find the config file: /home/vagrant/.composer/composer.json
To initialize a project, please create a composer.json file as described in the http://getcomposer.org/ "Getting Started" section
@lavoiesl
lavoiesl / cacheGetDefault.php
Last active August 29, 2015 14:10
Get a value from a Doctrine Cache or compute it using a callback, including stampede protection
<?php
/**
* Get a value from the cache or compute it using a callback
* Includes cache stampede protection
* @link http://en.wikipedia.org/wiki/Cache_stampede
* @link http://blog.lavoie.sl/2014/12/preventing-cache-stampede-using-doctrine-cache.html
* @global cache Doctrine\Common\Cache\Cache
*
* @param string $key Cache key
@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