Skip to content

Instantly share code, notes, and snippets.

View Nezteb's full-sized avatar
💣
hello world'); DROP TABLE Statuses;--

Noah Betzen Nezteb

💣
hello world'); DROP TABLE Statuses;--
View GitHub Profile
@Nezteb
Nezteb / check_types.ex
Created March 29, 2023 01:02
Theoretical mix task that will fail/alert when new Dialyzer errors are added to codebase. Based on: https://www.youtube.com/watch?v=4PZE40h13wM
defmodule Mix.Tasks.CheckTypes do
@moduledoc "The checktypes mix task: `mix help checktypes`"
use Mix.Task
@shortdoc "Runs Dialyzer and compares the results to our existing errors."
def run(_args) do
# https://github.com/jeremyjh/dialyxir/blob/ed0df656a74eb6d4e906fe20fc056ca42ba7d5ec/lib/mix/tasks/dialyzer.ex#L145-L155
output = Mix.Task.run("dialyzer", ["--quiet", "--format", "ignore_file"])
@Nezteb
Nezteb / kubeforward.sh
Last active March 29, 2023 04:24
A simple shell wrapper around socat for tunneling a TCP port in a Kubernetes cluster.
kubeforward() {
# https://yuku.takahashi.coffee/blog/2020/07/connect-to-a-resource-behind-a-k9s-cluster-from-local-machine
# https://hub.docker.com/r/alpine/socat
if [[ ($# -ne 3 && $# -ne 4) ]]; then
echo "Usage: kubeforward <endpoint> <endpoint_port> <local_port> [<label>]"
return
fi
KUBE_NAMESPACE="default"
@Nezteb
Nezteb / installing-rsql.sh
Last active March 29, 2023 15:26
Installing rsql on M2 Mac with macOS Ventura?
rsql() {
# https://docs.aws.amazon.com/redshift/latest/mgmt/rsql-query-tool-getting-started.html
# https://stackoverflow.com/questions/38670295/homebrew-refusing-to-link-openssl
# https://www.deepanseeralan.com/tech/openssl-dev-on-macOS/
BREW_PREFIX=$(brew --BREW_PREFIX [email protected])
RSQL_OPENSSL_PATH="/usr/local/opt/[email protected]/lib"
LIB="/usr/local/lib"
export PATH="$BREW_PREFIX/bin:$PATH"
export LDFLAGS="-L$BREW_PREFIX/lib"
@Nezteb
Nezteb / kube-db-access.sh
Last active March 27, 2023 20:59
Connecting to RDS behind EKS cluster VPC, Keyspaces, and Redshift via easy-to-use shell aliases.
kubeshell() {
# Set these:
KUBE_NAMESPACE=
KUBE_POD=
kubectl -n "$KUBE_NAMESPACE" exec -ti "$KUBE_POD" -- bash
}
kubepg() {
# Options:
# 1: dev, test, or prod
@Nezteb
Nezteb / Dockerfile
Last active April 4, 2025 21:37
Deploying Fossil with TLS on Fly.io via Docker
# Pulled from https://fossil-scm.org/home/file?name=Dockerfile&ci=trunk
# With more build ARGs, cleaner tarball extraction, HTTPS, etc.
ARG ALPINE_VERSION
ARG FSLHSH
ARG FSLVER
ARG FSLCFG=""
# syntax=docker/dockerfile:1.3
# See www/containers.md for documentation on how to use this file.
@Nezteb
Nezteb / pre-commit
Last active March 22, 2023 23:07
Pre-commit hook that will format any Elixir code that mix deems badly formatted AND that is staged for a commit. Instructions: https://www.git-scm.com/book/en/v2/Customizing-Git-Git-Hooks
#!/usr/bin/env bash
# Grep on macOS is limited and weird, so we're using Perl for the regex (and awk because it's easy)
UNFORMATTED_FILES=$(mix format --check-formatted 2>&1 | perl -nle'print $& while m{^|[^*]\* \K.*}g' | awk NF | sort)
STAGED_FILES=$(git diff --name-only --cached | sort)
# Files that need formatting and are currently staged (comm expects sorted inputs)
INTERSECTION=$(comm -12 <(echo "$UNFORMATTED_FILES") <(echo "$STAGED_FILES"))
GREEN='\033[0;32m'
{
"title": "Add ctrl/fn/cmd + left click -> right click",
"rules": [
{
"description": "ctrl+left click to right click",
"manipulators": [
{
"type": "basic",
"from": {
"pointing_button": "button1",
@Nezteb
Nezteb / downloadIndexOf.sh
Created March 19, 2023 04:51
Download "index of" sites
#!/bin/bash
wget --no-clobber --no-parent --recursive --random-wait --user-agent=mozilla --reject "*.html*" $1
@Nezteb
Nezteb / compress_videos.sh
Created March 11, 2023 21:10
A quick video compression script, but it's still pretty slow
#!/usr/bin/env bash
# VIDEOS=$(fd mp4)
# for VIDEO in $VIDEOS
# do
# done
/usr/bin/find . -type f -name "*.mp4" -print0 | while IFS= read -r -d '' VIDEO; do
echo "Compressing $VIDEO..."
@Nezteb
Nezteb / removeResolvedBotThreadsGitLab.js
Last active March 21, 2023 00:52
Remove GitLab resolved bot comments (for use with https://www.tampermonkey.net/)
// ==UserScript==
// @name Remove resolved bot threads on a merge request
// @description Remove resolved bot threads on a merge request
// @namespace http://tampermonkey.net/
// @version 0.1
// @author Noah Betzen
// @match https://gitlab.com/*/merge_requests/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=gitlab.com
// @grant none
// ==/UserScript==