Skip to content

Instantly share code, notes, and snippets.

Avatar

Bruno Bronosky RichardBronosky

View GitHub Profile
View based.linux.sh
#!/bin/bash
# gzip < hello_linux | base64 -b 76 > hello_linux.gz.base64
# :r !gzip < hello_linux | base64 -b 76
touch hello_linux; chmod +x hello_linux
( base64 -d | gunzip ) >hello_linux <<BASE64
H4sIAAGhdGAAA+1bb2gcxxWf+6N/kX06KXakWC6+OA5Rkmp9dmJFqe14T39XydlWHSltaZXJWXeS
Ltwf9W7PkVpobdS6HKlTlRLol0Ag+eBSAv1S4pSS2Mi1v5mEFmpoCsbEVG2aRIHWmEK0nZl9b29n
bpXaX0oL++Du7fvNezNv3s7evr2d9/3h5EgwECBIQfIk4ZIe1YWsA36u31FhWD9pZd9fIttJI5PD
Lj2d6BKfCxKJN4NeCOzOAn42qEt8O+ghD7h4mLhJl7gOjchJtGbX4JIJzA/5mzAAcred6CoGeEyX
@RichardBronosky
RichardBronosky / less
Last active Mar 22, 2021
A vim wrapper that allow you to use it for a pager, man reader, etc.
View less
#!/usr/bin/env bash
set -eu
cache_file="/tmp/pager.cache"
[[ ! -p "$cache_file" ]] && touch "$cache_file" && trap "rm $cache_file" 0
cat > "$cache_file"
vim -R -c "terminal cat $cache_file"
@RichardBronosky
RichardBronosky / Dockerfile
Created Jan 11, 2021
Jupyter notebook with bash kernel and ability to `su -` to install software
View Dockerfile
# https://docs.docker.com/engine/reference/builder/
# /home/jovyan/work
ARG BASE_CONTAINER=jupyter/minimal-notebook
FROM $BASE_CONTAINER
LABEL maintainer="Bruno Bronosky <bruno@bronosky.com>"
USER root
# Install all OS dependencies for fully functional notebook server
RUN pip install bash_kernel && python -m bash_kernel.install
@RichardBronosky
RichardBronosky / README.md
Last active Jan 4, 2021
A homebrew formula to build vim with support for pyenv version of python
View README.md

A homebrew formula to build vim with support for pyenv version of python

Build

  1. Patch /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/vim.rb
  2. Build
    brew reinstall --verbose --debug --build-from-source vim
  3. Locate your dynamic library with find /Users/bronoric/.pyenv/ -name '*libpython3*.dylib'
    • It's probably going to contain darwin in the path.
@RichardBronosky
RichardBronosky / nc.md
Created Nov 10, 2020 — forked from jtbonhomme/nc.md
Using Netcat for File Transfers
View nc.md

Netcat is like a swiss army knife for geeks. It can be used for just about anything involving TCP or UDP. One of its most practical uses is to transfer files. Non *nix people usually don't have SSH setup, and it is much faster to transfer stuff with netcat then setup SSH. netcat is just a single executable, and works across all platforms (Windows,Mac OS X, Linux).

Destination

On the receiving (destination) terminal, run:

nc -l -p 1234 > out.file 
@RichardBronosky
RichardBronosky / aws_token.py
Last active Nov 9, 2020
Convert the output of `aws sts get-session-token` to shell export statements
View aws_token.py
#!/usr/bin/env python
import json, re, sys
for k,v in json.load(sys.stdin)['Credentials'].items(): print("export AWS{}='{}'".format(re.sub('([A-Z])', r'_\1', k).upper(),v))
@RichardBronosky
RichardBronosky / vimcat.sh
Created Nov 2, 2020 — forked from echristopherson/vimcat.sh
Modified version of Matthew Wozniski's vimcat.sh
View vimcat.sh
#!/bin/bash
#!/usr/bin/env vim
#! This is a bash script that executes itself as a vimscript to do its work
#! vim:ft=vim:ts=2:sts=2:sw=2
: if 0
tmpfile=$(mktemp -t vimcat.XXXXXXXX)
exec 9<>"$tmpfile"
rm "$tmpfile"
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