Skip to content

Instantly share code, notes, and snippets.

View bshillingford's full-sized avatar

Brendan Shillingford bshillingford

View GitHub Profile
@bshillingford
bshillingford / remote.cpp
Created July 6, 2018 22:43
Arduino: IR remote data for Ambilight
// 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 April 14, 2017 05:25
really simple C++ single-header progress bar class
#include <iostream>
#include <chrono>
#include <ratio>
class progbar {
private:
int call_count = 0;
// formatting:
@bshillingford
bshillingford / log.h
Created April 14, 2017 05:23
really basic single-header C++ logging for one-off projects
#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 April 14, 2017 05:21
C++ numpy format deserializer
#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 March 1, 2024 12:50
arxiv2kindle: recompiles an arxiv paper for kindle-sized screens, and sends it to your wifi-enabled kindle
Loading
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 July 9, 2020 10:09
useful arxiv tools for bash
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 September 8, 2015 04:15
See test.lua for verification the new code works
--[[ 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
#!/bin/bash
##############################
# install Torch
# export PREFIX=/home/scratch/$USER/torch
export PREFIX="/home/scratch/torchshared/torch"
mkdir -p $PREFIX
rm -rf /tmp/luajit-rocks
"""
Google Directions API
"""
import urllib2
import urllib
import json
class Modes:
DRIVING="driving"
# -*- 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.