Skip to content

Instantly share code, notes, and snippets.

View HaleTom's full-sized avatar
Using human learning for machine learning

Tom Hale HaleTom

Using human learning for machine learning
View GitHub Profile
HaleTom / aria2-trackers-update
Last active June 22, 2024 08:17
Update aria2.conf with 20 "best" BitTorrent trackers
# Update the bt-tracker= line in aria2.conf
# Any bt-tracker= lines are removed and and a new one added at the bottom of the file
# Updates at:
# Inspiration:
set -euo pipefail
shopt -s failglob
HaleTom /
Created September 11, 2019 07:53
Keybase identity proof

Keybase proof

I hereby claim:

  • I am haletom on github.
  • I am tomhale ( on keybase.
  • I have a public key ASA0UCq38IWRstxf9o5_HXYCzXjb7paM7SF7QfHRykoxsAo

To claim this, I am signing this object:

HaleTom / nnCostFunction.m
Created July 9, 2019 08:34
Matlab gradient descent - Coursera's Machine Learning ex4/nnCostFunction.m
function [J grad] = nnCostFunction(nn_params, ...
input_layer_size, ...
hidden_layer_size, ...
num_labels, ...
X, Y, lambda)
%NNCOSTFUNCTION Implements the neural network cost function for a two layer
%neural network which performs classification
% [J grad] = NNCOSTFUNCTON(nn_params, hidden_layer_size, num_labels, ...
% X, y, lambda) computes the cost and gradient of the neural network. The
% parameters for the neural network are "unrolled" into the vector
HaleTom / describe.m
Last active July 9, 2019 08:27
Matlab/Octave: describe a variable (name, type, size)
% Based upon
% Gist at:
function varargout = describe(varargin)
% varargin used to accommodate variable number of input names
st = dbstack;
outstring = '';
for ii = size(st, 1):-1:2
outstring = [outstring, st(ii).file, ' > ', st(ii).name, ', line ', num2str(st(ii).line), '\n'];
HaleTom /
Last active June 2, 2022 21:32
describe - line and filename, variable name, class, str representation and some other info
# Print the line and filename, function call, the class, str representation and some other info
# Inspired by
import inspect
import re
def describe(arg):
frame = inspect.currentframe()
callerframeinfo = inspect.getframeinfo(frame.f_back)
HaleTom / Test.ipynb
Last active November 25, 2017 15:09
Test .ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
HaleTom / pacman-backup
Last active March 9, 2017 11:42
Safely backup pacman's sync databases
# Safely backup the pacman databases to enable reversal of system upgrade.
# Use pacman -b <backupdirectory> to use the saved databses
# Latest version:
set -euo pipefail; shopt -s failglob # safe mode
HaleTom / update_table
Created October 4, 2016 09:06
Update vim's ":help compatible" table from source code extract
#!/bin/bash -eu
function get_decorated_options {
# option_extract > while read -r option;
while read -r line; do
name=$(printf %s "$line" | sed -rn 's/^\s*\{\s*"(\w+).*/\1/p')
# Get decoration
HaleTom / git-quote-string-multiline
Created October 1, 2016 03:21
Quote a single- or multi-line string for use in git's aliases
#!/bin/bash -eu
# Quote a single- or multi-line string for use in git's aliases
# Copyright (c) 2016 Tom Hale under
quote() {
printf %s "$1" | sed -r 's/(["\\])/\\\1/g';
IFS=$(printf '\n')
HaleTom /
Last active June 29, 2024 16:16
Print a 256-colour test pattern in the terminal
# Tom Hale, 2016. MIT Licence.
# Print out 256 colours, with each number printed in its corresponding colour
# See
set -eu # Fail on errors or undeclared variables