Skip to content

Instantly share code, notes, and snippets.

View aaronsnoswell's full-sized avatar

Aaron Snoswell aaronsnoswell

  • Australia
View GitHub Profile
@aaronsnoswell
aaronsnoswell / gist:3921992
Created October 20, 2012 04:17
Fast Unit Vector Normalisation for Discrete Spaces
// Really (really) fast unit vector normalisation
var c = 0.7071067812;
if(v[X] != 0 && v[Y] != 0) {
v[X] *= c, v[Y] *= c;
}
@aaronsnoswell
aaronsnoswell / particle_filter.c
Created November 28, 2013 05:20
Simple example of a particle filter
/**
* particle_filter.c - A simple demonstration of a particle filter
*
* Example adapted from
* http://web.mit.edu/16.412j/www/html/Advanced%20lectures/Slides/Hsaio_plinval_miller_ParticleFiltersPrint.pdf
*
* Suppose you're trying to tell if it is rainy or sunny outside (a system
* with two possible states), but you can't see out any windows. The only
* information you have is observations you make as your boss periodically
* walks by your room; he will either be carrying an umbrella, or not carrying
@aaronsnoswell
aaronsnoswell / svg2png.sh
Created November 28, 2013 11:10
Convert SVGs to PNGs recursively
#!/bin/sh
# Convert .svg files to .png - works on a single file or
# recursively on the given directory.
# Requries ImageMagick's `convert` function
# Author: Aaaron Snoswell
density=${2-72}
function convertsvg () {
@aaronsnoswell
aaronsnoswell / cv_pick_points.py
Created December 27, 2017 08:42
Prompt a user to interactively pick N points using OpenCV and Python
"""
Prompts the user to pick num_points from the figure displayed in window_name
Promts the user to pick points from a displayed image. Users can cancel the
point selection by pressing Escape.
Args:
window_name: The name of the window the user should pick from
num_points: Number of points the user should pick (defaults to 4)
mouse_event: The event to use for picking points (defaults to left
Message Type ROS to UE4 UE4 to ROS
sdf
sdf sfdsf
@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;
@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 / 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 / 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 / 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