Skip to content

Instantly share code, notes, and snippets.

View binarymason's full-sized avatar
👾
meep

John Mason binarymason

👾
meep
View GitHub Profile
set nocompatible
call plug#begin('~/.vim/plugged')
" Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'ekalinin/Dockerfile.vim'
Plug 'airblade/vim-gitgutter' " Shows a git diff in the gutter (sign column) and stages/undoes hunks
Plug 'altercation/vim-colors-solarized'
Plug 'bronson/vim-trailing-whitespace' " Highlights trailing whitespace in red and provides :FixWhitespace to fix it
Plug 'christoomey/vim-tmux-navigator' " Seamless navigation between tmux panes and vim splits
@binarymason
binarymason / backup.sh
Last active July 13, 2021 13:59
backup home directory
#!/bin/sh
rsync="/usr/bin/rsync"
################################
# VARIABLES
################################
# General Variables
backup_user="m"
source="/home/$backup_user"
@binarymason
binarymason / open_struct.py
Created February 26, 2021 22:05
OpenStruct in python
from collections.abc import MutableMapping
class OpenStruct(MutableMapping):
"""A dictionary that applies an arbitrary key-altering
function before accessing the keys"""
def __init__(self, props={}, **kwargs):
"""
You can pass a dictionary or a list of kwargs and they get merged into a single object
"""
@binarymason
binarymason / gimp-md5-watcher.sh
Created October 12, 2020 18:15
watch for "Untitled.png" file and automatically rename to md5
#!/usr/bin/env bash
set -e
inotifywait -r -m $HOME/pics/ -e create |
while read path action file; do
if [[ "$file" =~ Untitled.png ]]; then
for i in {1..3}; do
echo -n "."
#!/usr/bin/env bash
src=$(basename $1)
dest="hashed/${src}"
mkdir -p "$dest"
for fullfile in ${src}/*; do
filename=$(basename -- "$fullfile")
import numpy as np
import os
import sys
import tensorflow as tf
import glob
from PIL import Image
from tensorflow_utils import label_map_util, ops as utils_ops
import cv2
# from object_detection.utils import ops as utils_ops
@binarymason
binarymason / upload.rb
Last active June 27, 2020 12:15
upload multipart/form-data with net http
uri = URI("#{ODM}/task/new/upload/#{oid}")
request = Net::HTTP::Post.new(uri)
form_data = [
['images', attachment.tempfile, { filename: attachment.original_filename, content_type: attachment.content_type }]
]
request.set_form form_data, 'multipart/form-data'
response = Net::HTTP.start(uri.hostname, uri.port) do |http| # pay attention to use_ssl if you need it
http.request(request)
@binarymason
binarymason / get_zoom.py
Created October 27, 2019 12:12
Get the closest web mercator zoom for a raster input
import math
import sys
import rasterio
from rasterio.warp import (calculate_default_transform, transform)
CHUNK_SIZE = 256
@binarymason
binarymason / vid.sh
Created September 5, 2019 19:52
record audio/video on linux
ffmpeg -f alsa -i plughw:CARD=C525,DEV=0 -f video4linux2 -s 320x240 -i /dev/video0 -t 30 out.mpg
@binarymason
binarymason / .bash_history
Created August 22, 2019 17:15
bash history to setup pi hole
clear
git clone --depth 1 https://github.com/pi-hole/pi-hole.git Pi-hole
cd Pi-hole/
git branch
git checkout release/v4.3.2
git branch -v
git fetch
git checkout release/v4.3.2
git --version
git checkout origin release/v4.3.2