Skip to content

Instantly share code, notes, and snippets.

Avatar

Bruno Bronosky RichardBronosky

View GitHub Profile
View evernote_code_block_without_double_empty_lines.sh
#!/bin/bash
convert_text(){
python3 -c 'import html, sys; [print(html.escape(l), end="") for l in sys.stdin]' | \
sed -E $'
1i\\\n<span style="-en-clipboard:true;"><br/></span><div style="-en-codeblock:true;"><div>\n
s, ,\&nbsp;,g
s,$,<br/>,
s,^<br/>$,<div><br/></div>,
$a\\\n</div></div>\n
@RichardBronosky
RichardBronosky / gtop.sh
Created Jul 2, 2020
grepped top (top, limited to commands filtered via regex arg)
View gtop.sh
# only tested on macOS
gtop(){ pattern="${1:-WindowServer}"; top $(ps -haxl | awk '/'"$pattern"'/{print "-pid " $2}'); }
gtop Chrome
@RichardBronosky
RichardBronosky / add_ip_to_ipset.sh
Created Jun 30, 2020
Add IP to AWS WAF IP set via CLI
View add_ip_to_ipset.sh
#!/usr/bin/env bash -eux
function usage(){
cat<<USAGE
NAME
add_ip_to_ipset - Add a single IP to a WAF IP Set
SYNOPSIS
add_ip_to_ipset IP IP_SET_NAME
@RichardBronosky
RichardBronosky / neo
Created Jun 29, 2020
Script for toggling my Raspberry Pi NeoPixel chromakey ringlight
View neo
#!/usr/bin/env python3
"""Script for toggling my Raspberry Pi NeoPixel chromakey ringlight
Usage:
activate with default power of 64/256:
./neo
activate full power:
./neo 64
deactivate:
./neo off
@RichardBronosky
RichardBronosky / aws.setup-credentials.sh
Last active Jun 11, 2020 — forked from sobi3ch/aws.setup-credencials
After downloading default user accessKeys.csv file from AWS console you can setup default profile with following bash function
View aws.setup-credentials.sh
#!/bin/bash -eu
aws.setup-credentials(){
local FILE="${1:--/dev/null}"
local file_paths_to_check=(
"$FILE"
"./accessKeys.csv"
"$HOME/accessKeys.csv"
"$HOME/Downloads/accessKeys.csv"
)
@RichardBronosky
RichardBronosky / README.md
Last active May 14, 2020
A bash plugin to manage plugins
View README.md

bash-bashplug

A bash plugin to manage plugins

Installation

Set up bash_plugins folder

(Skip this step if you already have a bash_plugins folder.)

{
# simply copy-pasta this whole block, or customize these vars and copy-pasta the rest
@RichardBronosky
RichardBronosky / README.md
Last active May 14, 2020
A bash plugin to make cd better
View README.md

bash-cdl

A bash plugin to make cd better

Installation

Set up bash_plugins folder

(Skip this step if you already have a bash_plugins folder.)

{
# simply copy-pasta this whole block, or customize these vars and copy-pasta the rest
@RichardBronosky
RichardBronosky / README.md
Last active May 14, 2020
A bash plugin to make files executable
View README.md

bash-plusx

A bash plugin to make files executable

Installation

Set up bash_plugins folder

(Skip this step if you already have a bash_plugins folder.)

{
# simply copy-pasta this whole block, or customize these vars and copy-pasta the rest
@RichardBronosky
RichardBronosky / DEMO1-handlebar_templates_via_argument.sh
Last active Mar 26, 2020
All other examples of rendering handlebars.js (double braces) templates in bash are way too complicated to put into a script
View DEMO1-handlebar_templates_via_argument.sh
#!/bin/bash
# This function works with both GNU/Linux and macOS/BSD version of sed and grep
# Inspired by https://github.com/relaxdiego/renderest
render(){
local template="$*"
for varname in $(<<<"$template" grep -oE '\{\{([A-Za-z0-9_]+)\}\}' | sed -En 's/.*\{\{([A-Za-z0-9_]+)\}\}.*/\1/p' | sort | uniq); do
template="$(<<<"$template" sed -E "s/\{\{$varname\}\}/$(sed 's_\\_\\\\\\\\_g;s_/_\\/_g' <<<"${!varname}")/g")"
done
@RichardBronosky
RichardBronosky / README.md
Created Feb 11, 2020
Pattern for using `main` and `exports` in Node.js
View README.md

Pattern for using main and exports in Node.js

Demo

~/src/node-playground(master#%)[0]
$ cat example-main_and_exports.js
#!/usr/bin/env node

const lib = require('./lib.js')
You can’t perform that action at this time.