Skip to content

Instantly share code, notes, and snippets.

View scottwallacesh's full-sized avatar

Scott Wallace scottwallacesh

View GitHub Profile
@scottwallacesh
scottwallacesh / RSA_pubkey_to_PEM
Last active February 16, 2016 21:01
Create SSH public key in PEM format for OpenSSL encryption/decryption
openssl rsa -in ~/.ssh/id_rsa -pubout -out ~/.ssh/id_rsa.pub.pem
@scottwallacesh
scottwallacesh / RSA_encrypt_decrypt_strings_files_using_OpenSSL_and_RSA_SSH_keys
Created February 18, 2016 08:58
Encrypt and/or decrypt strings or files using OpenSSL and SSH RSA keys
# encrypt stdin
echo "secret" | openssl rsautl -encrypt -inkey ~/.ssh/id_rsa -out secret.enc
# encrypt file
openssl rsautl -encrypt -inkey ~/.ssh/id_rsa -in secret.txt -out secret.enc
# decrypt to stdout
openssl rsautl -decrypt -inkey ~/.ssh/id_rsa -in secret.enc
@scottwallacesh
scottwallacesh / build-mono.sh
Created October 5, 2016 14:49
Steps for building Mono v3.10 on an old Netgear ReadyNAS Ultra 4
# Compiling Mono for the ReadyNAS Ultra-4 running Debian 4.0 (etch)
## Requires modern version of GCC and binutils
# Somewhere to build
mkdir -p /c/src
# Fetch and build GCC & deps
cd /c/src
curl -O ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-4.9.4/gcc-4.9.4.tar.bz2
tar xvfh gcc-4.9.4.tar.bz2
@scottwallacesh
scottwallacesh / build-libmediainfo.sh
Last active October 7, 2016 07:45
Steps for installing libmediainfo on an old Netgear ReadyNAS Ultra 4
# Install libmms
apt-get install libmms0
# Fetch and compile libmediainfo
cd /c/src
curl -LO https://mediaarea.net/download/binary/libmediainfo0/0.7.89/MediaInfo_DLL_0.7.89_GNU_FromSource.tar.bz2
tar xvfh MediaInfo_DLL_0.7.89_GNU_FromSource.tar.bz2
cd MediaInfo_DLL_GNU_FromSource
./SO_Compile.sh
( cd ZenLib/Project/GNU/Library && make install )
@scottwallacesh
scottwallacesh / validate_ip.py
Created June 14, 2017 10:27
Small Python function to validate an IP address
def is_valid_ip(ip):
m = re.match(r"^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$", ip)
return bool(m) and all(map(lambda n: 0 <= int(n) <= 255, m.groups()))
@scottwallacesh
scottwallacesh / blockads.sh
Created June 29, 2017 08:29
Block ads using dnsmasq
#!/bin/bash
BLOCKADS=/etc/dnsmasq.d/blockads
# Create the directory
mkdir -p $(dirname ${BLOCKADS})
# Fetch the List Of Evil™
/bin/curl -sq "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=nohtml&showintro=0&mimetype=plaintext" | /bin/xargs -n1 -I@ echo "address=/@/127.0.0.1" > ${BLOCKADS}
@scottwallacesh
scottwallacesh / openwrt-blockads.sh
Created June 29, 2017 17:44
Script for OpenWRT ad blocking
BLOCKADS=/etc/dnsmasq.d/blockads
CONF=/etc/dnsmasq.conf
cat - << EOF > ${CONF}
conf-dir=$(dirname ${BLOCKADS})
EOF
# Create the directory
mkdir -p $(dirname ${BLOCKADS})

Keybase proof

I hereby claim:

  • I am scottwallacesh on github.
  • I am scottsome (https://keybase.io/scottsome) on keybase.
  • I have a public key ASAtKyQY5bvl0kxDTiF7K_D4WYkSvmXjIU7ezucIOB_gnAo

To claim this, I am signing this object:

@scottwallacesh
scottwallacesh / build-openwrt-nginx-ssl.sh
Last active May 26, 2020 16:00
Compile nginx with SSL for OpenWRT
# Pre-requisites
brew install gnu-tar gnu-getopt gnu-time gawk wget grep
# Case sensitive-filesystem
hdiutil create -size 20g -type SPARSE -fs "Case-sensitive HFS+" -volname OpenWrt OpenWrt.sparseimage
hdiutil attach OpenWrt.sparseimage
cd /Volumes/OpenWrt
# OpenWrt/LEDE source
git clone https://github.com/openwrt/openwrt.git
@scottwallacesh
scottwallacesh / determrand.py
Created November 9, 2018 09:46
Deterministic "random" numbers filter_plugin for ansible
# vim: set ft=python:
"""Deterministic "random" numbers jinja filter for ansible.
Place in filter_plugins/ to use.
"""
import random
def determrand(high, seed, low=0):