Skip to content

Instantly share code, notes, and snippets.

View damncabbage's full-sized avatar
🙅‍♀️
permanent omnishambles

Robin Howard damncabbage

🙅‍♀️
permanent omnishambles
View GitHub Profile
RewriteEngine on
# Manual rewrites; see ###s below.
RewriteRule questions/ questions.php [NC,L]
RewriteRule questions questions.php [NC,L]
RewriteRule episodes/ episodes.html [NC,L]
RewriteRule episodes episodes.html [NC,L]

Backend (Elixir+Ruby) Developer at CancerAid

CancerAid is on a mission to help people who are undergoing cancer treatment understand their condition and take control of their journey. We're a funded startup focused on making people’s lives better. We’re looking for an backend developer to join our team and take the reins of our Elixir + Ruby apps and associated infrastructure, working primarily onsite at Chris O'Brien Lifehouse, near Newtown in Sydney.

The Company

CancerAid is a company founded by two radiation oncologists who were frustrated with the limitations of patient care tools available. They created CancerAid out of wanting to empower patient

@damncabbage
damncabbage / Examples.ex
Created June 6, 2018 08:50
Elixir "Traversing Error Mountain" Code Samples
defmodule Examples do
def zero do
files = ["abc.json", "def.json", "ghi.json"]
contents = files
|> Enum.map(fn (file) ->
File.read(file)
end)
# => [{:ok, "..."}, {:error, :enoent}, {:ok, "..."}]
@damncabbage
damncabbage / HaskellExample_Manual.hs
Last active May 7, 2018 13:48
Manual and TypeClass encodings of Show and Functor, in PureScript and Haskell.
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE NoImplicitPrelude #-}
-- Encoding and providing Show and Functor manually without using typeclasses.
module HaskellExample.Manual where
import qualified Prelude as Prelude
import Prelude (String, Int)
data Show a = Show {
show :: a -> String
@damncabbage
damncabbage / webpack.config.js
Last active April 16, 2018 00:30
Webpack Woe
module.exports = (env, argv) => {
let isProduction;
switch (argv.mode) {
case "production":
isProduction = true;
break;
case "development":
isProduction = false;
break;
default:
@damncabbage
damncabbage / file_utils.ex
Last active March 17, 2018 22:35
Dialyzer False "Positives" (Passes), showing how Dialyzer relies on call-site information to decide whether to consider something broken or not.
defmodule FileUtils do
# Reusable result union type.
@type result(good, error) ::
{:ok, good}
| {:error, error}
# Reusable list of file-access errors
@type file_errors :: :not_found | :permission_denied
# A sample usage that is... very broken.
@damncabbage
damncabbage / Identity.js
Last active April 15, 2018 01:05
Identity: Functor and Monad
function Identity(x) {
this.value = x;
}
// just a shortcut for "new Identity".
Identity.of = function(x) {
return new Identity(x);
}
// this.value is an A,
@damncabbage
damncabbage / proposal.md
Last active June 4, 2017 13:22
The DDDSydney submission that bounced.

JS Type-Checking Tools and Techniques

It's easy to make mistakes when writing code. We have some commonly-used tools to help us with this, with tests and linters, but there's more out there. Tools like Flow[1] and TypeScript[2] can be used to have the computer help us check our code, and can act as another protective barrier to bugs and blunders.

We'll explore types and type-checking with Flow. You'll see common bugs it catches and, step-by-step, will learn both how to use it, and how to reduce the number of tests you need to write. We'll then walk through more advanced techniques, using unions, wrappers, gatekeepers, phantoms, and other things besides to build a small robust app.

To enjoy this talk, you'll ideally have an intermediate-level understanding of JavaScript. We'll start easy with types and Flow, but will ramp it up as we go to keep things interesting if you're a more experienced user of either.

(Though this session uses Flow for its examples, but pretty much everything will be directly trans

@damncabbage
damncabbage / Scrabble.hs
Last active May 29, 2017 13:32
Scrabble (Hooroo Ruby Exercise, in Haskell and Ruby)
-- https://gist.github.com/elle/b9739bc21eb348916a60622f3fb6e2e4
module Scrabble (score) where
import Data.Char (toUpper)
import Data.List (concat)
import Data.Map as Map (Map, fromList, lookup)
import Data.Maybe (fromMaybe)
score :: String -> Int
score =
@damncabbage
damncabbage / ExNoodling1.elm
Last active April 22, 2017 14:05
Terrible experiments with Elm UI types.
module ExNoodling1 exposing (..)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
{-
type Authorised =
Authorised
| Unauthorised