This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const fs = require('fs') | |
// Flattens a nested array recursively. | |
const flatten = arr => | |
arr.filter( Array.isArray ).length | |
? flatten( Array.prototype.concat( ...arr ) ) | |
: arr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
find . -maxdepth 1 -mindepth 1 -type d -exec sh -c '(echo {} && cd {} && git status -s && echo)' \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
// Number -> Object | |
module.exports = rolls => | |
Array.from( Array(rolls) ) | |
.map( | |
() => | |
Math.ceil( Math.random() * 6 ) | |
) | |
.reduce( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Notes: | |
# - Requires Node.js to be managed by nvm. | |
# - Can require packages that are globally or locally installed. | |
NODE_PATH=$(realpath ${NVM_BIN}/../lib/node_modules) node -e "require(\"/path/to/file.js\")" -i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-- | |
You *can* load an external CSS file in Elm, but currently, | |
in Pure Elm that means adding a style element to the body instead of the head. | |
It does cause a flash of unstyled content, so I think it's only useful | |
for testing in Reactor. | |
--} | |
import Html exposing (..) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module PostExample exposing (..) | |
--TO RUN | |
--1. $ npm install -g elm | |
--2. $ elm-reactor | |
--3. Go to `http://localhost:8000/PostExample.elm`. | |
import Html exposing (Html, button, div, p, strong, text) | |
import Html.Events exposing (onClick) | |
import Html.Attributes exposing (style) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { zipObj } = require('ramda') | |
// (String, [String]) -> Object | |
const translate = (path, array) => | |
zipObj( | |
array, | |
array.map( | |
value => | |
this.$translate.instant(`${path}${value}`) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="<%= static_path(@conn, "/js/admin.js") %>"></script> | |
<script> | |
Elm.Main.fullscreen({ first_name: "<%= @data.first_name %>" }); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const assets = [].map(url => self.location.origin + url); | |
self.addEventListener("fetch", e => | |
e.respondWith( | |
fetch(e.request) | |
.then(res => { | |
if (res.ok && assets.includes(e.request.url)) { | |
caches.open("cache-name").then(cache => cache.put(e.request, res)); | |
} | |
return res.clone(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onEsc : msg -> Decoder msg | |
onEsc msg = | |
Decode.map2 | |
(\keyCode key -> | |
keyCode == 27 || key == "Escape" | |
) | |
keyCode | |
(Decode.field "key" Decode.string) | |
|> Decode.andThen | |
(\match -> |
OlderNewer