Skip to content

Instantly share code, notes, and snippets.

View jpetitcolas's full-sized avatar

Jonathan Petitcolas jpetitcolas

View GitHub Profile
@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
# 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
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
<?php
// Controller
$tag = new Tag();
$dm->persist($tag);
$dm->flush();
$this->getContainer()->get('my_service')->import($content, $tag);
// Service
@jpetitcolas
jpetitcolas / pre-commit
Created August 12, 2014 14:54
My standard Git pre-commit hook
#!/bin/sh
#
# Based on http://nrocco.github.io/2012/04/19/git-pre-commit-hook-for-PHP.html post
#
# Do not forget to: chmod +x .git/hooks/pre-commit
BAD_PHP_WORDS='var_dump|die|todo'
BAD_TWIG_WORDS='{{ dump(.*) }}'
EXITCODE=0
@jpetitcolas
jpetitcolas / parsing-binary-file.go
Last active July 27, 2020 12:40
How to parse a binary file in Go? Snippet based on MoPaQ SC2 replay parsing. Related blog post: http://www.jonathan-petitcolas.com/2014/09/25/parsing-binary-files-in-go.html
package main
import (
"bytes"
"encoding/binary"
"fmt"
"log"
"os"
)
@jpetitcolas
jpetitcolas / Makefile
Created January 27, 2015 13:01
Playing with websockets in Go
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
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
#!/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... ;)
// couvent.js - MIT license
Array.prototype.slice.call(document.querySelectorAll('*')).forEach(function (el) {
el.style.display = 'none';
});
const typeFinder = type => function* (params = {}, ref = 'master') {
const search = function* (searchParams) {
const Api = yield initApi;
const reference = ref === 'master' ? Api.master() : ref;
const preparedForm = Api.form('everything')
.ref(reference)
.pageSize(200);
const predicates = [];