Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Chris Buttery chrisbuttery

🏠
Working from home
View GitHub Profile
@chrisbuttery
chrisbuttery / 1.js
Last active Aug 3, 2021
Fade in / Fade out
View 1.js
// fade out
function fade(el) {
var op = 1;
var timer = setInterval(function () {
if (op <= 0.1){
clearInterval(timer);
el.style.display = 'none';
}
el.style.opacity = op;
@chrisbuttery
chrisbuttery / README.md
Last active May 3, 2019
Track GA Events
View README.md

track-event

Delegate a listener for the blur() event, on document.

This component is predominantly used to record 'blur' events on form elements. However is flexible enough to be customised.

Installation

$ component install nib-components/track-event
View uninstall.sh
#!/bin/sh
set -e
echo "Warning: You are about to remove all Elm executables!"
installdir=/usr/local/bin
for bin in elm elm-compiler elm-get elm-reactor elm-repl elm-doc elm-server elm-package elm-make
do
@chrisbuttery
chrisbuttery / CountDown.elm
Last active Jun 22, 2018
A countdown timer in Elm : elm-lang http://elm-lang.org
View CountDown.elm
module CountDown where
import Graphics.Element exposing (..)
import Time exposing (..)
import String
-- MODEL
minutes = 1
seconds = 30
@chrisbuttery
chrisbuttery / index.js
Last active Mar 1, 2018
Control the flow of asynchronous calls with ES6 generator functions
View index.js
/**
* get - XHR Request
*/
let get = function (url) {
return function (callback) {
let xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.onreadystatechange = function() {
let response = xhr.responseText;
@chrisbuttery
chrisbuttery / Main.elm
Last active Jan 3, 2018
Elm 0.17. A simple Mouse.moves example
View Main.elm
import Html exposing (Html, text, div)
import Html.App as Html
import Mouse exposing (..)
main =
Html.program
{ init = init
, view = view
, update = update
, subscriptions = subscriptions
@chrisbuttery
chrisbuttery / Main.elm
Last active May 8, 2017
Elm 0.17. A simple Keyboard.presses example
View Main.elm
import Html exposing (Html, text, div)
import Html.App as Html
import Keyboard exposing (..)
import Char exposing (..)
main =
Html.program
{ init = init
, view = view
, update = update
@chrisbuttery
chrisbuttery / index.js
Last active Mar 20, 2017
Control the flow of asynchronous calls with ES6 generator functions
View index.js
/**
* get - XHR Request
*/
let get = function (url) {
return function (callback) {
let xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.onreadystatechange = function() {
let response = xhr.responseText;
@chrisbuttery
chrisbuttery / destructuring.md
Created Oct 23, 2016 — forked from yang-wei/destructuring.md
Elm Destructuring (or Pattern Matching) cheatsheet
View destructuring.md

Destructuring(or pattern matching) is a way used to extract data from a data structure(tuple, list, record) that mirros the construction. Compare to other languages, Elm support much less destructuring but let's see what it got !

Tuple

myTuple = ("A", "B", "C")
myNestedTuple = ("A", "B", "C", ("X", "Y", "Z"))

let
  (a,b,c) = myTuple
View main.elm
module Main exposing (..)
import Html exposing (..)
depth : number
depth =
10