Skip to content

Instantly share code, notes, and snippets.

View chrisbuttery's full-sized avatar
🏠
Working from home

Chris Buttery chrisbuttery

🏠
Working from home
View GitHub Profile
@chrisbuttery
chrisbuttery / 1.js
Last active April 6, 2024 16:10
Fade in / Fade out
// 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 05:05
Track GA Events

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
@chrisbuttery
chrisbuttery / uninstall.sh
Created November 29, 2015 00:16
Uninstall Elm
#!/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 June 22, 2018 08:25
A countdown timer in Elm : elm-lang http://elm-lang.org
module CountDown where
import Graphics.Element exposing (..)
import Time exposing (..)
import String
-- MODEL
minutes = 1
seconds = 30
@chrisbuttery
chrisbuttery / index.js
Last active March 1, 2018 05:19
Control the flow of asynchronous calls with ES6 generator functions
/**
* 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 January 3, 2018 17:15
Elm 0.17. A simple Mouse.moves example
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 03:42
Elm 0.17. A simple Keyboard.presses example
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 March 20, 2017 10:47
Control the flow of asynchronous calls with ES6 generator functions
/**
* 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 October 23, 2016 23:45 — forked from yang-wei/destructuring.md
Elm Destructuring (or Pattern Matching) cheatsheet

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
@chrisbuttery
chrisbuttery / main.elm
Created November 14, 2016 05:21
elm-pascal
module Main exposing (..)
import Html exposing (..)
depth : number
depth =
10