Skip to content

Instantly share code, notes, and snippets.

View thibault's full-sized avatar

Thibault J. thibault

View GitHub Profile
@thibault
thibault / python
Created December 25, 2021 16:07
Solution à l'advent of code 2021, jour 18
import re
import math
class Leaf:
def __init__(self, val):
self.val = val
def __str__(self):
return f'{self.val}'
04341dccd2654e7465493acec7c1a27f806472544e34b09f3064f974202d233f6910cdda14bf80fd36d9d3fd7698b69150b9e0254b888aaddcbf494a10e76ec621
@thibault
thibault / .gitconfig
Created July 5, 2016 13:12
A nice starting git config file
[user]
mail = youremail@test.com
name = Your Name
[color]
ui = true
[alias]
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all
[push]
default = current
[pull]
@thibault
thibault / internationl_phone_regex.py
Created November 6, 2014 10:58
International phone number validation regex in Python
phone_re = re.compile(r'^\+(999|998|997|996|995|994|993|992|991|'
'990|979|978|977|976|975|974|973|972|971|970|'
'969|968|967|966|965|964|963|962|961|960|899|'
'898|897|896|895|894|893|892|891|890|889|888|'
'887|886|885|884|883|882|881|880|879|878|877|'
'876|875|874|873|872|871|870|859|858|857|856|'
'855|854|853|852|851|850|839|838|837|836|835|'
'834|833|832|831|830|809|808|807|806|805|804|'
'803|802|801|800|699|698|697|696|695|694|693|'
'692|691|690|689|688|687|686|685|684|683|682|'
@thibault
thibault / 01_fixtures.sh
Last active August 29, 2015 14:07
Testing script_fields and _source
# (Re)create the index
curl -X DELETE 'http://localhost:9200/script-fields-test/'
curl -X PUT 'http://localhost:9200/script-fields-test/'
# Index documents
curl -X POST 'http://localhost:9200/script-fields-test/d/1' -d '{"title":"Title1", "count":1}'
curl -X POST 'http://localhost:9200/script-fields-test/d/2' -d '{"title":"Title1", "count":2}'
curl -X POST 'http://localhost:9200/script-fields-test/_refresh'
@thibault
thibault / rexep.pl
Created October 14, 2014 07:15
Monster regexp
(?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)*\<(?:(?:\r\n)?[ \t])*(?:@(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\
@thibault
thibault / Makefile
Created April 1, 2014 18:15
Base js app
MOCHA='./node_modules/mocha/bin/mocha'
TEST_DIR='tests'
all: test
test:
$(MOCHA) $(TEST_DIR)
.PHONY: test
(function(exports) {
var Models = {};
exports.Models = Models;
Models.Hotel = Backbone.Model.extend({
defaults: {
name: 'default name',
price: 10
},
@thibault
thibault / 000-output.js
Last active April 21, 2017 09:54
Rappels de quelques éléments de syntaxe Javascript
// Pour afficher des données
// Popup (pas très propre)
alert('Coucou');
// Affichage sur la console
console.log('Coucou');
// Remplacer le texte d'un Nœud HTML
var node = document.getElementById('node-id');
@thibault
thibault / clean_add_and_commit
Created September 19, 2013 08:40
Sans commentaire
echo "toto plop"