Skip to content

Instantly share code, notes, and snippets.

@roine
roine / NumberRange.ts
Last active Oct 11, 2021
Range of numbers
View NumberRange.ts
type NumberRange<Min extends number, Max extends number> = _Range<Max, _Range1<Min,[Min]>>;
type _Range1<Min extends number, Acc extends unknown[]> = Acc['length'] extends Min ? Acc : _Range1<Min, [Min, ...Acc]>
type _Range<Max extends number, Range extends unknown[]> = Range['length'] extends Max
? Range['length']
: Range['length'] | _Range<Max, [Max, ...Range]>;
type FiveTo7 = NumberRange<5,7>
// 5 | 6 | 7
type OneTo7 = NumberRange<1,7>
View Debug.Extra.elm
module Debug.Extra exposing (viewModel)
import Html exposing (Html, p, pre, text)
import Html.Attributes exposing (style)
quote =
"\""
@roine
roine / Sample.elm
Last active Sep 23, 2018
Efficient (but less readable) checking if Leap Year. sample: https://ellie-app.com/3qN2Njbf2VWa1, source: https://stackoverflow.com/a/11595914/966187
View Sample.elm
isLeapYear : Int -> Bool
isLeapYear year =
Bitwise.and year 3 == 0 && (not (modBy year 25 == 0) || Bitwise.and year 15 == 0)
@roine
roine / 0_README.md
Last active Apr 8, 2021
Bare minimum for Elm 0.19
View 0_README.md

From 0.19 Elm introduced 4 ways to boot an app:

  1. sandbox (no outside interaction)
  2. element (simple outside interaction - side effect, flags, subscriptions)
  3. document (same as above but with title tag control)
  4. application (whole SPA features)
View keybase.md

Keybase proof

I hereby claim:

  • I am roine on github.
  • I am roine (https://keybase.io/roine) on keybase.
  • I have a public key ASDvAb8MA0QlE3KRNLrTECoLQHkKG0_g6V6zalgXio_UvAo

To claim this, I am signing this object:

View gist:e40afdd44d7fa421900b81a5917f001c
https://ellie-app.com/wmXvyWVYqza1/0
@roine
roine / Blocked by IE9
Created Nov 17, 2016
Non exhaustive list of features not supported by IE9
View Blocked by IE9
- Websocket
- Flexbox
@roine
roine / Confirm.elm
Last active Aug 22, 2016
confirm in ELM using Native
View Confirm.elm
module Confirm exposing (confirm)
import Native.Confirm
import Task exposing (Task)
confirm : String -> Task () ()
confirm str =
Native.Confirm.doConfirm str
@roine
roine / bumpversion.sh
Created Jun 6, 2016 — forked from pete-otaqui/bumpversion.sh
Bump a software project's VERSION, add the CHANGES, and tag with GIT
View bumpversion.sh
#!/bin/bash
# works with a file called VERSION in the current directory,
# the contents of which should be a semantic version number
# such as "1.2.3"
# this script will display the current version, automatically
# suggest a "minor" version update, and ask for input to use
# the suggestion, or a newly entered value.