Katriel Cohn-Gordon

Cyber security researcher at Oxford. Not nearly rational enough.

Read this first

flux and hue

[f.lux](www.justgetflux.com) is pretty awesome. Now that my room is lit by hue, I wanted a way to make my room colour temperature match my screen. This requires a few ingredients:

  • a working hue setup, obviously
  • some way to control the lights from the command line. You don’t actually need anything for this, since the bridge actually just accepts HTTP requests to set values, but it’s nice to have a wrapper so you don’t have to worry. I used hue-cli – which, beware, is not the only hue-cli package out there. It has a command hue lights all red which does what you expect
  • some way to get the desired colour temperature when the script is run. Ideally I’d use the f.lux one, and I’ve emailed the devs to ask, but in the meantime the open-source f.lux clone redshift will tell you what it thinks the colour should be given your current location. Note that f.lux has much more aggressive reddening

Continue reading →


appengine doesn’t work OOTB

Google App Engine for Python doesn’t work out of the box with Python 2.7.9 as of Jan 2014; you have to patch its fancy urllib overload.

Specifically, you get an error about an unexpected context argument, which is because the base AbstractHTTPHandler now allows more arguments in its do_open function which the child has to pass through.

To fix it, patch .../path/to/sdk/platform/google_appengine/lib/fancy_urllib/fancy_urllib/__init__.py.

Continue reading →


website hosting

I’m in the process of setting up cohn-gordon.org and cohn-gordon.com for my brother and me. They use a cute trick to host out of Dropbox and proxy via GAE, in order to get nice, fast, free websites.

 Step 1

We’re going to host the actual domain statically out of a Dropbox public folder. To do this, simply (create the Public folder in your Dropbox root if it isn’t already there then) make an index.html and copy the public link. Write this website as you will.

 Step 2

This now hosts your website on Dropbox, with a URL of the form dl.dropbox/com/u/.../index.html. We’ll run a proxy on GAE to create nice URLs. I used the shin1katayama fork of dropbprox, which uses index.html as the root of any directory if it isn’t specified. Follow the instructions on dropbprox to setup a new GAE app, clone the code, add your app ID to app.yaml and your Dropbox UID and index.html to mirror.py, and deploy.

Continue reading →


followupthen

For the next in the collection of “short blog posts with things that will make your life better”, I give you [followupthen.com](followupthen.com): forward any email to them and it’ll come back when you say.

For example, if you want a reminder to do something in two weeks, email twoweeks@followupthen.com (or the short version twoweeks@fut.io) and it’ll bounce back to you in two weeks.

If you want to make sure someone has replied within a day, bcc [tomorrow@fut.io](tomorrow@fut.io) and it’ll come back in a day.

If you want to get nagged every evening to do something, email tomorrow8pm-t@fut.io and it’ll come back every day until you clear it.

Etc, etc. Great service, and has the advantage over competitors like Mailbox or Boomerang that it works over email so mobile is as good as desktop.

Continue reading →


tmuxinator

A quick one: tmuxinator is a super-easy way to manage your tmux configurations, setting up windows and panes just as you like them. When set up, you just have to run

mux work

to connect to your “work” tmux session. Mine, for instance, opens up three different windows, for each of three projects I’ve been working on lately, and one editor window that I just use for command-line stuff, split into two panes.

To get it working just brew install tmux tmuxinator, and then run mux new work to set up a “work” tmuxinator config.

Continue reading →


iButton hackery

To get in to various places around Oxford, many places use little iButton fobs, which run on the Dallas Semiconductors 1-Wire protocol. When you tap them against a “master” device, they broadcast their unique ID, which the master can then look up in its list of people.

iButton fob

Kevin and I decided that this was excessively simple, and that we should build something to read and impersonate these fobs. Fortunately, the 1-Wire protocol they use is relatively standard, and there’s already an Arduino library to handle them.

The circuit you need is simple: connect some pin to a 4.7k resistor, +5v power and the centre of the fob, and ground the outside. Then run the following and the serial monitor should spit out the unique ID of any iButton you tap.

