Skip to content

Instantly share code, notes, and snippets.

View nilium's full-sized avatar
internal screaming intensifies

Noel nilium

internal screaming intensifies
View GitHub Profile
nilium / _ep-preview
Last active November 12, 2023 23:41
Latest version of ep for fish
#!/usr/bin/env bash
lscmd=(ls -lh)
if command -v &>/dev/null tree; then
-I gists
-I vim
-I vendor
-I node_modules
-I venv
nilium / config.lua
Last active July 19, 2022 04:52
LunarVim config, similar to my personal vimrc
lvim is the global options object
After changing plugin config exit and reopen LunarVim, then run
:PackerInstall and :PackerCompile. Sometimes it's also necessary to delete
~/.config/lvim/plugin/packer_compiled.lua and run :PackerSync.
-- general

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

nilium /
Last active July 7, 2022 19:06
Initial attempt at personal fish configuration, including a port of 'ep'
set -gx PATH ~/bin ~/go/bin $PATH
function fish_user_key_bindings
bind \cz 'fg 2>/dev/null; commandline -f repaint'
set -g EP_PATH \
$HOME/src 3 \
$HOME/p 4
nilium /
Last active April 10, 2020 20:46
Possible bug in jq

Only occurs when multiplying a string with an interpolation containing a suffix (i.e., the "\n"). Doesn't matter what the suffix is, does not seem to result in any difference for how many bytes are taken from the start of the third duplication.

The third entry onward in a string multiplication is missing 16 bytes, which have been replaced with NULs.

If the interpolation is instead a prefix, nothing incorrect happens.

Using concatenation instead of interpolation also works correctly.

In the second case, if using . in the interpolation instead of tojson, corruption of the string content occurs. If multiplied by 6 or more, the corruption seems to be stable, but doesn't appear to have any rhyme or reason to the content of the 16 bytes.

nilium / cleanroom
Created January 10, 2020 23:28
Script to run a shell or command in a clean, temporary copy of a repository.
#!/usr/bin/env bash
# cleanroom: run a command or shell in a clean, temporary copy of a repository.
case "$1" in
cat <<'USAGE'
Usage: cleanroom [-h|-help|--help] [CMD...]
Execute a command in a clone of the current repository, made under
a temporary directory.
nilium / consul.diff
Created August 13, 2019 23:59
Diff of Consul v1.5.3 between versions of the same tag
v1 is the original v1.5.3 tag, v2 is the changed v1.5.3 tag.
diff -U2 -r v1/consul-1.5.3/vendor/ v2/consul-1.5.3/vendor/
--- v1/consul-1.5.3/vendor/ 2019-07-25 16:41:17.000000000 -0700
+++ v2/consul-1.5.3/vendor/ 2019-07-25 16:41:17.000000000 -0700
@@ -56,5 +56,5 @@
// companion .gitattributes file containing 'export-subst' in this same
// directory. See also
- gitVersion string = "v0.0.0-master+a42ded477c"
+ gitVersion string = "v0.0.0-master+a42ded477"
nilium / nomad-tweak
Created August 11, 2019 07:38
Bash script and jq module to make it easier to make small adjustments to Nomad jobs
#!/usr/bin/env bash
# Copyright Noel Cower 2019.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# Usage: nomad-tweak <job> [options...] <jq-script>
# Options:
# -A, --apply
nilium / withtemp
Last active August 10, 2019 19:13
Script to generate an eval-able line to create a temporary file, assign it to a variable, and remove it upon exit.
# Usage: eval "$(withtemp [varname [mktempargs]])
# If varname is given, a tempfile is generated, its path assigned to the
# variable $varname, and deleted upon exit. Otherwise, no varname
# becomes 'tempfile' and no arguments are passed to mktemp. Varname is
# not exported or local, but you may evaluate using either
# $ eval "local $(withtemp ...)"
nilium / twitter.json
Created July 23, 2019 02:17
Twitter init-data
"keyboardShortcuts": [
"name": "Actions",
"description": "Shortcuts for common actions.",
"shortcuts": [
"keys": [