Skip to content

Instantly share code, notes, and snippets.

@SgtPooki
SgtPooki / output.txt
Created January 6, 2023 21:19
Attempt to generate a list of packages that need updated in order to update a dependency. My ideal goal for something like this is to run a script via `npx` in a project, with something like `--target=multiformats@11.0.0` and get out a list of dependencies to update working in a depth-first order.
╰─ ✔ ❯ npx -y ts-node parse-ls-output.ts
Package update order:
interface-ipfs-core - (depended on by 1 packages)
@ipld/car - (depended on by 1 packages)
@libp2p/interface-peer-id - (depended on by 1 packages)
@libp2p/peer-id-factory - (depended on by 1 packages)
@libp2p/peer-id - (depended on by 1 packages)
blockstore-core - (depended on by 1 packages)
dag-jose - (depended on by 1 packages)
did-jwt - (depended on by 1 packages)
@SgtPooki
SgtPooki / test-repos.sh
Created July 21, 2022 01:38
test if github repos are valid, or have been moved to another org/name, and output the new name if so.
#!/usr/bin/env bash
main() {
local valid_repos_file=$(mktemp)
local moved_repos_file=$(mktemp)
cat newline-delimited-repo-names.txt | while read repo; do {
local repo_site="https://github.com/$repo"
@SgtPooki
SgtPooki / eslint-plugin-import+2.26.0.patch
Last active July 5, 2022 21:24
eslint-plugin-esm: eslint rules to help autofix CJS code you're migrating to ESM
diff --git a/node_modules/eslint-plugin-import/config/recommended-esm.js b/node_modules/eslint-plugin-import/config/recommended-esm.js
new file mode 100644
index 0000000..0b78a13
--- /dev/null
+++ b/node_modules/eslint-plugin-import/config/recommended-esm.js
@@ -0,0 +1,20 @@
+const recommendedConfig = require('./recommended')
+
+/**
+ * The basics.
@SgtPooki
SgtPooki / comma-functions.sh
Last active March 26, 2022 04:23
Comma.ai video+log downloading via sftp via the command line
#!/usr/bin/env bash
COMMA_AI_IP="192.168.1.11"
function comma-download {
local REMOTE_DIRECTORY="/data/media/0/realdata/$1" && shift
local LOCAL_DIRECTORY="${1:-}"
if [ -n "$LOCAL_DIRECTORY" ]; then
mkdir -p $LOCAL_DIRECTORY
@SgtPooki
SgtPooki / Log.ts
Created February 28, 2022 22:25
A simple console log wrapper
type Console = typeof console
/**
* This class' sole purpose is to avoid cluttering the codebase with `eslint-disable-line no-console` comments
*
* When using this class to log errors or messages, one can assume it's intentional and principled.
*/
class Log {
constructor (private readonly namespace?: string) {}
@SgtPooki
SgtPooki / ipfs-chat
Last active February 7, 2022 21:39
Simple terminal chat app using experimental ipfs
#
##
### PUBLIC INTERFACE
##
#
# Set up ipfs-chat
function chat-setup() {
# Create folders
mkdir -p $(chat-prefix)
@SgtPooki
SgtPooki / vanilla-observable.ts
Created December 16, 2021 18:55
Typescript version of a simple Observable. This was copied from https://stackoverflow.com/a/62002044/592760, translated to TypeScript, and improved.
/**
* Modified by Russell Dempsey on 2021 DEC 15
* @see https://stackoverflow.com/a/62002044/592760
*/
type Subscriber<T> = (value: T) => void;
class Observable<T> {
private subscribers = new Set<Subscriber<T>>();
constructor(private value: T) {}
@SgtPooki
SgtPooki / add_to_cart.user.js
Last active November 8, 2021 20:19 — forked from beporter/add_to_cart.user.js
Greasemonkey script to repeatedly refresh a given page, look for specific "Add to Cart" buttons, click them if present, and make a lot of noise on success.
// ==UserScript==
// @name Add Saved Items to Cart
// @namespace https://gist.github.com/beporter/ce76204bcba35d9edb66b395bb5e9305
// @version 0.5
// @description Repeatedly refresh a given "saved items" page (Amazon, Walmart, BestBuy), look for specific "Add to Cart" buttons, click them if present, and make a lot of noise on success.
// @author https://github.com/beporter
// @match https://www.amazon.com/gp/registry/wishlist/*
// @match https://www.amazon.com/hz/wishlist/ls/*
// @match https://www.bestbuy.com/cart
// @match https://www.bestbuy.com/site/customer/lists/manage/saveditems
@SgtPooki
SgtPooki / html-table-to-markdown-extra.html
Created February 10, 2021 19:40 — forked from sunnywalker/html-table-to-markdown-extra.html
HTML Table to Markdown Extra converter
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>HTML Table to Markdown Extra Table</title>
<style type="text/css">
* { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;}
body { font-family: -apple-system, "Segoe UI", Arial, Helvetica, sans-serif; line-height: 1.5;
text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
textarea { width: 100%; height: 15em; }
@SgtPooki
SgtPooki / node-tar.js
Last active January 21, 2021 07:54 — forked from mafintosh/node-tar.js
tar-fs vs node-tar benchmarks
// does not work...
var tar = require('tar');
var fstream = require('fstream');
var input = `node_modules`;
var reader = fstream.Reader({type: "Directory", path: input});
var pack = tar.Pack();
reader.pipe(pack).pipe(tar.Extract({path: '/tmp/destination-node-tar'}));