#include <OneWire.h>

// This is the pin with the 1-Wire bus on it
OneWire ds(PIN_D0);

// unique serial number read from the key
byte addr[8];

//

Continue reading →


Yosemite broke my git svn

Previously on Mavericks:

$ git svn rebase
Can't locate SVN/Core.pm in @INC (@INC contains: /usr/local/Cellar/git/1.8.4/lib /Library/Perl/5.16/darwin-thread-multi-2level /Library/Perl/5.16 /Network/Library/Perl/5.12/darwin-thread-multi-2level /Network/Library/Perl/5.16 /Library/Perl/Updates/5.16.4 /System/Library/Perl/5.16/darwin-thread-multi-2level /System/Library/Perl/5.16 /System/Library/Perl/Extras/5.16/darwin-thread-multi-2level/System/Library/Perl/Extras/5.16 .) at /usr/local/Cellar/git/1.8.4/libexec/git-core/git-svn line 41.

Solution: since the system Perl 5.16 contains SVN::Core, link it in from /Applications/Xcode.app/Contents/Developer/Library/Perl/5.16.

Now on Yosemite:

$ git svn rebase 
Can't locate SVN/Core.pm in @INC (you may need to install the SVN::Core module) (@INC contains: /usr/local/git/lib/perl5/site_perl

Continue reading →


latexmk and auctex

Compiling LaTeX is a pain. LaTeXmk is a Perl script (eww) which iterates compilations, including of the bibliography, until complete.

auctex-latexmk integrates it with AucTeX‘s C-c C-c cycle. You need to add the following to .latexmkrc (the former to stop the compilation process hanging when you make a mistake, and the latter because emacs doesn’t know how to tell latexmk to compile pdfs).

$pdflatex = 'pdflatex --shell-escape -interaction=nonstopmode -file-line-error -synctex=1 %O %S';
$pdf_mode = 1;

Other useful commands include

  • latexmk -C removes all automatically generated files
  • latexmk -pvc continuously recompiles

Continue reading →


zotero + emacs + latex = awesome

As a PhD student, I have to reference a lot of stuff, which I do with Zotero. It struck me a while ago that it would be nice if this integrated with my LaTeX editor of choice, and so I spent a morning doing just that. Now, I can add references straight from Firefox, and immediately add a BibTeX citation to them in Emacs with C-c [.

  1. Install Zotero and set it up.
  2. Install the fantastic AutoZotBib Zotero extension. Take care: it looks like a Firefox extension, but you install it from Zotero’s add-on menu not Firefox’s.
  3. Configure AutoZotBib to dump your Zotero library to a .bib file somewhere.
  4. Enable the RefTeX minor mode (which you should already have as part of Emacs). If using biber, you also have to tell RefTeX that \addbibresource gives the path to the bibliography.

    (add-hook 'LaTeX-mode-hook 'reftex-mode)
    (setq reftex-plug-into-AUCTeX t)
    (setq reftex-bibliography-commands

Continue reading →


ssh tunnels are magical

After getting the Pi connected upstairs, I figured it would be nice to be able to connect to it when I’m out and about. Now, I don’t have a static IP, and don’t really want to open ports to the Internet anyway, but I do have a shell account on the Oxford linux.ox.ac.uk machine. SSH tunnels to the rescue!

  1. Add linux.ox.ac.uk to the Pi’s ssh config

    ~/.ssh/config on the Pi

    Host ox
        User <me>
        HostName linux.ox.ac.uk
    
  2. Tell the Pi to autossh to ox on boot, and forward port 3141 there to port 22 here

    /etc/rc.local on the Pi

    su - pi -c 'autossh -f -N -R 3141:localhost:22 <me>@linux.ox.ac.uk'
    
  3. Add a ProxyCommand on my machine that tells ssh “if you want to ssh to pi, instead of making the TCP connection yourself instead do this.”

    ~/.ssh/config on my machine

    Host pi
        User pi
        ProxyCommand ssh raven nc -q0 localhost 3141
    

Et voilà, ssh pi on my local machine now connects

Continue reading →