Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@focusaurus
focusaurus / notes.md
Last active October 17, 2017 00:02
Regular Expression Registry

What

A registry of regular expressions

Base Data

  • The expression string
  • taxonomy/category
  • supported engines
  • a set of test inputs
@focusaurus
focusaurus / build.sh
Last active June 5, 2017 09:20
markdown slides with reveal build snippet
#!/usr/bin/env bash
base_build() {
build_dir="./build"
mkdir -p "${build_dir}"
# OSX build support. BSD tar vs GNU tar issue
if [[ "$(uname)" == "Darwin" ]]; then
alias tar=gtar
fi
# This takes all files that have been at least added to git
@focusaurus
focusaurus / build.sh
Created January 26, 2017 02:49
Build script detects macOS and runs itself under docker
#!/usr/bin/env bash
cd "$(dirname "$0")/.."
if [[ "$(uname)" == "Darwin" ]]; then
docker build --tag foo-rpmbuild .
docker run --interactive --tty --rm \
--volume "${PWD}:/opt/docker-host" \
--volume "$(yarn cache dir | grep '^/'):/var/run/yarn-cache" \
foo-rpmbuild /opt/docker-host/bin/build.sh
exit
@focusaurus
focusaurus / WebDataPagination.elm
Created January 18, 2017 17:57
WebData for pagination
module Lab.WebDataPagination exposing (main)
import Html exposing (..)
import RemoteData as RD
import Json.Decode as JD
import Http
-- import Html.Attributes exposing (..)
@focusaurus
focusaurus / A.elm
Created December 14, 2016 18:00
Trying to handle blur event and get at event.target.textContent as a String
module A exposing (..)
import Debug
import Html
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onBlur, onClick, on)
import Json.Decode as JD
import Json.Encode as JE
@focusaurus
focusaurus / A.elm
Created December 5, 2016 00:26
Decode JSON string enum into elm union type
module A exposing (..)
import Json.Decode as JD
import Json.Encode as JE
type alias User =
{ id : Int
, theme : Theme
}
@focusaurus
focusaurus / sign-in.elm
Last active November 7, 2016 22:28
How to handle Http POST
module SignIn exposing (..)
import Html exposing (..)
import Html.App
import Http
import Json.Decode
import Task
type alias Model =
@focusaurus
focusaurus / package.json
Created October 10, 2016 16:50
atom-format-shell package.json
{
"activationHooks": [
"language-shellscript:grammar-used"
],
"author": "Peter Lyons <pete@peterlyons.com> (http://peterlyons.com)",
"bugs": {
"url": "https://github.com/focusaurus/atom-format-shell/issues"
},
"configSchema": {
"shfmtPath": {
function listUsers (req, callback) {
// use req as immutable input
// standard node error-first callback API
// success value of callback is a response-shaped object with properties: statusCode, headers, body
}
// I haven't built one of these, just riffing.
// Look at clojure and other functional languages for examples that might
// have reasonable counterparts in "functional-light" JS
// Thinking more along the lines of react/redux reducer style
@focusaurus
focusaurus / promises-are-always-async.js
Created January 29, 2016 16:52
Promises are always async
Promise.resolve('foo').then(console.log)
console.log('bar')
// outputs:
// bar
// foo