Skip to content

Instantly share code, notes, and snippets.

View wraithgar's full-sized avatar

Gar wraithgar

  • GitHub Staff
  • Tri-Cities, WA
View GitHub Profile
@wraithgar
wraithgar / promisify.js
Created May 24, 2020 19:56
Promisify all the functions in any object with a few lines of es6
const handler = {
get: function (target, prop, receiver) {
if (typeof target[prop] !== 'function' ) {
return target[prop]
}
return function () {
return new Promise((resolve, reject) => {
Reflect.get(target, prop, receiver).apply(target, [...arguments, function (err, result) {
if (err) {
return reject(err)
@wraithgar
wraithgar / gen.js
Created July 7, 2020 18:00
quick and dirty password generator
'use strict'
const fs = require('fs')
const words = fs.readFileSync('/usr/share/dict/words', 'utf8').split('\n')
const passwords = []
for (let i = 0; i < 12; i++) {
const randomNumber = Math.floor(Math.random() * words.length)
passwords.push(words[randomNumber])
}
console.log(passwords.join('-'))
@wraithgar
wraithgar / lifecycle.txt
Created February 18, 2021 15:24
npm7 lifecycle scripts notes
npm event lifecycle
cache add
- prepare (pacote.tarball.stream @npmcli/run-script)
ci
- preinstall (@npmcli/run-script)
- install (@npmcli/run-script)
- postinstall (@npmcli/run-script)
- prepublish (@npmcli/run-script)
- preprepare (@npmcli/run-script)
@wraithgar
wraithgar / broken
Last active October 20, 2021 18:48
Weird bedrock subchunk
version 9 subchunk with only one block?
09 01 04
[] sub_chunk_version = 9
[] num_storages = 1
[] sub_chunk_index = 4
00 00
!! !! two empty bytes !!
nbt
0a 00 00 08 04 00 6e616d65 13006d696e6563726166743a73... (nbt continues)
@wraithgar
wraithgar / instructions.txt
Created December 16, 2021 18:17
github graphql contributions query
// https://docs.github.com/en/graphql/overview/explorer
@wraithgar
wraithgar / npm-cli-autorelease-prs.graphql
Last active December 6, 2022 22:26
graphql dependabot open issues query
query {
search (query: "org:npm topic:npm-cli", type: REPOSITORY, first:100) {
nodes {
... on Repository {
nameWithOwner
pullRequests (labels: ["autorelease: pending"], first:100, states: [OPEN]) {
nodes {
number
url
title
@wraithgar
wraithgar / all-highest.js
Last active February 28, 2022 19:34
batch latest versions for a given npm package
'use strict'
const pacote = require('pacote')
const fetch = require('npm-registry-fetch')
const semver = require('semver')
const perRequest = 10
async function main() {
const manifest = await pacote.manifest(process.argv[2])
@wraithgar
wraithgar / main.js
Last active July 21, 2022 17:55
npm exec gist
#!/usr/bin/env node
const pkg = require('./package.json')
console.log(`Hi there! I am ${pkg.name} version ${pkg.version}`)
console.log(require('./package.json'))
@wraithgar
wraithgar / example.txt
Created January 12, 2023 15:38
npm pick manifest example
> pick = require('npm-pick-manifest')
[Function (anonymous)]
> packument
{
name: 'some-package',
'dist-tags': { foo: '1.0.1' },
versions: {
'1.0.0': { version: '1.0.0' },
'1.0.1': { version: '1.0.1' },
'1.0.2': { version: '1.0.2' },