Skip to content

Instantly share code, notes, and snippets.

View xoolive's full-sized avatar
🏃‍♂️

Xavier Olive xoolive

🏃‍♂️
View GitHub Profile
@xoolive
xoolive / pass.py
Created December 14, 2021 21:12
Read the contents of a covid pass
import json
import sys
import zlib
import base45
import cbor2
import cv2
from cose.messages import CoseMessage
# initialize the cv2 QRCode detector
[
{
"date": "2021-01-01T09:11:52+00:00",
"category": "unknown",
"hour": "2021-01-01T09:00:00+00:00"
},
{
"date": "2021-01-01T09:17:40+00:00",
"category": "good",
"hour": "2021-01-01T09:00:00+00:00"
@xoolive
xoolive / total_size.py
Created March 9, 2021 14:23
Size of structure in Python
from sys import getsizeof, stderr
from itertools import chain
from collections import deque
try:
from reprlib import repr
except ImportError:
pass
def total_size(o, handlers={}, verbose=False):
""" Returns the approximate memory footprint an object and all of its contents.
@xoolive
xoolive / parse_index.py
Last active February 23, 2021 05:39
Explore \index{} elements in your LaTeX aborescence
import sys
from collections import defaultdict
from itertools import repeat
from pathlib import Path
from typing import DefaultDict, Iterator, List, Optional, Tuple
import click
import regex as re
from rich import print

Keybase proof

I hereby claim:

  • I am xoolive on github.
  • I am xoolive (https://keybase.io/xoolive) on keybase.
  • I have a public key whose fingerprint is 481C FB6C A003 AC28 A707 9CC2 F860 C160 A6B9 B1CD

To claim this, I am signing this object:

@xoolive
xoolive / tufte-soul.sty
Created March 2, 2016 09:40
Conflict in soul with Tufte package
\ifxetex
\newcommand{\textls}[2][5]{%
\begingroup\addfontfeatures{LetterSpace=#1}#2\endgroup
}
\renewcommand{\allcapsspacing}[1]{\textls[15]{#1}}
\renewcommand{\smallcapsspacing}[1]{\textls[10]{#1}}
\renewcommand{\allcaps}[1]{\textls[15]{\MakeTextUppercase{#1}}}
\renewcommand{\smallcaps}[1]{\smallcapsspacing{\scshape\MakeTextLowercase{#1}}}
\renewcommand{\textsc}[1]{\smallcapsspacing{\textsmallcaps{#1}}}
\fi
@xoolive
xoolive / test_int64.cpp
Created February 18, 2016 23:11
Check int64_t size with your compiler
#include <iostream>
#include <cstdint>
template <typename T>
bool is_int64() { return false; }
template <>
bool is_int64<int64_t>() { return true; }
int main()
import facile
circuit = [facile.variable(0, Nv) for i in range(Nvmax + 1)]
facile.constraint(circuit[0] == 1)
for j in range(1, Nvmax + 1):
for i in range(j):
facile.constraint((circuit[j] == 0) | (circuit[i] != 0))
@xoolive
xoolive / grades.r
Last active January 30, 2016 15:09
Distribution of grades in a student group
grades <- read.csv("grades.csv")
# I like to have first name, last name, grade
# Adapt the column number to your needs
x <- as.numeric(as.character(grades[,3]))
# Export to png?
# png("grades.png")
# Adapt the breaks to your grades
hist(x, col="lightgreen", freq=FALSE, breaks=seq(10,20,by=.5), family="Ubuntu") # I trashed Arial
# Play with the adjust (default: 1) parameter in density
lines(density(x[!is.na(x)]), col = "red", lwd = 2)
@xoolive
xoolive / orbit.tex
Created December 28, 2014 20:36
Description des 6 paramètres orbitaux
\documentclass[border=10pt,varwidth]{standalone}
\usepackage[francais]{babel}
\usepackage[dvipsnames]{xcolor}
\usepackage{fontspec}
\usepackage{unicode-math}
\usepackage{tikz}
\usetikzlibrary{intersections}