Skip to content

Instantly share code, notes, and snippets.

View lrq3000's full-sized avatar
🎵

Stephen Karl Larroque lrq3000

🎵
View GitHub Profile
@lrq3000
lrq3000 / pylistmodules.py
Last active September 17, 2023 19:27
List recursively all imports of modules along with versions done from your Python application. Tested on Python 2.7. No dependencies except standard Python libs.
#!/usr/bin/env python
# encoding: utf-8
# Copyright (C) 2001-2007 Martin Blais. All Rights Reserved
# Copyright (C) 2010 Bear http://code-bear.com/bearlog/
# Copyright (C) 2013 lrq3000
# Excerpt from SnakeFood to recursively list all imports of modules using AST parsing
# Additions to print the versions of each module if available
@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 / plwatch.sh
Created May 2, 2013 13:05
A simple bash script to watch packets loss using ping on Unix/Linux
#!/bin/bash
# Packets Loss Watch
# Simple SHELL script for Linux and UNIX system monitoring with
# ping command
#
# Copyright (c) 2006 nixCraft project <http://www.cyberciti.biz/fb/>
# Copyleft 2013 Stephen Larroque
# This script is licensed under GNU GPL version 2.0 or above
#
# This script was inspired by a nixCraft script http://www.cyberciti.biz/tips/simple-linux-and-unix-system-monitoring-with-ping-command-and-scripts.html
@lrq3000
lrq3000 / neural-network.nlogo
Last active November 17, 2021 01:06
Efficient n-layers neural network implementation in NetLogo, with some useful matrix extended functions in Octave-style (like matrix:slice and matrix:max)
@lrq3000
lrq3000 / QVMDisas
Last active October 17, 2021 22:10
QVMDisas v0.3 Python version (older than the Go version), author Macpunk
#!/usr/bin/env python
# encoding: utf-8
"""
QVMDisas.py
Created by Macpunk on 2009-09-20.
Updated by GrosBedo on 2010-04-12
Copyright (c) 2009 Dalton M. Cummings. All rights reserved.
CHANGELOG
@lrq3000
lrq3000 / pylistmodules-modulefinder.py
Last active October 17, 2021 22:10
A simple example to list modules imported in your Python script using ModuleFinder (standard Python module).
from modulefinder import ModuleFinder
finder = ModuleFinder()
finder.run_script('yourscript.py')
moduleslist = {}
for name, mod in finder.modules.iteritems():
filename = mod.__file__
if filename is None:
continue
@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 / 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 / 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