Skip to content

Instantly share code, notes, and snippets.

View jpetitcolas's full-sized avatar

Jonathan Petitcolas jpetitcolas

View GitHub Profile
@jpetitcolas
jpetitcolas / smb.conf
Created July 31, 2013 08:25
Configuration of Samba share for Web dev between VM and host machine. Do not forget to change "guest account" and "dev" path. ;)
#
# Sample configuration file for the Samba suite for Debian GNU/Linux.
#
#
# This is the main Samba configuration file. You should read the
# smb.conf(5) manual page in order to understand the options listed
# here. Samba has a huge number of configurable options most of which
# are not shown in this example
#
# Some options that are often worth tuning have been included as
@jpetitcolas
jpetitcolas / new_gist_file
Created August 1, 2013 07:35
Remember a passphrase in CLI mode
ssh-agent bash
ssh-add
@jpetitcolas
jpetitcolas / vbox-additions.sh
Created August 28, 2013 10:21
How to install Virtual Box addition tools for Debian?
apt-get install build-essential module-assistant
m-a prepare
# Install Guest Additions from VBox menu
mount /media/cdrom
sh /media/cdrom/VBoxLinuxAdditions.run
@jpetitcolas
jpetitcolas / changeset.php
Created September 19, 2013 08:24
Detecting a property change on Doctrine2 listener
private function updateLastUpdateDate(LifecycleEventArgs $eventArgs)
{
$changeSet = $eventArgs->getEntityManager()->getUnitOfWork()->getEntityChangeSet($this);
if (!array_key_exists('status', $changeSet)) {
return;
}
// $statusBefore = $changeSet['status'][0];
// $statusAfter = $changeSet['status'][1];
}
@jpetitcolas
jpetitcolas / parse.php
Created October 2, 2013 07:06
Parse XML namespaced elements
$sitemap = new \DOMDocument();
$sitemap->loadXml($feedGenerator->generate());
$xpath = new \DOMXPath($sitemap);
$xpath->registerNamespace('image', 'http://www.google.com/schemas/sitemap-image/1.1');
$image = $xpath->evaluate('//image:image');
@jpetitcolas
jpetitcolas / array-manipulation.js
Created November 19, 2013 08:44
Array manipulation in Javascript
// Remove an element at desired index
a.splice(desiredIndex, 1);
// Add an element at given index
a.splice(desiredIndex, 0, "My new element");
@jpetitcolas
jpetitcolas / new_gist_file.sh
Created November 26, 2013 16:17
mysqldump of only n records
mysqldump --opt --where="1 limit 1000000" database table > dump.sql
@jpetitcolas
jpetitcolas / vagrant-php-project.sh
Created November 30, 2013 09:28
Vagrant bootstraping script for PHP project
#!/usr/bin/env bash
# Install common environment
apt-get update
apt-get install -y curl
# Install Git and configure it (useful when working on Windows)
apt-get install -y git-core
git config --global color.ui auto
git config --global core.filemode false
@jpetitcolas
jpetitcolas / Finding all test files not included in PHPUnit testsuite.sh
Last active August 29, 2015 13:57
Finding all test files not included in PHPUnit testsuite
find src/ -type f -name *Test.php -exec grep -H -c "@group" {} \; | grep :0\$ | awk -F':' '{ print $1 }'
@jpetitcolas
jpetitcolas / Pair lines with sed.sh
Created March 6, 2014 13:33
Pair lines with sed
sed '$!N;s/\n/ /' infile