Skip to content

Instantly share code, notes, and snippets.

View jab's full-sized avatar

Joshua Bronson jab

  • 05:24 (UTC -04:00)
View GitHub Profile
@jab
jab / flake-direnv.md
Created February 19, 2023 18:26 — forked from inscapist/flake-direnv.md
Nix Flakes and Direnv on Mac OSX (Catalina)

Development environment with Nix Flakes and Direnv

This document is targeted at those who seek to build reproducible dev environment across machines, OS, and time.

It maybe easier for remote teams to work together and not spending hours each person setting up asdf/pyenv/rbenv, LSP servers, linters, runtime/libs. Nix is probably the closest thing to Docker in terms of development environment.

Flake is used here because it provides hermetic build, with absolutely no reliance on system environment (be it Arch/Catalina/Mojave). Also it freezes dependencies in flake.lock so builds are reproducible.

This gist provides the setup to develop Java/Clojure/Python applications on Nix. But it can be easily adapted to ruby, nodejs, haskell.

@jab
jab / ait.py
Created September 21, 2022 02:16
aiter() / anext() await-free Python implementations
"""
❯ python3 ait.py
3
2
1
blastoff aiter!
3
2
1
blastoff anext!
@jab
jab / test.svg
Last active July 11, 2021 15:55
dark-mode-aware-svg-demo
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jab
jab / LICENSE.md
Created April 18, 2021 19:20 — forked from joshbode/LICENSE.md
YAML Loader with include constructor (Python 3)

MIT License

Copyright (c) 2018 Josh Bode

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 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

# Ideally, we would manage async access to stdin/stdout/stderr *without*
# setting them to non-blocking mode, because that can break other processes.
# (See https://github.com/python-trio/trio/issues/174 for much more detail.)
# Of course we can call read/write in a separate thread, but then we lose
# cancellation support.
# This file demonstrates a weird hack to make blocking read/write cancellable,
# and thus at least theoretically possible to integrate into Trio as ordinary
# first-class operations.
@jab
jab / indent.py
Created September 28, 2020 18:46 — forked from xhjkl/indent.py
Indentation context manager
import sys
import functools
import contextlib
@contextlib.contextmanager
def indented_output(indent=4, space=chr(32)):
""" Precede each carriage return with some quantity of spaces.
While nesting `indented_output` contexts, be prepared
@jab
jab / json_namedtuple.py
Created January 29, 2020 00:04 — forked from Daenyth/json_namedtuple.py
Parse json via python NamedTuple
import hashlib
import json
from decimal import Decimal
from typing import Any, Dict, Type
from typing_inspect import get_args, get_generic_bases, is_generic_type, is_union_type # type: ignore
Json = Dict[str, Any]
@jab
jab / pool.py
Created December 6, 2018 01:53 — forked from ziirish/pool.py
trio Pool primitive
class Pool:
def __init__(self, pool_size):
self._size = pool_size
self.send_channel, self.receive_channel = trio.open_memory_channel(pool_size)
@jab
jab / cljs.md
Created November 25, 2018 17:51 — forked from mfikes/cljs.md
cljs command

If you wan't a cljs that acts like clj, but for ClojureScript, there are a few minor changes you can make:

First, add the following entry to ~/.clojure/deps.edn under the :deps key:

org.clojure/clojurescript {:mvn/version "1.10.439"}

Then make copies of clj and clojure named cljs and clojurescript, and put those copies on your path.

Update

Just use https://github.com/ripeworks/iro which gets the challenge below right!

Mac Color Picking Done Right

Picking a Color on Mac is hard. Mainly due to the fact that several applications floating around the web ( AppStore and independant ), grab the color "incorrectly".

Why incorrectly?