Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Tony Narlock tony

💭
I may be slow to respond.
View GitHub Profile
View sphinx-toctree-signature.py
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
View sphinx-toctree-signature.py
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
View dataclasses-vs-typeddict.py
import dis
from dataclasses import dataclass
from typing import TypedDict
@dataclass
class MyDataclass:
field1: str
field2: int
class MyTypedDict:
@mgaitan
mgaitan / autofactory.py
Last active January 19, 2023 18:20
Automatically define factory boy recipes for dataclasses by inspecting the type annotations
View autofactory.py
## See https://github.com/FactoryBoy/factory_boy/issues/836
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
sciyoshi / esbuild-relay.js
Created February 19, 2021 16:34
Esbuild plugin for compiling relay queries
View esbuild-relay.js
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");
View doctest-myst.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View Electron on WSL2.md

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:

@olets
olets / zsh-plugin-manager-plugin-installation-procedures.md
Last active March 29, 2023 08:57
zsh plugin manager cross-reference
View zsh-plugin-manager-plugin-installation-procedures.md

Instructions for installing zsh plugins, for a variety of plugin managers

  • antibody: Add <owner>/<repo> to your plugins file. If you use static loading update the sh.

  • Antigen: Add antigen bundle <owner>/<repo> to your .zshrc.

  • Oh-My-Zsh:

    • Clone to OMZ's plugins' directory:
@difosfor
difosfor / my-element.ts
Last active January 23, 2023 13:11
Typed LitElement events
View my-element.ts
import { customElement, LitElement } from 'lit-element';
type UnpackCustomEvent<T> = T extends CustomEvent<infer U> ? U : never;
// Define custom event types and details here
interface CustomEventMap {
/**
* Dispatched when an error occurs.
*/
'my-error': CustomEvent<{ error: Error }>;