Skip to content

Instantly share code, notes, and snippets.

View zph's full-sized avatar

Zander Hill zph

View GitHub Profile
@zph
zph / pd-page-help.ts
Last active July 3, 2023 16:33
Deno wrapper for pagerduty-cli
#!/usr/bin/env -S deno run --allow-all
// Relies on pd binary which is auto installed with npx https://github.com/martindstone/pagerduty-cli/blob/master/docs/incident.md#pd-incident-create
// for globals and happy editor
import "https://deno.land/x/violet@0.1.0/globals.d.ts";
// For shell like syntax without needing vl shebang
import "https://deno.land/x/violet@0.1.0/globals.ts";
import "https://deno.land/std/log/mod.ts"
import * as log from "https://deno.land/std/log/mod.ts";
import { Checkbox } from "https://deno.land/x/cliffy@v0.25.7/prompt/checkbox.ts";
@zph
zph / ebs_warm_disk.sh
Created April 7, 2023 05:27
EBS disk warming script using fio
#!/usr/bin/env bash
# EBS disk warming script to run on boot to automatically warm restored snapshot
# disks once per volume id
# Place entry in crontab for root using `crontab -e`
# ### Note some paths are restrictive and require extra workarounds
# PATH=/sbin:/usr/local/bin:/bin
# @reboot bash -c "sleep 60 && ebs_warm_disk >> /var/log/fio.log 2>&1"
# Assumptions
# volume to warm is /data and xfs type
@zph
zph / build-keyhole.sh
Created November 7, 2021 14:45
Installs keyhole in the `./bin` folder relative to current directory
#!/usr/bin/env bash
set -eou pipefail
set -x
CURRENT_DIR="$(pwd)"
WORKSPACE=$(mktemp -d)
trap "rm -rf $WORKSPACE" EXIT
(
cd "$WORKSPACE"
@zph
zph / pull-request
Last active April 11, 2023 05:34
Pull request helper script
#!/usr/bin/env bash
set -eou pipefail
main() {
local branch_name
branch_name="$(git rev-parse --abbrev-ref HEAD)"
local base_branch="${1:-master}"
\git push origin "$branch_name"
hub pull-request -b "$base_branch"
require 'json'
def get_links(file)
body = File.read(file)
json = JSON.parse(body)
kv = json.dig("store", "pluginStates").to_a
JSON.parse(kv.first[1])["requests"]
.map { |k,v| v["url"] }
.reject { |l| l[/clients3\.google\.com|doubleclick|localhost|googleapis\.com/] }
.sort
#!/usr/bin/env ruby
# Load no gems beyond stdlib due to native extensions breaking
# and rebuilding between different ruby versions and chruby/system.
# Also should speed up script timing. ZPH
$LOAD_PATH.delete_if { |l| l[/\/(gems|extensions)\//] }
#########################################################
## Generated Code: do not submit patches.
## Submit patches against non-generated version of code.
#########################################################
defmodule RnaTranscription do
@doc """
Transcribes a character list representing DNA nucleotides to RNA
## Examples
RnaTranscription.to_rna('ACTG')
'UGAC'
"""
@rna_map %{?A => 'U', ?T => 'A', ?G => 'C', ?C => 'G'}
def lookup(k) do
#!/usr/bin/env bash
set -CEeuo pipefail
IFS=$'\n\t'
shopt -s extdebug
main() {
networksetup -getairportnetwork en0 | sed 's/Current Wi-Fi Network: //g'
}
class Archiver < Formula
desc "Easily create & extract archives, and compress & decompress files of various formats"
homepage "https://godoc.org/github.com/mholt/archiver"
url "https://github.com/mholt/archiver/releases/download/v3.2.0/arc_mac_amd64"
sha256 "1932ecb8b8dc8492e62a608f436dc6d514c8357e224fd5fe7653bd3266cd67e3"
def install
bin.install "arc_mac_amd64" => "arc"
end
class Mmake < Formula
GIT = "github.com/zph/mmake"
desc "Go wrapper for forked version of TJ Holowaychuk's Mmake"
homepage "https://#{GIT}"
url "https://#{GIT}.git",
tag: "v1.4.2"
head "https://#{GIT}.git"
depends_on "go"