Skip to content

Instantly share code, notes, and snippets.

View jpetitcolas's full-sized avatar

Jonathan Petitcolas jpetitcolas

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / Pair lines with sed.sh
Created March 6, 2014 13:33
Pair lines with sed
sed '$!N;s/\n/ /' infile
@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 / 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 / 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