Skip to content

Instantly share code, notes, and snippets.

View lrq3000's full-sized avatar
🎵

Stephen Karl Larroque lrq3000

🎵
View GitHub Profile
@lrq3000
lrq3000 / rapunzel_moviepy.py
Created May 1, 2023 21:22 — forked from Zulko/rapunzel_moviepy.py
Tangled + MoviePy
"""
This creates the following GIF, where the text appears to be "embedded"
in the video and "disappears" behind rapunzel.
http://i.imgur.com/gxEHfLX.gif
"""
from moviepy.editor import *
import numpy as np
import skimage.morphology as skm
@lrq3000
lrq3000 / CHANGELOG.md
Last active January 27, 2020 05:52
tqdm changelog (via github-changelog-generator)
@lrq3000
lrq3000 / win_subprocess.py
Created January 1, 2019 15:04 — forked from vaab/win_subprocess.py
Fixing python 2.7 windows unicode issue with ``subprocess.Popen``.
## issue: https://bugs.python.org/issue19264
import ctypes
import subprocess
import _subprocess
from ctypes import byref, windll, c_char_p, c_wchar_p, c_void_p, \
Structure, sizeof, c_wchar, WinError
from ctypes.wintypes import BYTE, WORD, LPWSTR, BOOL, DWORD, LPVOID, \
HANDLE
import os
import argparse
import nibabel as nib
def build_argparser():
DESCRIPTION = "Convert tractograms (TRK -> TCK)."
p = argparse.ArgumentParser(description=DESCRIPTION)
p.add_argument('tractograms', metavar='bundle', nargs="+", help='list of tractograms.')
p.add_argument('-f', '--force', action="store_true", help='overwrite existing output files.')
@lrq3000
lrq3000 / flattened_nested_dict.py
Last active October 17, 2021 22:10
Flattened nested dict, all items are settable and gettable through ['item1']['item2'] standard form or ['item1/item2'] internal form. This allows to replace the internal dict with any on-disk storage system like a shelve's shelf (great for huge nested dicts that cannot fit into memory). Main limitation: an entry can be both a singleton and a nes…
#!/usr/bin/env python
#
# Flattened nested dict
# Copyright (C) 2017 Larroque Stephen
#
# Licensed under the MIT License (MIT)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
@lrq3000
lrq3000 / PDF-Testing.md
Created February 17, 2017 13:33 — forked from tiarno/PDF-Testing.md
PDF Checking

PDF Testing Gist

These two files, pdf_linkchecker.py and pdf_fontchecker.py are code examples to go along with a blog article: http://reachtim.com/articles/PDF-Testing.html

See the article for details on how to test your PDFs for broken internal and external links and for unembedded fonts.

import os
import math
import time
import numpy
import pandas
import random
import matplotlib
import numpy.random as nrand
import matplotlib.pylab as plt
from sklearn.preprocessing import normalize
@lrq3000
lrq3000 / AntNeighbourhoodFunction.py
Created August 6, 2016 12:06 — forked from StuartGordonReid/AntNeighbourhoodFunction.py
Ant Colony Neighbourhood Function
def get_probability(self, d, y, x, n, c):
"""
This gets the probability of drop / pickup for any given Datum, d
:param d: the datum
:param x: the x location of the datum / ant carrying datum
:param y: the y location of the datum / ant carrying datum
:param n: the size of the neighbourhood function
:param c: constant for convergence control
:return: the probability of
"""
@lrq3000
lrq3000 / diss.py
Last active November 11, 2020 19:05
Recursive Python bytecode disassembler
import dis
import types
def getFuncByName(fname):
possibles = globals().copy()
possibles.update(locals())
f = possibles.get(fname)
if f:
return f
else:
@lrq3000
lrq3000 / zip-import.php
Created December 6, 2014 19:12
Quickly coded zip importer in PHP with multiple methods, including one with chunking and auto-reloading for webhosts with agressive limits
<?php // Import a zip file and extract it
$custom_max_time = 10;
$custom_wait_time = 45;
$random_wait_time = 5; // plus or minus this value. Set to 0 or false to disable.
$time_start = time();
$max_time = ini_get("max_execution_time");
$wait_time = 5;
if (!empty($custom_max_time) and $custom_max_time > 0 and $custom_max_time < $max_time) $max_time = $custom_max_time;