Skip to content

Instantly share code, notes, and snippets.

@rossant
rossant / parallel_write.py
Created August 30, 2019 15:04
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_):
@daeh
daeh / Papers3_to_Zotero.py
Last active September 6, 2024 18:58
Import Papers 3 library into Zotero
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Script to facilitate the import of a Readcube Papers 3 library into Zotero
__Purpose of this script__
If you export your Readcube (Mekentosj) Papers3 library as a BibTeX file, the file paths to the PDFs are not formatted
correctly for Zotero to import them.
@rossant
rossant / glwidget.py
Created November 26, 2018 17:14
Minimal modern PyQt5, OpenGL, QOpenGLWindow working example
#!/usr/bin/env python3
"""
Code from http://www.labri.fr/perso/nrougier/python-opengl/#the-hard-way
"""
import ctypes
import logging
@rossant
rossant / latex_to_image.py
Created February 12, 2018 13:46
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
@rootkea
rootkea / spectre.c
Created January 4, 2018 15:36
PoC from Spectre Attacks: Exploiting Speculative Execution (https://spectreattack.com/spectre.pdf)
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif
@rossant
rossant / installer.md
Last active March 26, 2016 18:06
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:
  • mypackage.sh: for Unix systems
@subfuzion
subfuzion / curl.md
Last active April 24, 2025 13:48
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@rossant
rossant / vispy-text
Last active February 12, 2019 14:17
vispy text
We couldn’t find that file to show.
@rossant
rossant / _template.ott
Last active March 25, 2024 12:03
Convert from Markdown to OpenOffice for Linux Magazine
@rossant
rossant / benchmark.ipynb
Last active July 12, 2023 09:34
Quick HDF5 benchmark
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.