Skip to content

Instantly share code, notes, and snippets.

View batiste's full-sized avatar
🏠
Working from home

Batiste Bieler batiste

🏠
Working from home
View GitHub Profile
@batiste
batiste / middleware.py
Created June 14, 2021 12:45
WSGI middleware storing request env. in the thread, it will work with Django, Flask, Fast API
# A middlware that stores the envrionement dict inside the current
# thread, implement a get_request_id method for easy retrieval
from threading import local
_threadlocals = local()
_threadvariables = set()
def set_thread_variable(key, val):
@batiste
batiste / patternMatching.js
Created March 26, 2021 17:03
Google Coding Competition, Pattern matching, Round 1A 2020
// https://codingcompetitions.withgoogle.com/codejam/round/000000000019fd74/00000000002b3034
function readInput() {
const readline = require('readline')
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
})
@batiste
batiste / md5.py
Created June 22, 2019 11:12
Moi aussi
#!/usr/bin/python
# -*- coding: utf-8 -*-
# pour executer ce script
# 1. Avoir python installé (déjà présent sur Mac ou Linux)
# 2. Ouvrir un Terminal (logiciel Terminal sur mac)
# 3. Taper dans le terminal: python <ce script> <le répértoire> > <fichier de sortie>
# E.g. python md5.py /Users/toto/Documents > output.txt
import glob
import hashlib
import sys
@batiste
batiste / DogPage.blop
Created June 6, 2019 13:13
Blop language example
import { DogGame } from './DogBreedGame.blop'
def DogPage(attributes) {
{ state } = attributes
<DogGame page=state.dogPage state=state loading=state.loading>
= 'Dog breed game'
</DogGame>
}
@batiste
batiste / Js sugar
Last active August 29, 2015 14:08
A proposition for some simple syntactic sugar that compiles to Javascript
Goal:
1. Not reinventing JavaScript. Minimalistic sugar.
2. Aleviate the verbosness of the language especially with function definition, semicolon, and the var keyword
3. Avoid CoffeScript error http://lucumr.pocoo.org/2011/12/22/implicit-scoping-in-coffeescript/
Features? Implicit return?
Implementation? PEG.js http://pegjs.majda.cz/online
@batiste
batiste / expression.js
Last active August 29, 2015 14:02
Easy expression engine in JavaScript
function replaceOutOfStrings(str) {
var index = 0, length = str.length, ch;
var new_str = "", inString = null, start = 0;
while(index < length) {
ch = str.charAt(index);
if(ch === '\\') {
index = index + 2;
continue;
}
if(ch === '"' || ch === "'") {
@batiste
batiste / index.js
Created June 11, 2014 11:52
requirebin sketch
var likely = require("likely.js");
var data = {list:[1, 2, 3]};
var template = likely.Template([
'for key, value in list',
' p',
' {{ value }}'
]);
var tree1 = template.tree(likely.Context(data));
@batiste
batiste / index.js
Created June 11, 2014 11:48
requirebin sketch
var likely = require("likely.js");
var data = {list:[1, 2, 3]};
var template = likely.Template([
'for key, value in list',
' p',
' {{ value }}'
]);
var tree1 = template.tree(likely.Context(data));
@batiste
batiste / splicer.py
Created June 22, 2012 13:38
Prototype for a multiprocessing test runner for Django
#!/usr/bin/env python
import multiprocessing
import os
import sys
import unittest
from django.test.simple import DjangoTestSuiteRunner
def run_test_slice(test_labels, extra_tests, slice_index, number_process):
print "Run test slice %s" % (slice_index)
runner = DjangoTestSuiteRunnerSlice(slice_index=slice_index,
@batiste
batiste / Supervisord startup
Created September 15, 2011 11:29
Supervisord
#! /bin/sh
### BEGIN INIT INFO
# Provides: supervisord
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.