Skip to content

Instantly share code, notes, and snippets.

View pelson's full-sized avatar

Phil Elson pelson

View GitHub Profile
@pradyunsg
pradyunsg / find-top-level-from-wheel-file.py
Last active December 4, 2023 13:15
Figuring out the top-level importable names from a wheel
"""Takes a .whl file and figures out the top-level importable names in that wheel.
Usage:
$ python find-top-level-from-wheel-file.py ./setuptools-65.4.1-py3-none-any.whl
['_distutils_hack', 'pkg_resources', 'setuptools']
Testing:
$ pytest find-top-level-from-wheel-file.py
...
@phizaz
phizaz / async.py
Last active September 19, 2024 23:54
Python turn sync functions to async (and async to sync)
import functools
def force_async(fn):
'''
turns a sync function to async function using threads
'''
from concurrent.futures import ThreadPoolExecutor
import asyncio
pool = ThreadPoolExecutor()
@ericdill
ericdill / render_env.py
Last active October 20, 2021 20:22
Render the dependency graph for your conda environment (needs graphviz!)
import json
import glob
import os
from os.path import join, basename
# install this with "conda install -c conda-forge python-graphviz"
import graphviz as gv
# path to your conda environment
path = os.environ.get('CONDA_PREFIX')
if path is None:
@mrocklin
mrocklin / trace.py
Created July 11, 2016 21:03 — forked from jcrist/trace.py
Dask Execution Tracer
import os
from dask.callbacks import Callback
from dask.dot import dot_graph
class Track(Callback):
def __init__(self, path='dasks'):
self.path = path
self.n = 0
@jcrist
jcrist / trace.py
Last active September 27, 2022 15:59
Dask Execution Tracer
import os
from dask.callbacks import Callback
from dask.dot import dot_graph
class Track(Callback):
def __init__(self, path='dasks', save_every=1):
self.path = path
self.save_every = save_every
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@CMCDragonkai
CMCDragonkai / http_streaming.md
Last active October 24, 2024 17:43
HTTP Streaming (or Chunked vs Store & Forward)

HTTP Streaming (or Chunked vs Store & Forward)

The standard way of understanding the HTTP protocol is via the request reply pattern. Each HTTP transaction consists of a finitely bounded HTTP request and a finitely bounded HTTP response.

However it's also possible for both parts of an HTTP 1.1 transaction to stream their possibly infinitely bounded data. The advantages is that the sender can send data that is beyond the sender's memory limit, and the receiver can act on

@dutc
dutc / implicit-self.py
Last active August 29, 2024 20:06
implicit self
#!/usr/bin/env python
from ctypes import c_void_p, c_char_p, c_long, c_int, c_size_t, py_object, \
Structure, POINTER, cdll
from opcode import HAVE_ARGUMENT, opmap
from itertools import imap, chain
from copy import deepcopy
from sysconfig import get_config_vars
from sys import version_info
@HeinrichHartmann
HeinrichHartmann / RPi_ADC8032.py
Created December 14, 2014 21:04
Raspbery Pi Analog Input with ADC0832
#!/usr/bin/env python
#
# Analog Input with ADC0832 chip
#
# Datasheet: http://www.ti.com/lit/ds/symlink/adc0838-n.pdf
# Part of SunFounder LCD StarterKit
# http://www.sunfounder.com/index.php?c=show&id=21&model=LCD%20Starter%20Kit
#
import time
@psmay
psmay / svg-to-fontforge-python.md
Created December 2, 2014 15:14
Notes on mass-importing SVG outlines into FontForge via Python

Notes on dumping SVG outlines into a FontForge file

Sources I've looked at:

I have a hunch that createMappedChar() doesn't work unless you've done loadNameList('glyphlist.txt') or loadNameList('aglfn.txt') (BSD-licensed Adobe glyph lists). An alternative seems to be to go by codepoint with createChar().