Skip to content

Instantly share code, notes, and snippets.

View georgevreilly's full-sized avatar

George V. Reilly georgevreilly

View GitHub Profile
@georgevreilly
georgevreilly / deps_topo.py
Created December 20, 2024 22:39
Compute topological dependency graphs for a shared library. See https://www.georgevreilly.com/blog/2024/12/16/PatchingAndSplittingPythonWheels.html
#!/usr/bin/env python3
"""
Produce topological sorted graphs of shared object library dependencies.
"""
from __future__ import annotations
import json
import os
@georgevreilly
georgevreilly / deterministic_shuffle.py
Last active October 27, 2024 07:27
Stable shuffle of a sequence
#!/usr/bin/env python3
from __future__ import annotations
import argparse
import random
from functools import reduce
from typing import Any
@georgevreilly
georgevreilly / vowels.md
Created February 12, 2024 10:26
Alphabetical vowels found in /usr/share/dict/words on macOS Sonoma 14.2.1

Words with all five vowels in forward and backward order

Using /usr/share/dict/words on macOS Sonoma 14.2.1

Forward order, aeiou

180 results

$ grep -i '.*a.*e.*i.*o.*u.*' /usr/share/dict/words
@georgevreilly
georgevreilly / cuda-deps-cannot-be-preloaded-under-bazel.md
Created January 12, 2024 12:48
CUDA deps cannot be preloaded under Bazel

CUDA deps cannot be preloaded under Bazel

🐛 Describe the bug

If Torch 2.1.0 is used as a dependency with Bazel and rules_python, _preload_cuda_deps fails with OSError: libcufft.so.11: cannot open shared object file: No such file or directory.

Torch 2.1 works fine if you install it and its CUDA dependencies into a single site-packages (e.g., in a virtualenv). It doesn't work with Bazel, as it installs each dependency into its own directory tree, which is appended to PYTHONPATH.

$ bazel test //...
#!/usr/bin/env python3
import random
def lcg(a, c, m):
def _lcg(a, c, m):
x = random.randint(0, m-1)
for _ in range(m):
yield x
@georgevreilly
georgevreilly / Makefile
Created October 9, 2021 19:30
`pyenv install 3.10.0` fails with `Makefile:222: *** missing separator`
# Generated automatically from Makefile.pre by makesetup.
# Top-level Makefile for Python
#
# As distributed, this file is called Makefile.pre.in; it is processed
# into the real Makefile by running the script ./configure, which
# replaces things like @spam@ with values appropriate for your system.
# This means that if you edit Makefile, your changes get lost the next
# time you run the configure script. Ideally, you can do:
#
# ./configure
@georgevreilly
georgevreilly / blob2jsonlines.py
Last active February 15, 2018 19:59
Convert large JSON blob into JSONLines. Handles corrupt records. The blob must be a JSON array, containing flat (non-nested) objects.
#!/usr/bin/env python
from __future__ import unicode_literals, absolute_import, print_function
import argparse
import codecs
from collections import OrderedDict
import json
import os
import re

Keybase proof

I hereby claim:

  • I am georgevreilly on github.
  • I am georgevreilly (https://keybase.io/georgevreilly) on keybase.
  • I have a public key ASBIOJqGGJhV02brqZCUoFOq_byUSWSmJyjrFXJ9YEscVgo

To claim this, I am signing this object:

@georgevreilly
georgevreilly / afterexec_queryparams.html
Last active September 18, 2015 19:26
SQLTap sometimes fails to capture query parameters.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="sqltap profile">
<meta name="author" content="inconshreveable">
<title>SQLTap Profiling Report</title>
@georgevreilly
georgevreilly / mysql-python-virtualenv.bat
Created January 15, 2014 21:24
Copy MySQL-Python into a Windows virtualenv.
@REM adapted from http://stackoverflow.com/a/20092578
if ["%VIRTUAL_ENV%"]==[""] echo Must run under a Virtualenv && goto :error
set SRCDIR=c:\Python27\Lib\site-packages
pushd "%VIRTUAL_ENV%\Lib\site-packages"
xcopy /ydfsi %SRCDIR%\MySQLdb MySQLdb
xcopy /ydfsi %SRCDIR%\_mysql* .
xcopy /ydfsi %SRCDIR%\MySQL_python-1.2.3-py2.7.egg-info MySQL_python-1.2.3-py2.7.egg-info
popd
goto :eof