Skip to content

Instantly share code, notes, and snippets.

View jsumners's full-sized avatar

James Sumners jsumners

View GitHub Profile

Let's see what happens with achors in a markdown table.

Toc

nonsense

A bunch of nonsense to elongate the viewport.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque sed nisl volutpat, molestie nisl et, convallis lorem. Ut varius at massa quis ultricies. Duis nec dolor ut risus sagittis pretium. Suspendisse malesuada quam ac tortor pulvinar, vitae iaculis tellus euismod. Nullam faucibus sapien quis libero auctor iaculis. Proin rhoncus vel elit nec fringilla. Aliquam bibendum, ligula et rutrum hendrerit, ligula urna pulvinar ex, in pellentesque ante tortor et sem. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In viverra ipsum quam, nec finibus nisi tempor in. Pellentesque porta dictum sem non tincidunt. Phasellus ut justo euismod, auctor nulla et, aliquet lorem. Vivamus metus ante, dignissim ac fermentum a, rhoncus id erat. Ut tincidunt tortor non laoreet bibendum. Nam in pharetra orci, vitae lobortis purus.

@jsumners
jsumners / index.mjs
Created March 3, 2023 22:58
Close and lock issues and pull requests for a GitHub repo
import dotenv from "dotenv";
dotenv.config();
// Create a .env file in the same directory
// as this script. Add the following constants
// to that file:
const ORG = process.env.ORG;
const REPO = process.env.REPO;
const GITHUB_TOKEN = process.env.GITHUB_TOKEN;
@jsumners
jsumners / index.js
Created January 12, 2023 15:26
A weird construct in a class static method that makes the method inheritable by class extensions
'use strict'
class Foo {
static createFoo() {
return new Foo()
}
}
class Bar {
static createBar() {
@jsumners
jsumners / gist:e6b5d0a699f16ba980a3
Last active November 24, 2022 16:09 — forked from thgaskell/gist:5987fccbd8473b5ef78f
Introduction to Sequelize Migrations

What are Migrations

Just like how we use Git to version control source code, we use migrations to manage the state of our database schemas.

I'm not really sure what that means...

Imagine you're working on project with another developer, and you're both tasked with creating a specific part of an event planning application. Let's say you are in charge of creating the Users and your friend is going to create the Events.

Let's say you and your friend divided the work in a way so that neither of you will have to to use each other's code to finish your tasks. While you're working on your part of the application, you only really need to touch the Users table when you are working with the database.

Creating models and migrations

@jsumners
jsumners / void-wsl.sh
Created November 11, 2022 21:40 — forked from kmatt/void-wsl.txt
Install Void Linux on WSL2
# Based on https://gist.github.com/kmatt/71603170556ef8ffd14984af77ff10c5
# prompt ">" indicates Powershell commands
# https://docs.microsoft.com/en-us/windows/wsl/install-win10
> dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
> dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
# install https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
@jsumners
jsumners / ntp.conf
Created July 26, 2017 16:12
RHEL7 Ansible task list to fix NTP
# {{ansible_managed}}
{% if 'vmware' in ansible_product_name|lower %}
# Disable panic quit if system is >1000s out of sync because VMware.
tinker panic 0
{% endif %}
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery
@jsumners
jsumners / index.mjs
Created May 5, 2022 11:32
Unsub GitHub org notifications
import dotenv from "dotenv";
dotenv.config();
const ORG = process.env.ORG;
const GITHUB_TOKEN = process.env.GITHUB_TOKEN;
import { Client } from "undici";
const client = new Client("https://api.github.com");
const headers = {
@jsumners
jsumners / readme.md
Created March 3, 2021 12:54
Start new PR with an existing PR as a base

Ocassionally, someone will start a pull request and, for various reason, not see it through. Later, someone else may wish to finish that work. Even though the original author was unable to finish their work, we should still include their efforts in our project's history. To do so, the person wishing to finish the original pull request should start their new pull request using the original as the base.

The simplest workflow to accomplish this is:

$ # For the project on GitHub to your account and then:
$ git clone 
@jsumners
jsumners / walk.mjs
Created November 18, 2021 15:41
Walk a Node project's dependency tree and list the dependencies and their versions
import fs from 'fs/promises';
import treeify from 'treeify';
const result = await readModDir('.');
console.log(treeify.asTree(result, true));
async function readModDir(modDirPath) {
const dirEntries = await fs.readdir(new URL(modDirPath, import.meta.url));
const hasNodeModules = dirEntries.some(entry => entry === 'node_modules');
const pkgSrc = await fs.readFile(new URL(`${modDirPath}/package.json`, import.meta.url));