Skip to content

Instantly share code, notes, and snippets.

Bruno Bronosky RichardBronosky

Block or report user

Report or block RichardBronosky

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@RichardBronosky
RichardBronosky / create_systemd_service_unit.sh
Last active Apr 10, 2019
A slightly Raspberry Pi specific Systemd service unit example.
View create_systemd_service_unit.sh
service_name="sample.service"
service_desc="My Sample Service"
service_cmd="/usr/bin/python /home/pi/sample.py"
cat > /lib/systemd/system/$service_name <<EOF
[Unit]
Description=$service_desc
After=multi-user.target
@RichardBronosky
RichardBronosky / net-check.service
Last active Jan 30, 2019
watches a URL and logs it
View net-check.service
[Unit]
Description=Network Status Monitor
After=multi-user.target
[Service]
Type=idle
WorkingDirectory=/home/pi/
ExecStart=/bin/bash -c '/usr/local/bin/net-check.sh 15 https://gist.github.com/RichardBronosky/dd13161b72284c209c5b80d88f9cdb4a/raw/acdb3e2a6e3a55055aef16580e4e613e819d1f37/random-1m.txt >> /home/pi/net-check.log'
[Install]
@RichardBronosky
RichardBronosky / get_authorized_keys.sh
Created Jan 25, 2019
Get ssh keys for Raspberry Pi from GitHub
View get_authorized_keys.sh
sudo bash <<EOF
local_user=pi
github_user=RichardBronosky
umask 077
mkdir -p ~$local_user/.ssh
curl -sSL https://github.com/${github_user}.keys >> ~$local_user/.ssh/authorized_keys
chown -R $(id -u $local_user):$(id -g $local_user) ~$local_user/.ssh
EOF
@RichardBronosky
RichardBronosky / gist:1431516cdc378484942b6e2ffb8dd073
Created Jan 24, 2019
Undestroy vim on RPI Raspbian Stretch
View gist:1431516cdc378484942b6e2ffb8dd073
# This includes some apparent redundant calls to sudo.
# They are there to make sure that no mater which user executes these commands,
# both root and pi users get files with the right permissions.
# Fix bash
sudo -u pi touch ~pi/.bashrc
( sudo tee -a /home/pi/.bashrc | sudo tee -a /root/.bashrc > /dev/null ) << 'EOF'
set -o vi
export EDITOR=vim
@RichardBronosky
RichardBronosky / watcher.sh
Created Jan 18, 2019
watcher.sh runs a comand at an internal and speaks when the status changes.
View watcher.sh
#!/bin/bash
# TODO:
# This was a 5 minute hack.
# Currently assumes presence of `say` command (macOS). Make more OS tolerant. Possibly changing *_MSG to *_CMD
usage(){
cat<<USAGE
$0 runs a comand at an internal and speaks when the status changes.
Accepts optional ENV vars: SUCCESS_MSG and FAILURE_MSG
@RichardBronosky
RichardBronosky / stand-in.sh
Last active Jan 14, 2019
This is a stand in script for any command that might take stdin or arguments and logs everything.
View stand-in.sh
#!/bin/bash
(
echo -e "\n\n #### $(date) ####"
echo -e "\n## Exported Variables"
printenv
echo -e "\n## Local Variables"
( set -o posix ; set) | grep -vf <(printenv | sed 's/^/^/;s/=.*/=/')
View npm-build.sh
#!/bin/bash
# WHY?
# Because lambda function project directories tend to have unnecessary files (like tests, docs, etc.)
# This skips the cruft and zip up only these files:
# ./node_modules (This is recursive.)
# ./*.js (This is not recursive. All *.js files in the base directory are included, subdirectories are excluded.)
# ./*.json (This is not recursive. All *.json files in the base directory are included, subdirectories are excluded.)
# Note:
View .gitaliases
# to add these aliases, copy-pasta the following line (without the #):
# curl -L https://gist.githubusercontent.com/RichardBronosky/eb1cc18c8c23020face1fe1926d27978/raw/setup.sh | bash
[push]
# See: https://stackoverflow.com/a/23918418/117471
default = current
# Use SSH instead of HTTPS for github.com
[url "ssh://git@github.com/"]
insteadOf = https://github.com/
@RichardBronosky
RichardBronosky / agentrc
Created Dec 22, 2018
ssh-add keys in your bashrc
View agentrc
:<<'DOCS'
* This script ensures that your shell always has an agent with your preferred keys added.
On macos you do not need to start the agent explicitly. Just add the keys. If your key
requires a password, and it should, you will not be prompted for it again as long as
agent maintains your key. Simply putting ssh-add ~/.ssh/id_rsa in your .bash_profile
causes you to get prompted for your password for every shell and encourages people to
remove the password, which they shouldn't. This was created to solve that properly.
* Place this file at ~/.ssh/agentrc use it in ~/.bash_profile with:
[[ -f ~/.ssh/agentrc ]] && source ~/.ssh/agentrc
@RichardBronosky
RichardBronosky / assume-role
Last active Apr 17, 2019
A wrapper around https://github.com/remind101/assume-role that feeds in the MFA and caches.
View assume-role
:<<'DOCS'
* This script is a wrapper around https://github.com/remind101/assume-role that feeds
in the MFA and caches the token.
* Either: Place this file at ~/.aws/assume-role use it in ~/.bash_profile with:
[[ -f ~/.aws/assume-role ]] && source ~/.aws/assume-role
* Or: You can copy-paste the next 5 lines to get and use this script:
curl -sLo ~/.aws/assume-role https://gist.githubusercontent.com/RichardBronosky/4cdd0b462f6fc6a8700d1d6b7650e363/raw/assume-role
cat >> ~/.bash_profile <<'EOF'
You can’t perform that action at this time.