Skip to content

Instantly share code, notes, and snippets.

View m-bartlett's full-sized avatar
⛓️

M B m-bartlett

⛓️
View GitHub Profile
@m-bartlett
m-bartlett / automatic-local-git-mirror-how-to.md
Last active June 26, 2021 06:28
How to configure a local-network machine that permits SSH access to automatically create git repos if it receives a `git push`.

Easy and Automatic Local Area Network Git Mirroring via SSH

Mirroring Remote Origin

A git user may add or modify a remote in their repository via the git remote subcommand. Most commonly (e.g. in the case the user has cloned from a popular git service such as GitLab or GitHub) git repositories have a remote named origin which is the default remote operated on. We can add extra URLs that point to other servers hosting a copy of the repository via git remote set-url --add origin <url>.

Alternatively, one can also manually edit .git/config in the root of the repository. An example of what may be in the config regarding the remote origin is

[remote "origin"]
  url = [email protected]:<user>/<repo_name>.git
  fetch = +refs/heads/*:refs/remotes/origin/*
@m-bartlett
m-bartlett / braille.py
Last active August 4, 2021 03:51
braille animation from binary arrays using numpy
#!/usr/bin/env python3
import numpy as np
FRAME_WIDTH = 2
brailles = np.uint8(
[
[1,1], [1,0], [1,1], [1,1], [1,1], [1,1], [1,1], [1,1], [0,1], [1,1], [0,1], [1,1], [0,0], [1,1], [0,0], [1,1], [0,0], [0,1], [0,0], [0,1], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [1,0], [0,0], [1,0], [0,0], [1,1], [0,0], [1,1], [0,0], [1,1], [1,0],
[1,0], [0,0], [1,0], [0,0], [0,0], [0,0], [0,0], [0,1], [0,0], [0,1], [0,0], [0,1], [0,0], [0,1], [0,0], [0,1], [0,0], [0,1], [0,0], [0,1], [0,0], [0,1], [0,0], [0,1], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [1,0], [0,0], [1,0], [0,0], [1,0], [0,0], [1,0], [0,0], [1,0], [0,0], [1,0], [0,0], [1,0], [0,0],
[0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,1], [0,0], [0,1], [0,0], [0,1], [0,0], [0,1], [0,0], [0,1
@m-bartlett
m-bartlett / full-disk-encryption-arch-uefi.md
Last active November 9, 2021 04:32 — forked from pjsawicki/full-disk-encryption-arch-uefi.md
Arch Linux Full-Disk Encryption Installation Guide [Encrypted Boot, UEFI, NVMe, Evil Maid]

Arch Linux Full-Disk Encryption Installation Guide

This guide provides instructions for an Arch Linux installation featuring full-disk encryption via LVM on LUKS and an encrypted boot partition (GRUB) for UEFI systems.

Following the main installation are further instructions to harden against Evil Maid attacks via UEFI Secure Boot custom key enrollment and self-signed kernel and bootloader.

Preface

You will find most of this information pulled from the Arch Wiki and other resources linked thereof.

Note: The system was installed on an NVMe SSD, substitute /dev/nvme0nX with /dev/sdX or your device as needed.

@m-bartlett
m-bartlett / elk_power_no_threshold.ino
Created November 20, 2021 02:45
Elk NeoPixel Spectrum Power Visualizer with Spectrum Shield
//For spectrum analyzer shield, these three pins are used.
//You can move pinds 4 and 5, but you must cut the trace on the shield and re-route from the 2 jumpers.
#define RESET 5
#define STROBE 4
#define BUTTON_1 8
#define BUTTON_2 9
#include <Adafruit_NeoPixel.h> //Library to simplify interacting with the LED strip
#ifdef __AVR__
#include <avr/power.h> //Includes the library for power reduction registers if your chip supports them.
#endif //More info: http://www.nongnu.org/avr-libc/user-manual/group__avr__power.htlm
#!/bin/bash
# Prevent the wine to add mime file association.
# Implements https://askubuntu.com/questions/323437/how-to-prevent-wine-from-adding-file-associations
set -o xtrace
rm -f ~/.local/share/mime/packages/x-wine*
rm -f ~/.local/share/applications/wine-extension*
rm -f ~/.local/share/icons/hicolor/*/*/application-x-wine-extension*
rm -f ~/.local/share/mime/application/x-wine-extension*
@m-bartlett
m-bartlett / README.md
Last active November 21, 2021 22:29
Sparsely clone only a specific git repo directory using a GitHub tree URL

Uses git sparse checkout features to git clone only a given directory path within a repo.

Usage

Provide a GitHub tree-URL (a URL to a specific directory on a branch) as the only argument. Currently this only supports sparse checkout from GitHub.

Example: git clonedir https://github.com/GoogleChrome/chrome-extensions-samples/tree/mv3-migration-snippet/mv2-archive/api/messaging/timer

git Subcommand Note

If you have custom executables named as git-* in $PATH, git will automatically detect and offer these commands as subcommands. Therefore if you place git-clonedir in your $PATH (e.g. /usr/local/bin/) then you can also run it as git clonedir.

@m-bartlett
m-bartlett / README.md
Created December 7, 2021 06:44
Random collage/montage generator with drop-shadow.

These are the sample input files in $PWD for the below examples:

Mochi 1.png Millie3 2.png
@m-bartlett
m-bartlett / README.md
Created December 14, 2021 21:59
i3 ipc script to allow breadth-first movement for moving focus between highly nested containers.

i3-focus-skip-tabs

This parses the i3 workspace tree from the i3 IPC to execute focus commands on the outermost tabbed container that has 1+ siblings. If such a container is not found in the hierarchy up from the focused window to the root container then this will call a regular focus command. In theory this script can take any valid arguments that the i3 command focus takes (e.g. prev and next, etc.), however it has only been tested with leftandright.

The idea is this will move focus between the highest level containers without requiring several focus parent commands if working with highly nested containers.

Demo

The following video demo is running with the following keybinds, i.e. the "normal" keybind to change focus instead runs this script with super+alt+(left/right) being a fallback to normal focus (left/right.

@m-bartlett
m-bartlett / i3dropdown.py
Created January 8, 2022 04:05
i3 dropdown terminal using your favorite terminal™️ in a special i3 container and the i3 scratchpad workspace
#!/usr/bin/env python3
import i3ipc
DROPDOWN_IDENTIFIER = "dropdown"
DROPDOWN_CHILD_IDENTIFIER = "dropdownchild"
INITIAL_TERMINAL_QUANTITY = 3
TERMINAL_COMMAND = f"terminal -n {DROPDOWN_CHILD_IDENTIFIER}"
HEIGHT_PERCENTAGE = 33
i3 = i3ipc.Connection()
@m-bartlett
m-bartlett / fetchchan.sh
Created January 23, 2022 01:33
Download all images in 4chan thread(s)
#!/usr/bin/bash
# Usage: fetchchan https://boards.4chan.org/{board}/thread/{thread_id} [...]
# or fetchchan -U in a directory housing a previous fetchchan to download only new images since last fetch
if [[ "$1" == "-U" ]]; then
urls="$(find . -name .url -type f -exec cat {} \;)"
set -- $urls
fi