Skip to content

Instantly share code, notes, and snippets.

View ncw's full-sized avatar
💥
429 Too Many Requests

Nick Craig-Wood ncw

💥
429 Too Many Requests
View GitHub Profile
@m-radzikowski
m-radzikowski / script-template.sh
Last active April 25, 2024 18:43
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@ogazitt
ogazitt / auth.go
Created April 14, 2020 05:53
Auth0 PKCE flow for a CLI built in golang
package auth
import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"net/url"
@joelgrus
joelgrus / lampsort
Last active August 29, 2015 14:10
non-recursive quicksort, based on http://bertrandmeyer.com/2014/12/07/lampsort/
from collections import deque
def partition(a, lo, hi):
"""partition a[lo] to a[hi] using a[hi] as the pivot"""
pivot_value = a[hi]
insert_at = lo
for i in range(lo, hi):
if a[i] < pivot_value:
a[i], a[insert_at] = a[insert_at], a[i]
insert_at += 1
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: