Skip to content

Instantly share code, notes, and snippets.

View revolunet's full-sized avatar
🐫
Killing bugz

Julien Bouquillon revolunet

🐫
Killing bugz
View GitHub Profile
@revolunet
revolunet / web-audio-fetch-stream.js
Last active May 8, 2024 08:11
Web Audio streaming with fetch API
//
// loads remote file using fetch() streams and "pipe" it to webaudio API
// remote file must have CORS enabled if on another domain
//
// mostly from http://stackoverflow.com/questions/20475982/choppy-inaudible-playback-with-chunked-audio-through-web-audio-api
//
function play(url) {
var context = new (window.AudioContext || window.webkitAudioContext)();
@revolunet
revolunet / python-es6-comparison.md
Last active April 22, 2024 19:22
# Python VS JavaScript ES6 syntax comparison

Python VS ES6 syntax comparison

Python syntax here : 2.7 - online REPL

Javascript ES6 via Babel transpilation - online REPL

Imports

import math
@revolunet
revolunet / countries-FR.json
Last active April 16, 2024 14:15
Liste des pays en FR
{
"AF": "Afghanistan",
"ZA": "Afrique du Sud",
"AL": "Albanie",
"DZ": "Algérie",
"DE": "Allemagne",
"AD": "Andorre",
"AO": "Angola",
"AI": "Anguilla",
"AQ": "Antarctique",
@revolunet
revolunet / publicodes.schema.json
Last active February 29, 2024 12:57
publi.codes sample JSON-schema
{
"$schema": "https://json-schema.org/draft-07/schema",
"additionalProperties": {
"$ref": "#/definitions/mecanismes/valeur"
},
"definitions": {
"mecanismes": {
"variations": {
"title": "variations",
"markdownDescription": "Contient une liste de conditions (si) et leurs conséquences associées (alors), ainsi qu’un cas par défaut (sinon).\n\nPour la première condition vraie dans la liste, on retient la valeur qui lui est associée.\n\nSi aucune condition n’est vraie, alors ce mécanisme renvoie implicitement non.\n\nCe mécanisme peut aussi être utilisé au sein d’un autre mécanisme avec des attributs, tel que produit ou barème.\n\nDoc: https://publi.codes/docs/api/m%C3%A9canismes#variations",
@revolunet
revolunet / execution-api.js
Created October 4, 2015 02:19
gapps execution api example
//
// creds.json is a service account json key
//
// -> always getting "The caller does not have permission"
//
var script = google.script('v1');
var key = require('./creds.json');
var jwtClient = new google.auth.JWT(key.client_email, null, key.private_key, ['https://www.googleapis.com/auth/spreadsheets'], null);
@revolunet
revolunet / scalingo.schema.json
Created February 5, 2024 23:16
scalingo.json validation schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "scalingo.json schema https://doc.scalingo.com/platform/app/app-manifest",
"description": "Extracted from https://developers.scalingo.com/scalingo-json-schema/",
"type": "object",
"additionalProperties": false,
"properties": {
"$schema": { "type": "string" },
"name": {
"description": "Complete name of the project",
@revolunet
revolunet / lzw_encoder.js
Created February 25, 2011 14:55
LZW javascript compress/decompress
// LZW-compress a string
function lzw_encode(s) {
var dict = {};
var data = (s + "").split("");
var out = [];
var currChar;
var phrase = data[0];
var code = 256;
for (var i=1; i<data.length; i++) {
currChar=data[i];
@revolunet
revolunet / publicodes.yml
Created January 23, 2024 18:16
Economies si on arrête de fumer, en publicodes
#
# https://publi.codes/studio/r%C3%A9sultat#prix%20paquet%3A%20%0A%20%20valeur%3A%2012%0A%20%20unit%C3%A9%3A%20%E2%82%AC%0A%0Aconsommation%20par%20jour%3A%0A%20%20question%3A%20Combien%20de%20cigarettes%20fumez-vous%20par%20jour%20en%20moyenne%20%3F%0A%20%20valeur%3A%208%0A%0Aeconomies%20par%20jour%3A%0A%20%20valeur%3A%20consommation%20par%20jour%20*%20(prix%20paquet%20%2F%2020)%0A%20%20unit%C3%A9%3A%20%E2%82%AC%0A%0Aeconomies%20par%20an%3A%0A%20%20valeur%3A%20economies%20par%20jour%20*%20365%0A%20%20unit%C3%A9%3A%20%E2%82%AC%0A%0Acommentaire%3A%0A%20%20variations%3A%0A%20%20%20%20-%20si%3A%20economies%20par%20an%20%3E%201500%0A%20%20%20%20%20%20alors%3A%20%22'Vous%20pourriez%20vous%20offrir%20un%20beau%20v%C3%A9lo%20%C3%A9l%C3%A9ctrique.'%22%0A%20%20%20%20-%20si%3A%20economies%20par%20an%20%3E%201000%0A%20%20%20%20%20%20alors%3A%20%22'Ca%20fait%20un%20beau%20petit%20voyage%20en%20Italie.'%22%0A%20%20%20%20-%20si%3A%20economies%20par%20an%20%3E%20500%0A%20%20%20%20%20%20alors%3A%20%22'Ca%20fait%20un%20tr%C3%
@revolunet
revolunet / psql.md
Last active December 18, 2023 12:25
PSQL tips and tricks

Backups/Restore

dump

pg_dump --dbname "postgres://user:pass@host:port/db" \
  --clean --if-exists \
  --quote-all-identifiers \
  --format=custom \
  -f /backup.dump;
@revolunet
revolunet / verdaccio.md
Last active December 1, 2023 11:28
Verdaccio tips 👉 https://verdaccio.org

run with docker

create ~/verdaccio/conf/config.yaml from example then:

V_PATH=~/verdaccio; docker run -it --rm --name verdaccio \
  -p 4873:4873 \
  -v $V_PATH/conf:/verdaccio/conf \
  -v $V_PATH/storage:/verdaccio/storage \
 -v $V_PATH/plugins:/verdaccio/plugins \