Skip to content

Instantly share code, notes, and snippets.

import {
DefineFunction,
DefineType,
Schema,
SlackFunction,
} from "deno-slack-sdk/mod.ts";
export const AlertCustomType = DefineType({
name: "Alert",
type: Schema.types.object,
@danrspencer
danrspencer / .zshrc
Last active January 11, 2023 15:35
Bash Scratch
function scra {
FILE=/tmp/scratch-`uuidgen`.sh
echo '#!/bin/bash' > ${FILE}
chmod +x ${FILE}
code ${FILE}
ls ${FILE} | entr ${FILE}
}
export -f scra > /dev/null
@danrspencer
danrspencer / get-spec.sh
Created May 4, 2021 11:02
Extract and fully expand a Kubernetes definition
#!/bin/bash
trap "kill 0" EXIT
# Setup the proxy and wait for it to connect
kubectl proxy &
timeout 10s bash -c "until curl http://127.0.0.1:8001/; do sleep 1; done"
# Grab the Kubernetes openapi schema from the API
SCHEMA=$(curl http://127.0.0.1:8001/openapi/v2)
@danrspencer
danrspencer / createTestStore.js
Last active January 14, 2019 11:20
Redux Test Store
export const createTestStore = (
reducer,
initialState = {},
path = [],
thunkArguments = {}
) => {
const stateHistory = [];
const dispatchHistory = [];
const logHistory = store => next => action => {
@danrspencer
danrspencer / gist:0b75870b9c0d69fbc0a4011d68524edf
Created October 11, 2018 13:44
Open all pages for git commits matching regex
git log --grep "##regex##" --basic-regexp --pretty=format:%h | xargs -I '{}' open https://github.com/danrspencer/repo/commit/'{}'
@danrspencer
danrspencer / update.js
Created June 20, 2018 07:36
Use lenses to update state in reducers
const update = (lensGenerator, func) => (state, payload) =>
over(
lensGenerator(payload),
obj => ({ ...obj, ...func(payload, obj, state) }),
state
);
@danrspencer
danrspencer / fix_git_email.sh
Last active June 15, 2018 20:50
Fix Committer Email
#!/usr/bin/env bash
git config user.email "danrspen@gmail.com"
git filter-branch -f --env-filter '
NAME="Dan Spencer"
EMAIL="danrspen@gmail.com"
if [ "$GIT_COMMITTER_NAME" = "$NAME" ]
then
export GIT_COMMITTER_EMAIL="$EMAIL"
@danrspencer
danrspencer / fn.js
Last active June 29, 2017 11:04
Some functions to allow a more functional paradigm in js
export const compose = (...fns) =>
fns.reduce((f, g) => (...args) => f(g(...args)));
export const pipe = (...fns) => compose.apply(compose, fns.reverse());
export const partial = (fn, [args]) => (...moreArgs) =>
fn(...[args, ...moreArgs]);
@danrspencer
danrspencer / curry.js
Created June 5, 2017 09:28
Chicken Korma
function curry(func, ...args) {
return (...moreArgs) => func(...args, ...moreArgs);
}
const target = (a, b, c, d, e) => a+b+c+d+e;
const abTarget = curry(target, "a", "b");
const abcdTarget = curry(abTarget, "c", "d");
@danrspencer
danrspencer / setup-shell.sh
Last active August 31, 2023 14:41
Setting up shell on new machine
#!/usr/bin/env bash
# Setup the dev volume: https://brianboyko.medium.com/a-case-sensitive-src-folder-for-mac-programmers-176cc82a3830
set -e
# Install Brew
# https://brew.sh
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"