Skip to content

Instantly share code, notes, and snippets.

View halfzebra's full-sized avatar

Eduard Kyvenko halfzebra

View GitHub Profile
@halfzebra
halfzebra / SassMeister-input.scss
Last active October 14, 2015 13:33
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
li {
@for $i from 1 through 8 {
&:nth-of-type(#{$i}) {
transition-delay: 0.1s * $i;
}
}
@halfzebra
halfzebra / ripple.css
Created October 15, 2015 07:16
JS Button Ripple Effect
.button {
background: #000000;
color: #ffffff;
line-height: 32px;
font-size: 16px;
max-width: 100px;
width: 100%;
text-align: center;
cursor: pointer;
position: relative;
{
// http://eslint.org/docs/rules/
"ecmaFeatures": {
"arrowFunctions": false, // enable arrow functions
"binaryLiterals": false, // enable binary literals
"blockBindings": false, // enable let and const (aka block bindings)
"classes": false, // enable classes
"defaultParams": false, // enable default function parameters
"destructuring": false, // enable destructuring
@halfzebra
halfzebra / Ports.js
Created April 4, 2016 15:27 — forked from evancz/Ports.js
Example usage of Elm "ports" that uses signals, non-signals, records, and tuples. Build the Elm code with "elm --only-js Shanghai.elm" and include all of the JS in the HTML document.
// initialize the Shanghai component which keeps track of
// shipping data in and out of the Port of Shanghai.
var shanghai = Elm.worker(Elm.Shanghai, {
coordinates:[0,0],
incomingShip: { name:"", capacity:0 },
outgoingShip: ""
});
function logger(x) { console.log(x) }
@halfzebra
halfzebra / Actions.elm
Created April 5, 2016 22:31
Exposing union type in Elm
-- module Actions (Action(NoOp, UpdateModel))
module Actions (Action(..))
where
type Action
= NoOp
| UpdateModel Int
@halfzebra
halfzebra / TestMaybe.elm
Last active April 15, 2016 19:08
Maybe.withDefault crashes every time, because it evaluates both branches first
import Graphics.Element exposing (show)
import Debug
import Maybe exposing (..)
main =
-- Maybe.withDefault crashes every time, because it evaluates both branches first, before passing them to case
-- https://github.com/elm-lang/core/blob/4.0.0/src/Maybe.elm#L51
show (withDefault (Debug.crash "Test") (Just 1))
@halfzebra
halfzebra / UpdateDict.elm
Created May 5, 2016 21:41
Generalized function to handle updates of the Dictionary
import Graphics.Element exposing (show)
import Dict exposing (Dict)
type alias Model = Dict String Int
initModel : Model
initModel =
Dict.fromList
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
#input {
border: 0;
clip: rect(0 0 0 0);
@halfzebra
halfzebra / requirejs.logger.js
Created August 29, 2016 10:17
Intercept requirejs calls and output info to console
// Alternative https://gist.github.com/nantunes/c4eb68c32843ccd43c7b
window.require = new Proxy(window.require, {
apply: function (target, thisArg, argumentsList) {
console.log('require call to \n ' + argumentsList[ 0 ].join('\n ') + '\n\n');
return target.apply(thisArg, argumentsList);
}
});
@halfzebra
halfzebra / handlebars-template-name-comment.js
Created August 30, 2016 11:08
Print HTML comment with template name
Handlebars.templates = new Proxy(Handlebars.templates, {
get: function (target, property) {
var TEMPLATE_KEY = '<!-- TEMPLATE: Teamplates/' + property + '.handlebars -->\n'
var method = target[ property ];
if (typeof target[ property ] === 'function') {
return new Proxy(method, {
apply: function (target, thisArg, argumentsList) {
return TEMPLATE_KEY + target.apply(thisArg, argumentsList) + TEMPLATE_KEY;