Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
import pika
import time
import threading
import random
import json
import sys
# NOTE pika is not threadsafe, so any newly created threads should create a new connection within their own scopes
conn = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
@benwiz
benwiz / karabiner_caps-to-esc-ctrl.json
Created August 14, 2019 00:01
This snippet goes inside the `rules` array of ~/.config/karabiner/karabiner.json
{
"manipulators": [
{
"description": "Change caps_lock to control when used as modifier, escape when used alone (~/.config/karabiner/karabiner.json)",
"from": {
"key_code": "caps_lock",
"modifiers": {
"optional": [
"any"
]
@benwiz
benwiz / s3-sync
Created December 23, 2018 15:56
Sync a folder on my computer with an S3 folder in my S3 archive bucket
#!/bin/bash
# TODO: Should take `DEST_DIR` as a required input
aws s3 sync . s3://benwiz-archive/$DEST_DIR --profile personal --exclude "*node_modules/*" --exclude "*venv/*" --exclude "*.DS_Store"
@benwiz
benwiz / cronfile
Last active December 22, 2018 07:26
# sync bashrc, bash_profile, bash_alias on boot (every 3rd hour should be more than sufficient)
0 */3 * * * $HOME/code/backup_bash_configs/backup_bash_configs.sh &> /tmp/cronjob_logs
TARGET_DIR="$HOME/code/bash_configs"
# Copy .bashrc to general git repo
cp "$HOME/.bashrc" "$TARGET_DIR/bashrc"
# Copy .bash_profile to general git repo
cp "$HOME/.bash_profile" "$TARGET_DIR/bash_profile"
# Copy .bash_alias to general git repo
cp "$HOME/.bash_alias" "$TARGET_DIR/bash_alias"
# commit and push change
# ~/.bash_alias is a convention of my own design. All aliases (and functions?) should be placed in here.
# Then this file is sourced in ~/.bashrc.
# my local ip address
alias myip="ipconfig getifaddr en0"
# python & pip
alias pip=pip3
alias python=python3

Keybase proof

I hereby claim:

  • I am benwiz on github.
  • I am benwiz37 (https://keybase.io/benwiz37) on keybase.
  • I have a public key ASDd6AN_wVRCCwtI769nxZ9DAALG3ZAWeIqJqKvke2zhmwo

To claim this, I am signing this object: