Skip to content

Instantly share code, notes, and snippets.

View henrik's full-sized avatar

Henrik Nyh henrik

View GitHub Profile
@henrik
henrik / iplayer_availability_time_on_tabs.user.js
Last active September 29, 2016 17:26
Tampermonkey (https://tampermonkey.net/) script to indicate on BBC iPlayer browser tabs when the episode becomes unavailable.
// ==UserScript==
// @name iPlayer better tabs
// @namespace http://henrik.nyh.se/
// @version 0.2
// @description Indicates on browser tabs when the episode becomes unavailable. Counts down if the tab is left open. Also strips title prefixes like "BBC iPlayer" so tabs show actual titles.
// @author Henrik Nyh
// @match http://www.bbc.co.uk/iplayer/*
// @match http://www.bbc.co.uk/programmes/*
// @grant none
// @updateURL https://gist.githubusercontent.com/henrik/c7ad3b90379a19f2c0164b3243c6b378/raw
@henrik
henrik / uninstalling_erlang_history.md
Last active March 16, 2017 09:34
Uninstall erlang-history

I wanted to uninstall erlang-history on OS X because of this issue.

This is what I did, essentially reversing the install instructions.

Note that file paths may vary with OS, installation method, versions etc.

  • Open /usr/local/Cellar/erlang/18.3/lib/erlang/lib/kernel-4.2/ebin/kernel.app in an editor and remove group_history from the modules list.
  • Recompile group.erl like so: cd /usr/local/Cellar/erlang/18.3/lib/erlang/lib/kernel-4.2/src; erlc group.erl
  • Move the compiled group.beam from src to ebin: cd ..; mv src/group.beam ebin/
  • Remove group_history.beam just to be tidy: rm ebin/grop_history.beam
@henrik
henrik / macos_sierra_upgrade.md
Last active February 28, 2017 21:25
macOS Sierra update: Ruby, Rails, homebrew, VirtualBox/Vagrant, Elixir etc.

My notes from updating to macOS Sierra, as a Ruby/Rails developer working in VirtualBox/Vagrant.

Homebrew

brew doctor told me to fix /usr/local ownership:

sudo chown -R $(whoami) /usr/local

It also said Error: Failure while executing: /usr/bin/otool -L /usr/bin/install_name_tool.

@henrik
henrik / first_uk_bus_prices.md
Last active January 13, 2017 19:35
Some "First UK" bus prices for my own reference. Since they don't publish them anywhere and their customer support can't provide a list…
Time Route and type Price
Fri 2016-06-24 ~15:40 Adult Single: Todmorden to Littleborough £2.90
Sat 2016-05-14 ~11:50 "HX / Hud [Halifax to Huddersfield?] Day O/P [off-peak day return?]" £3.90
@henrik
henrik / typed_elixir.ex
Created June 3, 2016 22:23
Silly experiment with a type-y syntax for Elixir method definitions. Not good for anything!
defmodule Lab do
defmacro deft({name, _, [{:::, _, [argthing, {_, _, [:Integer]}]}]}, do: block) do
quote do
def unquote(name)(arg) when is_integer(arg) do
var!(unquote(argthing)) = arg
unquote(block)
end
end
end
@henrik
henrik / socrates_uk_2016.md
Last active June 8, 2016 07:06
Some random notes from SoCraTes UK 2016. Not intended to be exhaustive summaries of each session.

SoCraTes UK 2016 notes

Discussion: Slack integrations

  • Idea: Use DnD with a timer for a pomodoro/pairing stint.
  • Enforce discipline in certain chat rooms, perhaps even have a code of conduct. E.g. no chat in notifications rooms; keep "for fun" discussions in a separate room.

Discussion: Admitting you don't know

  • When pairing, as a senior dev, you can slow down and ask the more junior dev to explain how this or that works.
@henrik
henrik / ab_test_false_negatives.rb
Last active May 25, 2016 19:34
A/B test simulations for my own learning.
# Simulating running an A/B test several times to see false negatives vs. statistical power.
# https://github.com/bmuller/abanalyzer
# gem install abanalyzer
require "abanalyzer"
# A converts at 50%. B converts at 66.66…%.
treatment_a = -> { [ "converted", "unconverted" ].sample }
treatment_b = -> { [ "converted", "converted", "unconverted" ].sample }
@henrik
henrik / tsb_memorable_information_autofill.tampermonkey.js
Last active December 21, 2018 17:12
Automatically fills out characters from your "memorable information" on TSB. For use with https://tampermonkey.net/ in e.g. Chrome.
// ==UserScript==
// @name TSB Memorable Information Autofill
// @namespace http://henrik.nyh.se/
// @version 0.1
// @description Automatically fills out characters from your "memorable information". Prompts for the full string the first time only. Intentionally fills out but doesn't submit, so you're in control.
// @author Henrik Nyh
// @match https://internetbanking.tsb.co.uk/personal/logon/login/
// @grant GM_setValue
// @grant GM_getValue
// @updateURL https://gist.githubusercontent.com/henrik/f7d25092582f64bf15925671692e8f49/raw
@henrik
henrik / screenhero_io.scpt
Created April 28, 2016 15:18
AppleScript to change Screenhero audio input/output device.
-- AppleScript to change Screenhero audio input/output device.
-- By Henrik Nyh for Auctionet.com 2016-04-28 under the MIT license.
--
-- Usage in a terminal, assuming this file is screenhero_io.scpt:
--
-- osascript screenhero_io.scpt "My desired input" "My desired output"
on run argv
set desiredInputDevice to item 1 of argv
set desiredOutputDevice to item 2 of argv
@henrik
henrik / sharing_attributes_with_prepend.rb
Last active April 25, 2016 05:10
Sharing attributes in Ruby with a single `prepend` instead of e.g. `include` + `merge`. Proof of concept. Too implicit for my taste, I think.
module SharedAttributes
def attributes
super.merge(shared: true)
end
end
class FooAttributes
prepend SharedAttributes
def attributes