Skip to content

Instantly share code, notes, and snippets.

@stvhwrd
stvhwrd / itermcolors.xml
Created August 3, 2018 02:06
My iTerm colour scheme - save file as stvhwrd.itermcolors and open with iTerm2
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.20312860608100891</real>
@stvhwrd
stvhwrd / manual-squash-commit.md
Last active April 3, 2020 19:10
Local steps for a nice clean squashed git commit.

Squashing git commits into one atomic commit

See Git-Branching-Rebasing for the built-in way. Here's how to do it manually:


Preconditions: On a new branch, forked off of develop and now ready to merge back into develop.

  1. Fetch updates from remote
@stvhwrd
stvhwrd / 1. test-setup.sh
Last active April 8, 2018 08:20
Super basic test scripts for modifications to Homebrew's `brew search`. Run from directory as `./test-setup.sh && ./test-search.sh`
#!/usr/bin/env bash
ORIGINAL="Homebrew-brew"
MY_FORK="stvhwrd-brew"
# --------------------------------Setup------------------------------------ #
rm -rf /tmp/${MY_FORK}.txt && \
rm -rf /tmp/${MY_FORK} && \
git clone https://github.com/SENG480-18/brew.git /tmp/${MY_FORK}
/tmp/${MY_FORK}/bin/brew tap homebrew/core
@stvhwrd
stvhwrd / pia-openvpn-tunnelblick.sh
Last active January 28, 2018 21:37
[WIP] Install and/or update Private Internet Access' available OpenVPN config with Tunnelblick on macOS
#!/bin/env bash
echo "This script is a work in progress." @DEBUG
# Assumes that wget is installed.
echo "Install configurations for all Users?"
# Move config files to (i) user directory or (ii) all-users directory, based on user's input
# Download and unzip config files
wget https://www.privateinternetaccess.com/openvpn/openvpn.zip -P /tmp
@stvhwrd
stvhwrd / entropy.py
Created January 24, 2018 03:36
An entropy calculator for UVic SENG 474 - Data Mining
'''An entropy calculator for UVic SENG 474 - Data Mining'''
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from math import log
def main():
'''Calculates the entropy H(X) for the data in a given attribute'''
num_attr = int(input("How many classes in the attribute?\n"))
num_el = int(input("How many elements (eg. total cardinality) in the attribute?\n"))
@stvhwrd
stvhwrd / Vultr Ubuntu startup script.sh
Last active November 22, 2021 14:11
Setting up a general web dev Ubuntu VPS
# Startup script for Ubuntu 17.04 VPS on Vultr (Dev machine and cloud server)
# add a new user @todo: make this a one-liner
# adduser stvhwrd
# usermod -aG sudo stvhwrd
## MANUALLY LOG OUT AS ROOT AND LOG IN AS NEW USER
# OPTIONAL: to add ssh key, assuming that you have ssh-copy-id installed on local machine and your keypair is in ~/.ssh and named id_rsa:
# Locally, i.e. on your laptop. eg. ssh-copy-id stvhwrd@45.63.10.205
@stvhwrd
stvhwrd / SENG321-quiz3.md
Created March 21, 2017 21:18
formal languages and specifications

Formal Languages and Specifications

Validation criteria is to discover and understand all requirements and domain properties.

Verification criteria is to verify that the program satisfies the specification, and the specification, given the domain properties, satisfies the requirements.

Definition and overview of formal methods

A broad view of formal methods includes all applications of discrete mathematics to software engineering problems. This application usually involves modelling and analysis where the models and analysis procedures are derived from or derived by an underlying mathematically-precise foundation.

@stvhwrd
stvhwrd / gist:e1c118b3f0c8c9d79089b5a25d958a8e
Created February 25, 2017 19:44
/etc/network/interfaces content for assigning a static ip to local machine
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
# The primary network interface
auto enp0s25
iface enp0s25 inet static
address 192.168.0.101
netmask 255.255.255.0
gateway 192.168.0.1
@stvhwrd
stvhwrd / setup_tmux_zsh.sh
Last active July 9, 2020 04:20
Install tmux and zsh on a remote server without root
#!/usr/bin/env bash
# Connect to the server..
# ssh username@server_ip
mkdir ~/.local;
# Download source and build libevent
cd /tmp;
wget https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz;
tar xvfz libevent-2.1.8-stable.tar.gz;
@stvhwrd
stvhwrd / tunnelblick.sh
Created February 22, 2017 03:48
Connect to / disconnect from VPN server via Tunnelblick on the macOS command line
# Connect to VPN configuration, usage: vpn_connect "US Seattle";
vpn_connect() {
osascript -e "tell application \"Tunnelblick\"" -e "connect \"$1\"" -e "end tell"
}
# Disconnect from all Tunnelblick connections, usage: vpn_disconnect;
vpn_disconnect() {
osascript -e "tell application \"Tunnelblick\"" -e "disconnect all" -e "end tell"
}