Skip to content

Instantly share code, notes, and snippets.

#!/bin/env python
import sys
import re
from argparse import ArgumentParser
WORD_SPLIT = re.compile('[^a-zA-Z0-9]+')
FIRST_ALPHA = re.compile('^[a-zA-Z]')
def render(args,typename,values):
@ericgj
ericgj / Main.elm
Created March 6, 2018 04:39
session example
type Page
= Search Page.Search.Model
type alias Model =
{ page : Page
, session : Session
}
type Msg
@ericgj
ericgj / actor.py
Last active February 27, 2019 21:26
sequencing tasks in dramatiq
import dramatiq
@dramatiq.actor
def sequence(environ, sequence, environ_key=None, result_key=None):
""" could be anything, just used to kick off a sequence """
return {
u'environ': environ,
u'count': len(sequence)
}
@ericgj
ericgj / Main.elm
Last active January 9, 2017 20:14
messy page update chains
-- update triggered by browser URL change
updatePage : Pages.Page -> Model -> (Model, Cmd Msg)
updatePage page model =
let
(valueTypesStatus, valueTypesTask) =
if isLoadedValueTypes model then
( model.valueTypes
module Validation
exposing
( ValidationResult(..)
, map, mapMessage, andThen, andMap, succeed
, withDefault
, fromMaybeInitial, fromMaybe, toMaybe
, fromResultInitial, fromResult
, toString, message, isValid, isInvalid
, validate
)
module AutocompleteIDList exposing (..)
{-
Adapted from https://github.com/thebritican/elm-autocomplete/blob/master/examples/src/AccessibleExample.elm
**Work in Progress**
Note that the underlying items must be `List (id,item)`
and `selectedItem` is `Maybe id` .
@ericgj
ericgj / form.elm
Last active October 5, 2016 01:28
import Html exposing (Html, div, button, text)
import Html.Attributes as Attr
import Html.Events as Evt
import Html.App exposing (beginnerProgram)
import Html.Events exposing (onClick)
import Json.Decode as Json
import String
sample : Person
@ericgj
ericgj / f.py
Last active June 18, 2018 09:41
simple tagged union type matching in python
"""
Derived from [fn.py](https://github.com/kachayev/fn.py) function 'curried'
Amended to fix wrapping error: cf. https://github.com/kachayev/fn.py/pull/75
Copyright 2013 Alexey Kachayev
Under the Apache License, Version 2.0
http://www.apache.org/licenses/LICENSE-2.0
"""
@ericgj
ericgj / dev.sh
Last active May 23, 2016 16:24
tmux open session/window for project
#!/usr/bin/env sh
# loosely based on http://pastebin/D8y7prYV, except with windows not sessions
if [ ${#} -eq 3 ]; then
echo "You need to provide both a session and path" 2>&1
exit 1
fi
sess=${1}