Skip to content

Instantly share code, notes, and snippets.

View paulmr's full-sized avatar

Paul Roberts paulmr

  • Guardian
  • London
View GitHub Profile
@paulmr
paulmr / x-shell-command
Created October 4, 2018 08:29
simple (fish) shell script to execute a command via an X dialog box
#!/bin/fish
set -l histfile ~/.x-shell-command-history
set -l lastcmd ""
if test -f $histfile
set lastcmd (cat $histfile)
end
@paulmr
paulmr / keybase.md
Created March 21, 2018 10:54
keybase.md

Keybase proof

I hereby claim:

  • I am paulmr on github.
  • I am paulmr (https://keybase.io/paulmr) on keybase.
  • I have a public key ASDkCIflwoPxEaoMW6rMUjLEzKeX33uGQgLAdj-XnCdTSwo

To claim this, I am signing this object:

@paulmr
paulmr / .bashrc
Last active January 31, 2018 09:46
run ssh agent or connect to exisiting
AGENT_DATA_PATH=~/.ssh/agent-data
function s {
. $AGENT_DATA_PATH
if ssh-add -l >/dev/null 2>&1
then
true
else
echo "not running"
ssh-agent >$AGENT_DATA_PATH
@paulmr
paulmr / advent02.sc
Created December 6, 2017 12:10
Advent 2017-02
// -*- mode: scala -*-
import scala.io.Source
def input(fname: String): List[List[Int]] = input(Source.fromFile(fname))
def input(in: Source): List[List[Int]] = in.getLines.toList.map(_.split("[\t ]+").toList.map(_.toInt))
def calc(data: List[List[Int]]) =
data.map(row => {
@paulmr
paulmr / patch
Created October 30, 2017 10:01
put st chips back in
diff --git a/def/flashepr.def b/def/flashepr.def
index 5e19937a..a483dfef 100644
--- a/def/flashepr.def
+++ b/def/flashepr.def
@@ -73,18 +73,21 @@ DEFC FE_I28F008S5 = $89A6 ; 1Mb memory, 16 x 64K erasable sectors, 64 x 16K ba
; ==========================================================================================
-; AMD Flash Memory constants:
+; AMD/STMicroelectronics Flash Memory constants:
@paulmr
paulmr / pmtest.js
Last active August 30, 2017 10:29
Testing prosemirror position mapping across steps of a transform
/* testing the prose mirror bits */
import jsdom from 'node-jsdom'
import { Document } from 'xmldom'
import { Node, DOMSerializer, DOMParser } from 'prosemirror-model'
import { EditorState } from 'prosemirror-state'
import * as basic from 'prosemirror-schema-basic'
const parser = DOMParser.fromSchema(basic.schema)
@paulmr
paulmr / advent11.erl
Last active May 4, 2017 08:22
Advent of Code 2016, Day 11
-module(advent11).
-export([main/1]).
-record(state, { elevator = 1, floors }).
-define(TOP_FLOOR, 4).
-define(LIMIT, 120).
%% some housekeeping funcs for creating items
-define(MICRO(Cat), { microchip, Cat }).
@paulmr
paulmr / advent25.erl
Last active May 4, 2017 07:53
Advent of Code 2015, Day 25
-module(advent25).
-export([main/1]).
-define(Start, {{1,1}, 20151125}).
nextN(Last) -> Last * 252533 rem 33554393.
nextXY({ X, 1 }) -> { 1, X + 1 };
nextXY({ X, Y }) -> { X + 1, Y - 1 }.
@paulmr
paulmr / advent21.erl
Created April 26, 2017 18:18
Advent of Code 2015, Day 21
-module(advent21).
-export([main/0, main/1]).
winner(PD, PA, BD, BA, PHP, BHP) ->
Req = BHP / max(1, (PD - BA)),
Avail = PHP / max((BD - PA), 1),
Req =< Avail.
-define(Weapons, [ { 8, 4, 0 },
{ 10, 5, 0 },
@paulmr
paulmr / advent18.erl
Created April 19, 2017 14:00
Advent of Code 2015, Day 18
-module(advent18).
-export([main/1]).
-record(state, { width, height, lights }).
deltas() ->
[ { X, Y } || X <- lists:seq(-1, 1), Y <- lists:seq(-1, 1), (X =/= 0) or (Y =/= 0) ].
neighbours(X, Y) ->
[ { X + Xd, Y + Yd } || { Xd, Yd } <- deltas() ].