Skip to content

Instantly share code, notes, and snippets.

View JeanOlivier's full-sized avatar

Jean Olivier Simoneau JeanOlivier

View GitHub Profile
@JeanOlivier
JeanOlivier / par2protect.py
Created March 16, 2016 15:17 — forked from ynsta/par2protect.py
Protect files in each directory recursively using par2. It repairs and updates with par2, if only adler32 sum of files does not match.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import re
import zlib
import ctypes
import subprocess
DESCRIPTION = 'Protect files in directories recursively with par2.'
@JeanOlivier
JeanOlivier / functionCache.py
Created June 28, 2017 13:28
A function to cache the result of a function call. For long calculations/data loading.
import os
from numpy import savez_compressed, load
def functionCache(fn, fct, *args, **kwargs):
"""
force_recalc = True -> self-descriptive
"""
force_recalc = kwargs.pop('force_recalc', False)
if os.path.isfile(fn) and not force_recalc:
@JeanOlivier
JeanOlivier / makefile
Created June 28, 2017 15:05
A makefile to submit an article to arxiv/aps with figures in eps format.
filename=article
.PHONY: all first last bibtex ps pdf clean readdvi readps readpdf
MK = latex
BK = bibtex
PS = dvips
PDF = dvipdf
RM = rm
JOURNAL = arXiv
@JeanOlivier
JeanOlivier / keymap_snippet.c
Created July 7, 2017 20:30
keymap.c snippet: QMK LGUI hold as F(1).
const int GUILAY = 1;
typedef struct {
bool layer_toggle;
bool sticky;
} td_ta_state_t;
static void ang_tap_dance_ta_finished (qk_tap_dance_state_t *state, void *user_data) {
td_ta_state_t *td_ta = (td_ta_state_t *) user_data;
@JeanOlivier
JeanOlivier / SpawnSimpleHTTPAuthServer.sh
Created February 20, 2018 16:13
Creates a HTTPS server in the current directory with randomly generated username/password. Arguments are : 1- Username, 2- Number of random characters appended to username, 3- length of password, 4- Port number
# SimpleHTTPAuthServer installed via:
# pip install git+git://github.com/tianhuil/SimpleHTTPAuthServer.git@master
function SpawnSimpleHttpAuthServer()
{
name="${1:-username}-$(< /dev/urandom tr -dc A-Z-a-z-0-9 | head -c${2:-4};echo;)"
pass=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${3:-32};echo;)
echo "Username is: $name"
echo "Password is: $pass"
python -m SimpleHTTPAuthServer --https ${4:-8000} $name:$pass
}
@JeanOlivier
JeanOlivier / niceDelim.tex
Created April 28, 2020 16:22
LaTeX Delimiters with automatic sizing that's easily overridable.
\usepackage{xstring}
% Parenthèses communes via commandes avec taille ajustable en argument optionnel
% La taille par défaut est automatique
%
% Tester ainsi:
% \p{123}
% \p[]{123}
% \p[big]{123}
% \pc[Big]{123}
% Multiples citations avec commentaires séparées par des ;
% Utilisation: Mettres les réfs à la suite entre {<refkey>} et mettre un [<commentaire>] avant celles dont on veut un commentaire
% Exemple, la commande
% \cites[p.1]{ref1}{ref2}[chap.3]{ref3}
% donnera quelquechose du style:
% [<label1>, p.1 ; <label2> ; <label3>, chap.3]
\usepackage{xspace}
\makeatletter
\newcommand{\citecomment}[2][]{\citen{#2}#1\citevar}
@JeanOlivier
JeanOlivier / nlfit.py
Created July 21, 2020 01:17
Fit many functions/data at once with individual and shared parameters
#!/bin/python
# -*- coding: utf-8 -*-
# from pylab import * # Might be required by the loading script
from numpy import array, sqrt, diag, concatenate, mean, size, ndarray, iscomplex
from scipy.optimize import leastsq
@JeanOlivier
JeanOlivier / ma_figure.py
Created September 9, 2020 22:21
Exemple figures python compilées avec math latex et packages personels
#!/usr/bin/env python
# -*- coding: utf-8 -*-
try:
__ISINTERACTIVE__ = __IPYTHON__
except:
__ISINTERACTIVE__ = False
print "IS NOT INTERACTIVE"
@JeanOlivier
JeanOlivier / private_fork.md
Created March 19, 2021 18:24 — forked from 0xjac/private_fork.md
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare git@github.com:usi-systems/easytrace.git