Skip to content

Instantly share code, notes, and snippets.

View jonchurch's full-sized avatar
♥️

Jon Church jonchurch

♥️
View GitHub Profile
@jonchurch
jonchurch / getReleases.sh
Created November 10, 2024 20:02
Get all GH releaes from a repo in a flat file, using gh cli
#!/bin/sh
# Check if gh CLI is installed
if ! command -v gh >/dev/null 2>&1; then
echo "Error: GitHub CLI (gh) is not installed. Please install it to continue." >&2
exit 1
fi
# Check if a repository identifier was provided
if [ -z "$1" ]; then
@jonchurch
jonchurch / 1orgStats.sh
Last active April 12, 2024 08:00
Given a github org, get the npm registry download stats for the past week
#!/bin/bash
# Exit on error, uninitialized variable use, and catch errors in pipelines
set -euo pipefail
# set -x
# Initialize the DEBUG flag
DEBUG=false
# Process command-line arguments
@jonchurch
jonchurch / orgs.json
Last active February 24, 2024 20:45
Unique github orgs in express package.json deps. Keys are github orgs, array values are (npm) package names
{
"jshttp": [
"accepts",
"content-disposition",
"content-type",
"cookie",
"etag",
"fresh",
"http-errors",
"methods",
[alias]
root = rev-parse --show-toplevel
pr = "!f() { git fetch -fu ${2:-upstream} refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f"
conflicts = diff --name-only --diff-filter=U
fix = "!f() { ${EDITOR} `git conflicts`; }; f"
@jonchurch
jonchurch / magicBytes.ts
Last active July 19, 2023 20:52
Typescript for checking a file's magic bytes to determine what mimetype it should have
/**
* Reads the first 8 bytes (magic bytes) from the provided file.
*
* @param {File} file - The file from which the magic bytes are to be read.
* @returns {Promise<Uint8Array>} A promise that resolves to a `Uint8Array` containing the first 8 bytes of the file.
* @throws {Error} Throws an error if the file cannot be read or if there's another reading issue.
*
* @example
* const file = new File(["content"], "filename.txt");
* sniffMagicBytes(file).then(bytes => {
#!/bin/sh
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to abort the commit.
#
# Will skip linting if the commit is a merge commit
# to avoid introducing formatting diffs on already committed code
PATH=$PATH:/usr/local/bin:/usr/local/sbin
echo --------------------------------------------
@jonchurch
jonchurch / roundtable1.md
Last active May 29, 2023 21:59
Spacetraders Roundtable #1 5/29/23

Discussion Minutes

  • Felix (@feba66), Joel (@space-admiral), James (@Green), and Jon (@jonchurch) in attendance
  • What are goals of the Project?
  • 2946 folks are in the discord
  • Joel is the main dev lead
  • Artokun is other dev and helping to manage the other devs
    • 2 people have access to the codebase (artokun and Joel)
  • Felix has already been using real concepts he has learned for Spacetraders in his CompSci studies
  • The HTTP spec is a great compromise on technology because it is approachable for learners
@jonchurch
jonchurch / axiosRequestQueue.ts
Last active May 16, 2023 00:30
[WIP] Axios Request Queuing for Spacetraders.io rate limit .... uh, limiting
import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';
interface Job {
id: string;
createdAt: string;
status: 'queued' | 'processing' | 'completed' | 'failed';
priority?: number;
retryCount?: number;
data?: any;
execute: () => void;
@jonchurch
jonchurch / factions.8-13.json
Created May 13, 2023 18:32
Spacetraders.io factions from May 13th 2023 reset
{
"data": [
{
"symbol": "COSMIC",
"name": "Cosmic Engineers",
"description": "The Cosmic Engineers are a group of highly advanced scientists and engineers who seek to terraform and colonize new worlds, pushing the boundaries of technology and exploration.",
"headquarters": "X1-ZA40-15970B",
"traits": [
{
"symbol": "INNOVATIVE",
@jonchurch
jonchurch / gist:c4ab048c81b0c0caba2cca4f0cefbf52
Created February 6, 2023 19:13
Get unique filenames from eslint output
# input looks like
# ~/proj/src/some/file/path.tsx(60,9): error jest/no-conditional-expect : Avoid calling `expect` conditionally`
npm run lint -- --quiet | awk 'BEGIN { FS="(" }; {print $1O}' | uniq -u