Skip to content

Instantly share code, notes, and snippets.

Avatar

David Baynard dbaynard

View GitHub Profile
@dbaynard
dbaynard / git-review.sh
Created Feb 11, 2019
Pull github PRs for review
View git-review.sh
#!/usr/bin/env zsh
#
# Review github PRs.
#
# This script makes reviewing github PRs simple. Supply the requester's branch
# in the form it is presented at the top of the PR on github (i.e. user:branch).
# This adds:
#
# - a new remote corresponding to the user, with only the PR branch
# - a new local branch (unless a branch with that name exists already, in
View jindosh.lhs
---
title: Jindosh puzzle
author: David Baynard
date: 16 Jan 2019
fontfamily: libertine
csl: chemical-engineering-science.csl
link-citations: true
abstract: |
...
@dbaynard
dbaynard / diagonal-span.hs
Last active Dec 17, 2018
A correct-by-construction AST representation of typographic tables, using diagonalization
View diagonal-span.hs
-- |
-- Module : diagonal-span
-- Copyright : David Baynard 2018
-- License : BSD-3-Clause OR Apache-2.0
--
-- Maintainer : haskell@baynard.me
-- Stability : experimental
-- Portability : unknown
--
-- A proposal for a correct by construction abstract syntax tree for pandoc
@dbaynard
dbaynard / Forestay.lhs
Created Nov 25, 2018
Haskell snippets
View Forestay.lhs
---
title: Forestay
author: David Baynard
date: 05 Jun 2017
fontfamily: libertine
csl: chemical-engineering-science.csl
link-citations: true
abstract: |
...
@dbaynard
dbaynard / humble.md
Created May 31, 2018
Downloading purchases (pdf books) from humble bundle
View humble.md

Super hacky, original method

Requires

  • jq
  • pandoc
  • Browser with dev tools (much easier than navigating source)
  • aria2c for batch downloading
  • text editor with f&r
  1. Go to purchase page.
View snapshot.yaml
resolver: lts-13.5
name: 8.6.3-13.5-baynard-snapshot
compiler: ghc-8.6.3
packages:
- git: https://github.com/jameysharp/corrode
commit: 34053342c2f1ca04f23ad94d67057f14e74d9fb9
- git: https://github.com/mgattozzi/curryrs
commit: 6d3ecbc3d1786ccc16e2ff20c6d6da53734f6b03
View passhte.lhs
---
title: passhte
author: David Baynard
date: 22 May 2017
fontfamily: libertine
csl: chemical-engineering-science.csl
link-citations: true
abstract: |
Paste over ssh
...
@dbaynard
dbaynard / Takeover-website.md
Last active Aug 14, 2016
Incremental API takeover
View Takeover-website.md

Ever been faced with an old website that needs an upgrade best done incrementally? At http://www.parsonsmatt.org/2016/06/24/take_over_an_api_with_servant.html, Matt Parsons describes an approach to incrementally take over an old API using Servant and a reverse proxy, which is worth a read!

On occasions, though, your predecessor may not have written a considered, documented API. Sometimes all that exists is a sprawl of tangled php, html and javascript that just about works, until there’s a change in business logic and the code gets touched — at which point everything breaks. Unlike the example in Matt’s post, it has an index.php route with all the pages at index.php?page=<PAGE>, instead of using path pieces separated by solidus.

Matt’s approach works in this case too, and we don’t even need to change the haskell server he supplies! We simply change how we use the reverse proxy and add some url rewriting middleware.

This example copies Matt’s woofing and meowing server, for simplicity of comparison.

@dbaynard
dbaynard / Fix-encoding.md
Last active Jul 18, 2016
Fix latin1 encoding issues (mysql in particular) using vim
View Fix-encoding.md

Fix encoding issues (e.g. ’ ~ ’)

WARNING: You must copy the commands from the raw version of this document. The markdown converter doesn’t like it…

Do you have a file with weird encoding errors? Perhaps instead of you have á^€™. The cause is a mix up between latin1 (usually — and especially if mysql is involved — the windows cp1252 encoding) and utf8.

Many solutions drop bytes. This has the advantage that you can see every change that is made, as it happens, should you wish.

It requires the file to be encoded in ISO 8859–1.

@dbaynard
dbaynard / gist:8807189
Last active Aug 29, 2015
Convert an RTF from ApE to LaTeX using vim
View gist:8807189

RTF (ApE) -> LaTeX

Eventually, this will become a script. Until then…

Mostly automated

First, find all strings of bases (except the last)

/\v([0-9]*1) .{-} ([0-9]*0)/e
You can’t perform that action at this time.