Skip to content

Instantly share code, notes, and snippets.

View pbar1's full-sized avatar
☄️

Pierce Bartine pbar1

☄️
View GitHub Profile
@pbar1
pbar1 / op_gpg.sh
Created October 23, 2024 06:09
Fix GPG keys collapsed into 1Password items
#!/bin/bash
set -euo pipefail
op item get 'GPG' --fields GPG.publickey | rg '(-----BEGIN.*?-----)(.*?)(-----END.*?-----)' --replace='${1}
${2}
${3}' | fold -w 65 > public.pem
op item get 'GPG' --fields GPG.secretsubkeys | rg '(-----BEGIN.*?-----)(.*?)(-----END.*?-----)' --replace='${1}
@pbar1
pbar1 / BIN.md
Last active October 23, 2024 04:12
My binaries

My bin directory

Dumping ground for freestanding scripts I make.

@pbar1
pbar1 / cb.ts
Created August 17, 2024 22:04
Convenience builder for Constructs in CDKs.
import { App, Chart, YamlOutputType } from "cdk8s";
import { Construct } from "constructs";
import * as k8s from "./imports/k8s";
/**
* Utility type to extract the `*Props` type from the constructor of a {@link Construct}.
*/
type ConstructProps<T extends abstract new (...args: any) => any> =
ConstructorParameters<T> extends [
scope: Construct,
@pbar1
pbar1 / subtitle_merge.sh
Created September 19, 2023 07:19
Make dual subtitles
#!/usr/bin/env bash
set -euo pipefail -x
for input in *.mkv; do
# map to sonarr-managed files
n="$(echo "$input" | awk '{print $6}')"
target="$(ls '/data/media/tv/Rurouni Kenshin (2023)/Season 01/'*"S01E$n"*'.mkv')"
ass_en="${target%.*}.en.ass"
@pbar1
pbar1 / github_forcecommand.sh
Created July 25, 2023 04:38
Example implementation of the GitHub SSH ForceCommand
#!/usr/bin/env sh
set -e
# Omitting logic to deal with Git since this is just an example
if [ -z "${SSH_ORIGINAL_COMMAND}" ]; then
echo "Hi ${USER}! You've successfully authenticated, but GitHub does not provide shell access."
exit 1
else
use async_ssh2_lite::ssh2::Session;
use async_ssh2_lite::AsyncSession;
use criterion::Criterion;
use criterion::{criterion_group, criterion_main};
use std::io::prelude::*;
use tokio::io::AsyncReadExt;
async fn ssh2_spawn_blocking() {
tokio::task::spawn_blocking(|| {
let tcp = std::net::TcpStream::connect("127.0.0.1:2222").unwrap();
@pbar1
pbar1 / nps_visitors_1904-2021.csv
Created January 3, 2023 02:37
Annual Visitation and Record Year by Park (1904 - 2021) [via https://irma.nps.gov/STATS]
We can't make this file beautiful and searchable because it's too large.
RegionName,ParkName,ParkType,Year,TRV
Alaska Region,Alagnak Wild River,National Wild & Scenic River,1904,
Alaska Region,Alagnak Wild River,National Wild & Scenic River,1905,
Alaska Region,Alagnak Wild River,National Wild & Scenic River,1906,
Alaska Region,Alagnak Wild River,National Wild & Scenic River,1907,
Alaska Region,Alagnak Wild River,National Wild & Scenic River,1908,
Alaska Region,Alagnak Wild River,National Wild & Scenic River,1909,
Alaska Region,Alagnak Wild River,National Wild & Scenic River,1910,
Alaska Region,Alagnak Wild River,National Wild & Scenic River,1911,
Alaska Region,Alagnak Wild River,National Wild & Scenic River,1912,
@pbar1
pbar1 / sapling-from-source.nix
Created November 19, 2022 05:17
Attempt at building Sapling from source with Nix
{ bzip2
, dpkg
, fetchFromGitHub
, lib
, libnghttp2
, libssh2
, lz4
, openssl
, pkg-config
, python3
#![feature(test)]
extern crate test;
fn main() {}
#[cfg(test)]
mod tests {
use rayon::prelude::*;
use std::sync::atomic::{AtomicI32, Ordering};
FROM continuumio/anaconda3
RUN pip install duckdb investpy
WORKDIR /workdir
RUN useradd --create-home user && \
chown user:user /workdir
USER user
CMD ["jupyter-lab", "--no-browser", "--ip=0.0.0.0", "--ServerApp.token="]