Skip to content

Instantly share code, notes, and snippets.

-- A comparison to https://chriswellswood.github.io/#blog/creating-simple-reusable-view-modules
import Html exposing (..)
import Html.Attributes exposing (style)
import Html.Events exposing (onClick)
main = Html.program
{ init = init
, view = view
@ckoster22
ckoster22 / tsconfig.json
Created May 24, 2017 01:19
tsconfig.json
{
"compilerOptions": {
"outDir": "./build/",
"sourceMap": false,
"strictNullChecks": true,
"noImplicitAny": true,
"noImplicitThis": true,
"alwaysStrict": true,
"module": "commonjs",
"target": "es5",
@ckoster22
ckoster22 / .flowconfig
Created May 24, 2017 01:20
.flowconfig
[libs]
flow-typed
@ckoster22
ckoster22 / Radar.elm
Last active June 10, 2017 20:10
Positioning blips on a tech radar
determineCoordinatesForRadar : List GoogleSheetBlip -> List PositionedBlip
determineCoordinatesForRadar blips =
List.foldl
(\blip ( accBlips, seed ) ->
let
generator =
accBlips
|> List.map .position
|> findCoordForBlip 0 blip
mockData : List GoogleSheetBlip
mockData =
List.range 1 4
|> List.map
(\quadrantNum ->
let
quadrant =
case quadrantNum of
1 ->
Tools
generateEvenValues : Int -> Generator (List Int)
generateEvenValues howMany =
Random.map
(\randInt ->
if randInt % 2 == 0 then
randInt
else
randInt + 1
)
(Random.int 1 99)
arc : Float -> Float -> Float -> Float -> Float -> Attribute msg
arc x y radius startAngle endAngle =
let
( startX, startY ) =
polarToCartesian x y radius endAngle
( endX, endY ) =
polarToCartesian x y radius startAngle
largeArcFlag =
triangleBlip : Position -> Svg msg
triangleBlip pos =
path
[ d "M412.201,311.406c0.021,0,0.042,0,0.063,0c0.067,0,0.135,0,0.201,0c4.052,0,6.106-0.051,8.168-0.102c2.053-0.051,4.115-0.102,8.176-0.102h0.103c6.976-0.183,10.227-5.306,6.306-11.53c-3.988-6.121-4.97-5.407-8.598-11.224c-1.631-3.008-3.872-4.577-6.179-4.577c-2.276,0-4.613,1.528-6.48,4.699c-3.578,6.077-3.26,6.014-7.306,11.723C402.598,306.067,405.426,311.406,412.201,311.406"
, transform <| "scale(" ++ toString (blipWidth / 34) ++ ") translate(" ++ toString (-404 + pos.x * (34 / blipWidth) - 17) ++ ", " ++ toString (-282 + pos.y * (34 / blipWidth) - 17) ++ ")"
]
[]
circleBlip : Position -> Svg msg
type Tab = {
label: string,
isActive: boolean,
onClick: (index: number) => void
};
type TabPanelProps = {
tabs: Tab[],
topIsHighlighted: boolean,
bottomIsHighlighted: boolean
};
type Border = "top" | "bottom";
let myBorder: Border = "top"; // Ok
myBorder = "bottom"; // Ok
myBorder = "left"; // Compiler error, broken guarantee prevented
myBorder = null; // Compiler error, broken guarantee prevented