Skip to content

Instantly share code, notes, and snippets.

Brendan Shillingford bshillingford

  • University of Oxford
  • Oxford, UK
View GitHub Profile
@bshillingford
bshillingford / remote.cpp
Created Jul 6, 2018
Arduino: IR remote data for Ambilight
View remote.cpp
// For Phillips Ambilight TV
#include <IRremote.h>
IRsend irsend;
// Raw data recorded from a few buttons:
unsigned int mute[40] = {2700,850,500,750,500,400,500,350,1350,1200,500,400,500,350,500,350,500,400,500,350,500,350,500,400,500,350,500,350,500,400,450,400,950,350,500,800,950,2850,50,};
unsigned int power[42] = {2700,850,500,750,500,400,500,350,1350,1200,500,400,500,350,500,350,500,400,500,350,500,350,500,400,500,350,500,350,500,400,450,400,950,350,500,800,500,350,500,2800,200,};
unsigned int netflix[38] = {2700,850,500,750,550,300,500,350,1400,1200,550,300,550,350,500,350,500,350,550,350,500,350,500,350,500,400,900,400,500,350,500,800,950,350,550,750,500,};
unsigned int smarttv[40] = {2700,800,500,800,500,350,500,350,1400,1200,500,350,500,350,500,400,500,350,500,350,500,400,500,350,950,800,950,350,500,350,500,400,500,350,500,800,500,2250,1200,};
@bshillingford
bshillingford / progbar.h
Created Apr 14, 2017
really simple C++ single-header progress bar class
View progbar.h
#include <iostream>
#include <chrono>
#include <ratio>
class progbar {
private:
int call_count = 0;
// formatting:
@bshillingford
bshillingford / log.h
Created Apr 14, 2017
really basic single-header C++ logging for one-off projects
View log.h
#ifndef _LOG_H_
#define _LOG_H_
// logging utils
//
#include <iostream>
#include <ctime>
#define LOG(level) ::log_internal::_log_helper<::log_internal::loglevel:: level >(__FILE__, __LINE__, __FUNCTION__)
@bshillingford
bshillingford / readnp.h
Created Apr 14, 2017
C++ numpy format deserializer
View readnp.h
#ifndef _READNP_H_
#define _READNP_H_
// Simple header-only library for loading serialized numpy arrays.
// Only for testing.
#include <algorithm>
#include <cassert>
#include <fstream>
#include <regex>
#include <string>
@bshillingford
bshillingford / arxiv2kindle.ipynb
Last active Sep 23, 2018
arxiv2kindle: recompiles an arxiv paper for kindle-sized screens, and sends it to your wifi-enabled kindle
View arxiv2kindle.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bshillingford
bshillingford / arxiv_bash_aliases.sh
Last active Mar 2, 2016
useful arxiv tools for bash
View arxiv_bash_aliases.sh
function arxiv-authors() {
if [ $# -ne 1 ]; then
echo "Usage: arxiv-authors arxiv_url_or_id"
echo "Prints authors' names, one per line."
else
if [[ $1 == http* ]]; then
url=$1
else
url=http://arxiv.org/abs/$1
fi
@bshillingford
bshillingford / lbfgs_new.lua
Last active Sep 8, 2015
See test.lua for verification the new code works
View lbfgs_new.lua
--[[ An implementation of L-BFGS, heavily inspired by minFunc (Mark Schmidt)
This implementation of L-BFGS relies on a user-provided line
search function (state.lineSearch). If this function is not
provided, then a simple learningRate is used to produce fixed
size steps. Fixed size steps are much less costly than line
searches, and can be useful for stochastic problems.
The learning rate is used even when a line search is provided.
This is also useful for large-scale stochastic problems, where
View 2015-01-16-practicals-install-torch.sh
#!/bin/bash
##############################
# install Torch
# export PREFIX=/home/scratch/$USER/torch
export PREFIX="/home/scratch/torchshared/torch"
mkdir -p $PREFIX
rm -rf /tmp/luajit-rocks
View directions.py
"""
Google Directions API
"""
import urllib2
import urllib
import json
class Modes:
DRIVING="driving"
View property_dict.py
# -*- coding: utf-8 -*-
__author__ = 'brendan'
import collections
class property_dict(collections.Mapping):
"""
Dictionary wrapper that adapts a dict with a wrapper allowing property-style reads. Intended
for ease of JSON accessing.
You can’t perform that action at this time.