Skip to content

Instantly share code, notes, and snippets.

View tony's full-sized avatar
I may be slow to respond.

Tony Narlock tony

I may be slow to respond.
View GitHub Profile
#!/usr/bin/env python
import multiprocessing
import random
import time
class Logger:
def __init__(self, num_lines, last_output_per_process, terminal_lock):
self.num_lines = num_lines
from typing import List, TypeVar
from docutils import nodes
from docutils.nodes import Element
from sphinx import addnodes
from sphinx.application import Sphinx
from sphinx.environment.adapters.toctree import TocTree
import sphinx.environment.collectors.toctree as toctree_collector
from sphinx.transforms import SphinxContentsFilter
from sphinx.transforms import SphinxTransform
import sphinx.environment.collectors.toctree as toctree_collector
from sphinx import addnodes
from docutils import nodes
from typing import Any, Dict, List, Set, Tuple, Type, TypeVar, cast
from docutils import nodes
from docutils.nodes import Element, Node
tommyip /
Last active February 23, 2024 20:00 - Automatically activate/deactivate virtualenv in fish shell
# Based on
# Changes:
# * Instead of overriding cd, we detect directory change. This allows the script to work
# for other means of cd, such as z.
# * Update syntax to work with new versions of fish.
# * Handle virtualenvs that are not located in the root of a git directory.
function __auto_source_venv --on-variable PWD --description "Activate/Deactivate virtualenv on directory change"
status --is-command-substitution; and return
import dis
from dataclasses import dataclass
from typing import TypedDict
class MyDataclass:
field1: str
field2: int
class MyTypedDict:
mgaitan /
Last active December 9, 2023 16:16
Automatically define factory boy recipes for dataclasses by inspecting the type annotations
## See
import inspect
from typing import List, get_args, get_origin
import factory
import factory.fuzzy
from dataclasses import dataclass, Field, MISSING, is_dataclass
from enum import Enum
from datetime import date, datetime
from decimal import Decimal
sciyoshi / esbuild-relay.js
Created February 19, 2021 16:34
Esbuild plugin for compiling relay queries
import { promises } from "fs";
import crypto from "crypto";
import path from "path";
import { print, parse } from "graphql";
const plugin = {
name: "relay",
setup: build => {
build.onLoad({ filter: /\.tsx$/, namespace: "" }, async args => {
let contents = await promises.readFile(args.path, "utf8");
zh4n7wm /
Last active July 12, 2023 21:27
AWS CloudFront generate signed urls and cookies with Python and Golang
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Electron is tricky to get set up on Windows Subsystem for Linux, but it can work!

Four things needed overall:

  1. you need WSL2, not WSL1
  2. you need node, of course, and that part isn't so bad
  3. you need to apt install several dependencies
  4. you need an X Server so it can display the electron GUI over in Windows-land

Setup instructions, in order: