Skip to content

Instantly share code, notes, and snippets.

View lelandbatey's full-sized avatar

Leland Batey lelandbatey

View GitHub Profile
@lelandbatey
lelandbatey / circleci-retry-failing-workflow.bash
Created November 15, 2023 01:10
Re-run your latest failing CircleCI workflow for a given Github project till it succeeds
#!/bin/bash
# A script to re-run your latest failing workflow for a given Github project
# Examples:
#
# circleci-retry-failing-workflow.bash orgservice
#
# circleci-retry-failing-workflow.bash lichee
if [ $# -eq 0 ]; then
@lelandbatey
lelandbatey / goodluck.js
Created August 12, 2023 21:11
GOOD LUCK challenge
// A fun challenge; make it print your name, instead of mine : )
((G, O)=>O((D, __, LUCK)=>()=>{
console.log("from your friend: "+D(__)(LUCK));
})())("HAVE FUN",
(w) => {return w(
((window) => ((_)=>_(_))( (($)=>window( ((console)=>$($)(console)))))),
((N) => ((L)=> 6 ^ (~~L) ? String.fromCharCode(95-(31 & 924798803 >> 5 * L))+N((~~L)+1) : "\n")),
undefined)});
@lelandbatey
lelandbatey / cmdinfo.c
Created August 24, 2022 21:55
Prints a detailed view of all arguments. When you're confused about args, substitute in `cmdinfo` for a hex dump of every arg.
// Compile with:
// gcc ./cmdinfo.c -lm -o cmdinfo
#include <stdio.h> /* printf(), fprintf() */
#include <string.h> /* strcmp() */
#include <math.h> /* log10(), ceil() */
// fwd decl to cease warnings
int print_arguments(FILE* outf, int argc, char *const *argv);
int xxdline(int lineno, char* input, int inputlen, char* outbuf);
@lelandbatey
lelandbatey / goprintfuncs.go
Last active August 19, 2022 19:27
Print all functions in all Go source files under PATH
package main
import (
"fmt"
"go/ast"
"go/parser"
"go/token"
"io/fs"
"io/ioutil"
"log"
@lelandbatey
lelandbatey / rg-replace.bash
Created August 17, 2022 20:03
Replace all occurrences of "THIS" with "THAT" in all files in current directory and descendants
#!/bin/bash
# Originally based on ag-replace.sh:
# https://gist.github.com/adamryman/1de22e36a14c29da2f41c8512cb86b6d
usage() {
echo "Usage: $(basename $0) \"THIS\" \"THAT\"";
echo "Replaces all instances of THIS with THAT in all files which contain THIS."
echo "Additionally, prints each file as that file is modified"
exit 1;
@lelandbatey
lelandbatey / ag-replace.sh
Last active August 17, 2022 19:36 — forked from adamryman/ag-replace.sh
`ag --literal --case-sensitive "THIS"`, I want to replace all occurrences of "THIS" with "THAT". `Just do ag-replace "THIS" THAT"`
#!/bin/bash
usage() {
echo "Usage: $(basename $0) \"THIS\" \"THAT\"";
echo "Replaces all instances of THIS with THAT in all files which contain THIS."
echo "Additionally, prints each file as that file is modified"
exit 1;
}
@lelandbatey
lelandbatey / columnize.py
Last active August 9, 2024 13:12
columnize.py parses STDIN as column-based data, printing as nicely formatted columns
#!/usr/bin/env python3
#
# Copyright (c) 2022 Leland Batey. All rights reserved.
#
# This work is licensed under the terms of the MIT license.
# For a copy, see <https://opensource.org/licenses/MIT>.
"""
columnize.py reads column-oriented text data and prints that data as
nicely-padded columns to STDOUT. Input data *must* be line-oriented; data that
spans multiple lines will not be correctly understood and will not be correctly
@lelandbatey
lelandbatey / remove_csv_newlines.py
Created July 22, 2022 19:21
Remove all newlines from all cells of all rows and all columns of a CSV
#!/usr/bin/env python3
#
# Copyright (c) 2022 Leland Batey. All rights reserved.
#
# This work is licensed under the terms of the MIT license.
# For a copy, see <https://opensource.org/licenses/MIT>.
'''
Reads a CSV on stdin and writes a CSV on stdout. The output CSV should be
semantically identical to the input CSV, except that each cell will have
newline characters ('\n') replaced with an escaped newline ('\\n'). The
@lelandbatey
lelandbatey / timespans.py
Last active October 22, 2022 00:13
Code for visualizing overlapping named spans of time
'''
Timespan is code for visualizing timelines of events. We can show spans of time
on a timeline, as well as individual events.
The following is example code and what it prints:
>>> example_timespans = [
... TimeSpan(1647922287310, 1647922287564, 'A short thing happened'),
... TimeSpan(1648123040908, 1648123109165, 'a span of time where things happening'),
... ]
@lelandbatey
lelandbatey / stardew_animation_cancel.ahk
Created December 21, 2021 19:34
An autohotkey script for animation-canceling while playing Stardew valley.
; Stardew Valley animation cancel script
; Original from this post:
; https://forums.stardewvalley.net/threads/a-better-animation-canceling-autohotkey-script.7391/
; This version has been modified to be slightly more explicit about things like
; making sure that the Keyboard Hooks are in use.
; WARNING: make sure that the "Check/Do Action" control within the options of
; Stardew Valley is bound to a *DIFFERENT* key than the key that this script uses
; to trigger the animation canceling. If you have this script bound to the same
; key as the "Check/Do Action" key in-game, you'll face issues where holding down