Skip to content

Instantly share code, notes, and snippets.

View aaronsnoswell's full-sized avatar

Aaron Snoswell aaronsnoswell

  • Australia
View GitHub Profile
@aaronsnoswell
aaronsnoswell / common-syllables.txt
Created February 5, 2022 12:59
The 322 most common syllables (ordered most common to least) in the 5000 most common English words
ing
er
a
ly
ed
i
es
re
tion
in
@aaronsnoswell
aaronsnoswell / process_large_csv.py
Created October 14, 2018 23:24
Incrementally process a CSV file that is too large to fit in memory
import csv
import itertools
import multiprocessing.pool
def process_large_csv(
filename,
per_row,
worker_pool,
@aaronsnoswell
aaronsnoswell / pytorch_mnist.py
Created October 6, 2018 05:02
A hello world example for PyTorch implementing a ConvNet for MNIST
"""A basic PyTorch ConvNet implementation on the MNIST dataset
From http://adventuresinmachinelearning.com/convolutional-neural-networks-tutorial-in-pytorch/
"""
import os
from torch.utils.data import DataLoader
import torchvision.transforms as transforms
import torchvision.datasets
@aaronsnoswell
aaronsnoswell / bokeh_test.py
Created October 6, 2018 03:27
A hello world example for the Bokeh plotting library
from bokeh.plotting import figure, output_file, show
import numpy as np
x = [1, 2, 3, 4, 5]
y = [6, 7, 2, 4, 5]
# Output to static HTML file
output_file("lines.html")
@aaronsnoswell
aaronsnoswell / dacadc.py
Created June 2, 2018 03:25
Multidimensional discrete <-> continuous conversions
# -*- coding: utf-8 -*-
"""Multidimensional discrete <-> continuous conversions
Copyright 2018 Aaron Snoswell
"""
import math
import collections
import numpy as np
@aaronsnoswell
aaronsnoswell / apt-get-movo-install.sh
Last active April 9, 2018 22:47
Bash script to download packages locally, then install them on a Kinova MOVO robot
#!/bin/bash
# Acts as a proxy for apt-get - downloads packages on the local (devlopment)
# machine, then copies them to movo1 and movo2 and installs them
# It is suggested you run this in a temporary folder, as it downloads packages
# to the current working directory
# Caveat: Your movo-dev machine must be running the same ubuntu version and
# architecture as the movo machines (14.x, x86_64), otherwise it won't grab the
# correct packages
@aaronsnoswell
aaronsnoswell / print-github-md.js
Last active April 8, 2018 03:45
Print GitHub Markdown Document
/* The below code is designed to be injected into any GitHub page with a
* markdown document, e.g. from a bookmarklet
*/
// Build list of parent and child elements (don't hide these)
var mdel = document.querySelector("article.markdown-body");
var el = mdel;
var els = [];
while (el) {
els.unshift(el);
@aaronsnoswell
aaronsnoswell / shalev-shwartz-batch-perceptron.py
Last active February 25, 2018 22:38
Demonstrates the batch_perception binary classification algorithm (Rosenblatt 1958)
"""
Demonstrates the batch_perception binary classification algorithm
(Rosenblatt 1958) from p190 of Shavel-Shwartz, 2014 "Understanding Machine
Learning"
Requires:
* Python 3
* numpy
* scikit-learn
* matplotlib
@aaronsnoswell
aaronsnoswell / toggle_vpn.bat
Last active March 2, 2018 04:04
Toggles a VPN, then does some other things (e.g. mount / unmount network drives)
@echo off
:: Toggles a VPN connection and does some other things
:: [e.g. connect/disconnect shared drives]
:: To set up a new VPN: type "rasphone /a" in the Run dialog [Win+R]
set vpn_name="EAIT VPN Connection"
ipconfig | find /i %vpn_name% && (
:: Disconnect VPN
net use G: /delete
@aaronsnoswell
aaronsnoswell / c-defined-operator-testcase.cpp
Last active January 11, 2018 06:29
Minimal test-case for undefined compiler behaviour when using the C/C++ defined() operator
/**
* Simple testcase for compiler-specific behaviour with the defined() C++ operator
* The spec states that if defined() appears as part of macro expansion, the behaviour is undefined
*
* On GNU cpp treats it as a genuine define() operator. Visual C++ doensn't.
* This generates many warnings when compiling e.g. the BSON library under Windows
*
* See https://gcc.gnu.org/onlinedocs/cpp/Defined.html for details
*
* On Visual C++ this program generates the following;