Skip to content

Instantly share code, notes, and snippets.

View jonchurch's full-sized avatar
♥️

Jon Church jonchurch

♥️
View GitHub Profile
@jonchurch
jonchurch / git.md
Last active April 15, 2024 19:13
My Most Used Git Commands

Viewing Commits

I often want to look at commit history, individual commits, the changes a commit brought, etc.

This can be challenging when you don't know the exact commit or range you want.

If you only want to see X number of commits, you can pass a numerical flag: git log -3 will output the last 3 commits.

You can further filter by author:

@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",
@jonchurch
jonchurch / chonkArray.js
Created July 23, 2019 21:35
Array Chonk (Array chunking)
function chonkArray(array, chonkSize) {
let arrayOfChonks = [];
for (let i = 0; i < array.length; i += chonkSize) {
const chonk = array.slice(i, i + chonkSize);
arrayOfChonks.push(chonk);
}
return arrayOfChonks;
}
const chonkable = ["🍕","🐡","🍝","🐙","✨"]
[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",