Skip to content

Instantly share code, notes, and snippets.

Avatar

Jonathan Petitcolas jpetitcolas

View GitHub Profile
@jpetitcolas
jpetitcolas / Finding all test files not included in PHPUnit testsuite.sh
Last active Aug 29, 2015
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 / Split big files into several smaller ones.sh
Created Mar 24, 2014
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 Apr 2, 2014
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 Aug 29, 2015
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 Jan 27, 2015
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
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 Sep 19, 2015
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 Sep 22, 2015
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 Dec 28, 2012
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.");
You can’t perform that action at this time.