Skip to content

Instantly share code, notes, and snippets.

View jpetitcolas's full-sized avatar

Jonathan Petitcolas jpetitcolas

View GitHub Profile
@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
View Finding all test files not included in PHPUnit testsuite.sh
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
View Pair lines with sed.sh
sed '$!N;s/\n/ /' infile
@jpetitcolas
jpetitcolas / Split big files into several smaller ones.sh
Created March 24, 2014 08:34
Split a big file into several parts with Linux
View Split big files into several smaller ones.sh
# Splitting file into smaller parts
split --bytes=512M bigfile prefix
# Joining all file parts
cat prefix* > bigfile
@jpetitcolas
jpetitcolas / cleaning.sh
Created April 2, 2014 10:34
Cleaning all Docker containers and images
View cleaning.sh
sudo docker stop $(sudo docker ps -a -q)
sudo docker rm $(sudo docker ps -a -q)
sudo docker rmi $(sudo docker images -a -q)
@jpetitcolas
jpetitcolas / issue.php
Last active August 29, 2015 13:58
Issue with Document Manager
View issue.php
<?php
// Controller
$tag = new Tag();
$dm->persist($tag);
$dm->flush();
$this->getContainer()->get('my_service')->import($content, $tag);
// Service
@jpetitcolas
jpetitcolas / Makefile
Created January 27, 2015 13:01
Playing with websockets in Go
View Makefile
run:
docker run \
--rm \
--volume="`pwd`:/srv" \
--tty \
--interactive \
--publish="8080:8080" \
marmelab/go run src/marmelab/gollabedit/*.go
@jpetitcolas
jpetitcolas / Application.js
Created February 27, 2015 10:45
Issue with Babel
View Application.js
import View from "./folder/View";
class Application {
constructor() {
this.view = new View("I'm a view!");
}
sayHello() {
console.log("Hello");
}
@jpetitcolas
jpetitcolas / db-save.sh
Created September 19, 2015 13:14
Dump a Docker-ized database to Amazon S3
View db-save.sh
#!/bin/bash
# @see http://www.jonathan-petitcolas.com/2015/09/21/dump-docker-ized-database-to-amazon-s3.html
# Configuration
FILENAME="awesomeproject-`date +%Y-%m-%d-%H:%M:%S`.sql"
CONTAINER_NAME="awesomeproject_pgsql"
DUMPS_FOLDER="/home/awesomeproject/dumps"
BUCKET_NAME="awesomeproject-private"
@jpetitcolas
jpetitcolas / couvent.js
Created September 22, 2015 12:19
Only French would understand this lib... ;)
View couvent.js
// couvent.js - MIT license
Array.prototype.slice.call(document.querySelectorAll('*')).forEach(function (el) {
el.style.display = 'none';
});
@jpetitcolas
jpetitcolas / read-only-on-select-list.js
Created December 28, 2012 06:33
A short snippet to simulate read-only attribute on a select list, which is currently not W3C-compliant. We can not just disable it, as a disabled input is not sent when submitting a form. The trick here is to store the disabled select value into a hidden field.
View read-only-on-select-list.js
/**
* Simulate the read-only attribute on a select list (as it is not normalized).
* @see http://www.w3.org/wiki/HTML/Elements/select
* @param Object Select list element
**/
function setReadOnlyOnSelect(selectList)
{
// Ensure selectList exists
if(!selectList.length) {
console.warn("Unable to find specified select list.");