Skip to content

Instantly share code, notes, and snippets.

View zph's full-sized avatar

Zander Hill zph

View GitHub Profile
@zph
zph / jira-cli
Last active July 27, 2024 13:13
jira-cli
#!/usr/bin/env bash
set -eou pipefail
jira issue list \
-a$(jira me) \
--plain \
--columns id,summary,status |
fzf \
--layout=reverse \
@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 / 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"
@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"
# Variables to replace in urls below
username = 'your_username_here_without_at_symbol'
key = 'public_key_from_dev'
application_token = 'very_long_application_token'
# This needs to be parsed as JSON for all of the 'id' fields. These are the board_hashes
url_for_board_hashes = "https://api.trello.com/1/members/#{username}/boards?&key=#{key}&token=#{application_token}"
#
# Loop over each board_hash and call the following url
@zph
zph / trello-cards-from-csv.rb
Created October 5, 2012 19:33 — forked from joshmcarthur/trello-cards-from-csv.rb
A Ruby script to import Trello cards from a CSV file
#!/usr/bin/env ruby
# You can skip this bit if you wish - you will need the 'ruby-trello' gem installed, and
# optionally, 'foreman' to run the script with.
require 'bundler/setup'
Bundler.require
require 'trello'
require 'csv'
@zph
zph / photo_to_scan.rb
Created April 26, 2012 00:49
Script to transform images to scanned documents (In Progress)
#!/usr/bin/env ruby
#
# Author : tevic@civet.ws
# License: MIT
# Function: Wrapper for unpaper & imagemagick to allow easy conversions
# Date 2012.04.06
# Credits:
# Requirements:
# Linux
# unpaper
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.
#########################################################