Skip to content

Instantly share code, notes, and snippets.

View DanCouper's full-sized avatar

Dan Couper DanCouper

  • Strive Gaming
  • Newcastle, UK
  • 06:10 (UTC +01:00)
  • X @DanCouper
View GitHub Profile
@DanCouper
DanCouper / index.html
Created May 23, 2017 20:38
React Calculator
<div id="wrapper">
<div id="app"></div>
</div>
@DanCouper
DanCouper / index.pug
Created May 23, 2017 20:49
React Calculator
#app
@DanCouper
DanCouper / controlled-slider.markdown
Last active May 26, 2017 08:23
Controlled slider
@DanCouper
DanCouper / calculator-spike.re
Last active June 5, 2017 10:41
Not really functional initial spike for a calculator processor
/**
* Dunno how to phrase this as I'm at a very early stage of learning OCaml/Reason,
* but I'm writing a calculator as first semi-complex toy app, and not sure if what
* I'm trying to do is completely wrongheaded (& if I'm making some futile attempt
* to replicate Erlang tagged tuple conventions using the OCaml type system).
* Calculator takes a sequential stream of inputs, and I need to parse those as
* they come in. To facilitate pattern matching, I wanted to set it up so that each
* input is a tuple of `type * displayValue`, eg `(Digit One, "1")` or
* `(Number Int, "1234")` or `(Op Div, "÷")`, so I can do basically all
* processing using the type system, and configure how the display looks by
/* ---------------------------
* Helpers
* --------------------------- */
/* `ReasonReact.stringToElement` is a little verbose, so alias it.
* NOTE this particular vagary get annoying quickly. */
let stringToEl = ReasonReact.stringToElement;
/* ReasonReact doesn't play nice with React Devtools. This is a pain
* point; for development, manually printing out the state turns out
* to be helpful: */
/*
Given two buckets of different size, demonstrate how to measure an exact number of liters by strategically transferring liters of fluid between the buckets.
Since this mathematical problem is fairly subject to interpretation / individual approach, the tests have been written specifically to expect one overarching solution.
To help, the tests provide you with which bucket to fill first. That means, when starting with the larger bucket full, you are NOT allowed at any point to have the smaller bucket full and the larger bucket empty (aka, the opposite starting point); that would defeat the purpose of comparing both approaches!
Your program will take as input:
the size of bucket one, passed as a numeric value
@DanCouper
DanCouper / right-margin.md
Created January 24, 2018 16:24
Spacemacs Notes

(referenced from syl20bnr/spacemacs#4856)

SPC t f to show the right margin line. By default this is set at 80 characters.

To activate for modes (for example):

;; Activate column indicator in prog-mode and text-mode
(add-hook 'prog-mode-hook 'turn-on-fci-mode)
(add-hook 'text-mode-hook 'turn-on-fci-mode)
defmodule MapExtras do
def take_strict!(map, keys) do
existing_keys = Map.keys(map)
case Enum.all?(keys, fn(k) -> Enum.member?(existing_keys, k) end) do
true -> Map.take(map, keys)
false -> raise "One or more of the keys passed does not exist in the map"
end
end
[
{
"name": "Instant Queue",
"videos": [
{
"id": 70111470,
"title": "Die Hard",
"boxarts": [
{
"width": 150,
@DanCouper
DanCouper / reset.css
Last active August 29, 2018 13:32
Getting sick of the copy/paste/minify/copy/paste dance for this
/* Force the correct box-sizing property: */
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
/* Remove margins/padding etc from everything: */
html, body, div, span, applet, object, iframe,