Skip to content

Instantly share code, notes, and snippets.

View jphastings's full-sized avatar
🌴

JP Hastings-Edrei jphastings

🌴
View GitHub Profile
@jphastings
jphastings / README.md
Created October 27, 2024 08:17
A random comment picker for scalzi.com

Random Comment Picker for Scalzi.com

A short script that can be dropped in the developer console, or used as a bookmarklet, on Scalzi.com that will highlight & move to the comment with the specified number. (The prompt pre-populates with a randomly chosen comment.)

I will look at the the total number of comments, ask Alexa to pick a number in that field of numbers, and then painstakingly go through the comments until I find the comment that corresponds to that number, and then pick that one. This will be an enormous pain in my ass, so I hope at least one of you gets the moon right.

Hey, Want an ARC of “When the Moon Hits Your Eye”? on Scalzi.com

@jphastings
jphastings / git-download-subpath
Last active May 14, 2024 12:32
I made a git helper tool that lets you retrieve files from a subpath of git without downloading the whole of the (possibly huge) repo.
#!/bin/bash
set -e
repo="$1"
subpath="$2"
if [[ -z "${repo}" || -z "${subpath}" ]]; then
echo "usage: git-download-subpath <repo> <subpath> [destination]"
exit 1
fi
@jphastings
jphastings / openpgp.md
Created November 12, 2022 11:39
Proving my identity with Keyoxide

openpgp4fpr:52A59FB334967177D8E425D5FDD468F7EF117819

@jphastings
jphastings / rpi_firmware
Created March 27, 2021 13:35
Ensures the basic RPi firmware is in the given folder
#!/bin/sh
FIRMWAREURL="https://raw.githubusercontent.com/raspberrypi/firmware/master/boot/"
DIR="$1"
[ ! -d "${DIR}" ] && { echo "First argument should be a directory that exists"; exit 1; }
for firmware in LICENCE.broadcom bootcode.bin fixup.dat start.elf; do
firmware_dest="${DIR}/${firmware}";
if [ ! -f "${firmware_dest}" ]; then
echo "Downloading RPi firmware: ${firmware}";
curl --silent --output "${firmware_dest}" "${FIRMWAREURL}${firmware}";
@jphastings
jphastings / git-into
Created September 18, 2019 15:04
Git into merges your current branch into the given remote branch, first resetting your local version of the given branch to remote's version thereof. To be invoked with a deep southern accent.
#!/bin/sh
# Place in your path and invoke with a deep southern accent: `git into staging`
mergeinto="$1"
if [[ $(git status -s) ]]; then
echo "Your working directory is not clean, please commit or stash first."
exit 1
else
branch=$(git rev-parse --abbrev-ref HEAD)
git fetch > /dev/null
git checkout "$mergeinto"
@jphastings
jphastings / looper.go
Last active February 16, 2019 23:54
Animation gif looper
package main
/*
Some really shonky code that looks for looping moments within a set of frames from animated TV shows.
Find out more here: https://twitter.com/jphastings/status/1096915446702489600
*/
import (
"fmt"
@jphastings
jphastings / mkport
Created September 4, 2018 17:18
Need a port number for your service that's unlikely to clash with other services and easy to remember? Try mkport!
#!/usr/bin/env ruby
port = ARGV[0].downcase.split(//).reduce(0) do |sum, char|
sum * 10 + case char
when *%w[a b c] then 2
when *%w[d e f] then 3
when *%w[g h i] then 4
when *%w[j k l] then 5
when *%w[m n o] then 6
when *%w[p q r s] then 7
@jphastings
jphastings / app.go
Created July 6, 2018 09:15
Structuring a gin webapplication: an idea
package main
import (
"fmt"
"github.com/go-gonic/gin"
)
var Routes struct {
Homepage func() string
CreateWidget func() string
@jphastings
jphastings / README.md
Last active May 18, 2022 08:59
JIRA Standup!

Standup helper

The following Manager Code™ will let you walk through your Jira Project board person by person, in a 'random order' (deterministic on a per-day basis) and show only their tickets.

It works in my Chrome browser; your mileage may vary… (forks of this gist very welcome!)

To use it:

  1. Copy the code below
  2. Create a new bookmark in Chrome
@jphastings
jphastings / README.md
Last active May 3, 2018 08:55
Show your codeowners in Sublime Text 3

Codeowners

Github uses a CODEOWNERS file in the root of a repo as a declaration of individuals or teams that should be notified if files are changed.

This is very useful when working on a project with a large number of contributors; but it can be a bit hard to make use of as a human.

This Sublime Text plugin adds a status bar hint to let you know who you might want to talk to about the file you're editing.

Illustration of plugin active in the Status Bar