Skip to content

Instantly share code, notes, and snippets.

Avatar

Jonathan Petitcolas jpetitcolas

View GitHub Profile
@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
@jpetitcolas
jpetitcolas / parsing-binary-file.go
Last active Jul 27, 2020
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
View parsing-binary-file.go
package main
import (
"bytes"
"encoding/binary"
"fmt"
"log"
"os"
)
@jpetitcolas
jpetitcolas / pre-commit
Created Aug 12, 2014
My standard Git pre-commit hook
View pre-commit
#!/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 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 / 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 / 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 / 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 / vagrant-php-project.sh
Created Nov 30, 2013
Vagrant bootstraping script for PHP project
View vagrant-php-project.sh
#!/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 Nov 26, 2013
mysqldump of only n records
View new_gist_file.sh
mysqldump --opt --where="1 limit 1000000" database table > dump.sql