Skip to content

Instantly share code, notes, and snippets.

Jonathan Petitcolas jpetitcolas

Block or report user

Report or block jpetitcolas

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jpetitcolas
jpetitcolas / javascript.json
Created Mar 5, 2018
React Functional Component Visual Code Snippet
View javascript.json
{
"Create new functional component": {
"prefix": "_compo",
"body": [
"import React from 'react';",
"import PropTypes from 'prop-types';",
"",
"export const $1 = ({$2}) => (",
" $3",
");",
@jpetitcolas
jpetitcolas / Dockerfile
Created Dec 12, 2017
Docker configuration for Prestashop
View Dockerfile
# config/php/Dockerfile
FROM php:7.0-fpm
RUN apt-get update
RUN apt-get install -y zlib1g-dev && docker-php-ext-install -j$(nproc) zip
RUN \
apt-get install -y libpng-dev libjpeg62-turbo-dev libfreetype6-dev && \
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \
docker-php-ext-install -j$(nproc) gd
@jpetitcolas
jpetitcolas / gist:4b93a9c9745af5345182fadd0176d298
Created Apr 13, 2017
Display browser logs in Selenium logs
View gist:4b93a9c9745af5345182fadd0176d298
driver.manage().logs()
.get('browser')
.then(v => v && v.length && console.log(v));
View test.js
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 = [];
@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 / 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"
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 / 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 Aug 21, 2019
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
You can’t perform that action at this time.