Skip to content

Instantly share code, notes, and snippets.

View nberlette's full-sized avatar
👋
Available for new projects

Nicholas Berlette nberlette

👋
Available for new projects
View GitHub Profile
@nberlette
nberlette / RenewExpiredGPGkey.md
Created September 29, 2023 18:23 — forked from TheSherlockHomie/RenewExpiredGPGkey.md
Updating expired GPG keys and backing them up 🔑🔐💻

Updating expired GPG keys and their backup 🔑🔐💻

I use a GPG key to sign my git commits.

An error like this one might be a sign of an expired GPG key.

error: gpg failed to sign the data fatal: failed to write commit object
@nberlette
nberlette / deno_install.sh
Created June 5, 2023 04:30 — forked from LukeChannings/deno_install.sh
Deno installation script
#!/bin/sh
# A modification of the standard Deno installation script (https://deno.land/install.sh)
# updated to support downloading a Linux arm64 binary from LukeChannings/deno-arm64
set -e
if ! command -v unzip >/dev/null; then
echo "Error: unzip is required to install Deno (see: https://github.com/denoland/deno_install#unzip-is-required)." 1>&2
exit 1
fi
@nberlette
nberlette / schema.graphql
Created July 7, 2022 22:26 — forked from nyancodeid/schema.graphql
DenoQL: GraphQL Schema
type Query {
page(
# A URL to fetch the HTML source from.
url: String
# A string containing HTML to be used as the source document.
source: String
): Document
}
@nberlette
nberlette / starship.toml
Created June 2, 2022 23:36 — forked from pythoninthegrass/starship.toml
Starship prompt setup
# SOURCE: https://starship.rs/config
# DEBUG via: `starship explain`
# Timeout for commands executed by starship (ms)
command_timeout = 1000
# Replace the "❯"
[character]
success_symbol = "[λ](green)"
/**
* Maps a callback to an element in an array-like object
* Basically a copy of underscore's _.each
* source: http://underscorejs.org/docs/underscore.html#section-20
*/
export function forEach(obj, iteratee, context) {
let ctx = this;
const isObject = function(obj) {
// Creates a new promise that automatically resolves after some timeout:
Promise.delay = function (time) {
return new Promise((resolve, reject) => {
setTimeout(resolve, time)
})
}
// Throttle this promise to resolve no faster than the specified time:
Promise.prototype.takeAtLeast = function (time) {
return new Promise((resolve, reject) => {
@nberlette
nberlette / .npm-init.js
Created March 28, 2022 18:11 — forked from afj176/.npm-init.js
example .npm-init.js
var fs = require('fs'),
path = require('path'),
homeDir = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE,
gitConfig = path.join(homeDir, '.gitconfig'),
cwd = process.cwd(),
name = cwd.split('/').pop();
/*
decode function and required functions copied from
https://github.com/npm/ini
in order to parse github config without added reqs
@nberlette
nberlette / orgy-location.md
Last active March 24, 2022 17:18 — forked from aidswidjaja/ghlorg.md
GitHub custom organization locations

Set custom GitHub organization locations, like this one:

image

Since GitHub tries to make you choose from countries now, just use the API to get around it.

curl -X PATCH -H "Accept: application/vnd.github.v3+json" -H "Authorization: token $GITHUB_TOKEN" \
        https://api.github.com/orgs/$ORGANIZATION -d '{"location":"localhost:420"}'
@nberlette
nberlette / array_iteration_thoughts.md
Created December 13, 2021 19:38 — forked from ljharb/array_iteration_thoughts.md
Array iteration methods summarized

Array Iteration

https://gist.github.com/ljharb/58faf1cfcb4e6808f74aae4ef7944cff

While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.

Intro

JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it mu