Skip to content

Instantly share code, notes, and snippets.

@dlip
dlip / replay-stripe-events.sh
Created July 4, 2023 07:42
Replay stripe events bash script
#!/usr/bin/env bash
set -euo pipefail
LAST_EVENT=""
API_KEY=""
WEBHOOK_ENDPOINT=""
while true; do
OUTPUT=$(stripe --api-key $API_KEY events list --ending-before $LAST_EVENT --limit 100)
EVENTS=$(echo $OUTPUT | jq -r '.data[] | .id')
@dlip
dlip / he
Last active March 15, 2024 12:17
Helix exec: run command on current file with helix using zellij
#!/usr/bin/env bash
# Run command on current file with helix using zellij
# Requires https://github.com/helix-editor/helix/pull/6985
# eg. echo current filename
# :sh he echo
set -euo pipefail
# run command
zellij action write-chars ':'
# write shell command
zellij action write-chars "sh $@ "
@dlip
dlip / gcol.sh
Created June 4, 2020 00:59
Git checkout latest on a different branch without moving your HEAD twice
# Git checkout latest on a different branch without moving your HEAD twice
gcol() {
if [ -z $1 ]; then
echo "Error: Please provide branch name"
return
fi
git fetch
git branch -f $1 origin/$1
git checkout $1
}
@dlip
dlip / cloudSettings
Last active March 11, 2020 06:16
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-03-11T06:16:27.511Z","extensionVersion":"v3.4.3"}

readme

@dlip
dlip / corecloze.py
Created June 8, 2014 10:07
Converts this https://ankiweb.net/shared/info/702754122 Anki deck into a furigana cloze deck.
import re
debug = False
file = None
if debug:
file = open('test.txt', 'r')
else:
file = open('core10k.txt', 'r')
@dlip
dlip / cloze.py
Last active August 29, 2015 14:02
Generates cloze for japanese from regular reading card
import re
debug = False
file = None
if debug:
file = open('test.txt', 'r')
else:
file = open('core10k.txt', 'r')
@dlip
dlip / gist:2051ef4136e42e2b5e1c
Created May 11, 2014 02:30
Replaces variables in a template using shell script
#!/bin/bash
if [ $# -eq 0 ]
then
echo "Templater"
echo "Copies templates from one folder to another."
echo "Only replaces variables that exist in the environment"
echo "Usage: templater IN_FOLDER OUT_FOLDER"
exit 1
fi
@dlip
dlip / gist:11169293
Created April 22, 2014 07:57
Simple bash templating for nginx and docker
#!/bin/bash
REGISTRY_IP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' registry)
for f in *
do
if [[ "$f" != *\.sh ]]
then
config=$(<$f);
config=${config//REGISTRY_IP/$REGISTRY_IP};
printf '%s\n' "$config" >../sites-enabled/$f
@dlip
dlip / Capfile
Last active March 10, 2016 22:51
Capistrano 3 deploy notification email with git diff
require 'mail'