Skip to content

Instantly share code, notes, and snippets.

Cyrille Rossant rossant

Block or report user

Report or block rossant

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
rossant /
Created Jan 6, 2020
Custom LRU cache implementation that gives access to the underlying cache dictionary.
def lru_cache(maxsize=0):
"""Custom LRU cache implementation that gives access to the underlying cache dictionary. [better to used functools one if you don't need this]"""
def wrap(f):
cache = {}
last_used = []
def wrapped(*args):
if args in cache:
# HIT.
# Update the last_used list.
rossant /
Last active Sep 24, 2019
ONE light API proposal
from onelib import one
Different ONE backends are available, HTTP, figshare, etc.
One has to implement the following functions to create a new ONE backend:
* list_all_files(): return a list of relative file paths for ALL available files.
* search(...): return a list of dset_ids (by default, a dset_id is a relative file path).
The default implementation calls list_all_files(), and performs the search directly on that list.
rossant /
Created Aug 30, 2019
Write a NumPy array in parallel from multiple CPUs/processes, using shared memory. No copy/serialization involved. Pure Python/NumPy.
"""Write a NumPy array in parallel from multiple CPUs/processes, using shared memory."""
from contextlib import closing
import multiprocessing as mp
import os
import numpy as np
def _init(shared_arr_):
import os
import requests
import shutil
def _dl(url, path):
print("download", url, "to", path)
response = requests.get(url, stream=True)
if response.status_code != 200:
rossant /
Created Nov 26, 2018
Minimal modern PyQt5, OpenGL, QOpenGLWindow working example
#!/usr/bin/env python3
Code from
import ctypes
import logging
rossant /
Created Feb 12, 2018
Convert a LaTeX equation into EPS and PNG with Python
import os
import os.path as op
from pathlib import Path
import shutil
import subprocess
import tempfile
from IPython.lib.latextools import genelatex
rossant / code_postal.vba
Last active Dec 2, 2016
VBA code to find French cities associated to a given postal code
View code_postal.vba
Function collectionToArray(c As Collection) As Variant()
Dim a() As Variant: ReDim a(0 To c.Count - 1)
Dim i As Integer
For i = 1 To c.Count
a(i - 1) = c.Item(i)
collectionToArray = a
End Function
rossant /
Created Mar 28, 2016
Install latest .deb pandoc, using the GitHub release page -- useful on CI systems
PANDOCPAGE="$(wget $URL -q -O -)"
DEBURL="$(echo $PANDOCPAGE | grep -oP '"([^"]+.deb)"')"
wget $URL -O pandoc.deb
sudo dpkg -i pandoc.deb
rossant /
Last active Mar 26, 2016
Build cross-plaform graphical installers for Python software

Distributing Python software to non-technical users is too hard. We need to make it simpler.

I'm imagining a tool based on conda.

Ideally I'd like to have something like this:

  • I write an environment.yml file with the conda/pip dependencies for my software
  • I write an installer.yml file that describes my installer: package name, paths to logo/images, icon shortcuts for binaries, etc.
  • I type build-installer and a few files are created:
    • for Unix systems
We couldn’t find that file to show.
You can’t perform that action at this time.