Skip to content

Instantly share code, notes, and snippets.

View dfcarpenter's full-sized avatar

Daniel Carpenter dfcarpenter

View GitHub Profile
@dfcarpenter
dfcarpenter / dockerfile
Created April 14, 2018 21:36
django dockerfile
FROM python:3.6-stretch as python-base
COPY webpack requirements.txt package.json yarn.lock ./
RUN set -ex \
&& apt-get update \
&& apt-get install apt-transport-https \
&& apt-get update \
&& apt-get install --no-install-recommends -y \
libpq-dev curl libjpeg-dev rsync libsass-dev libicu57 zlib1g-dev libpng-dev libmagickwand-dev \
@dfcarpenter
dfcarpenter / core.clj
Created March 23, 2018 21:00 — forked from maacl/core.clj
Domain Modelling using Clojure
(comment "This is a small experiment inspired by Oskar Wickströms
excellent work at
https://haskell-at-work.com/episodes/2018-01-19-domain-modelling-with-haskell-data-structures.html.
I wanted to see what would be involved in building the equivalent
functionality in reasonably ideomatic Clojure. It is also my first
from scratch use of Clojure spec, which was a very interesting and
productive experience. It is amazing how little work one has to do
to be able to generate example datastructures for testing. The
generated examples helped me find a subtle bug in the tree pretty
printer, that would have been hard to find without." "I would love
@dfcarpenter
dfcarpenter / wagtail.Dockerfile
Created January 25, 2018 22:29
wagtail multistage build dockerfile
FROM python:3.6
COPY requirements.txt .
COPY package.json .
WORKDIR /app/
ADD . /app/
RUN set -ex \
&& apt-get update \
@dfcarpenter
dfcarpenter / wizard.cljs
Created October 1, 2017 23:39
converting some JS
getNavStates(indx, length) {
let styles = [];
for (let i=0; i<length; i++) {
if (i < indx) {
styles.push('done');
}
else if (i === indx) {
styles.push('doing');
}
// Mutex implementation originally taken from https://github.com/mgtitimoli/await-mutex
/* Why do you need mutexes in a single threaded context ?
* Presumably instances of `MyObject` can be accessed by functions which are running while this function is suspended,
* waiting for the network call. It's single threaded, as in only one thing happens at a time from JS's point of view,
* but other functions can be invoked (by a request coming in, or a UI event etc) while an asynchronous operation
* is awaiting completion.
*/
@dfcarpenter
dfcarpenter / main.elm
Last active March 30, 2016 19:19
Github users
module Main (..) where
import Effects exposing (Effects, Never)
import Html exposing (..)
import Html.Attributes exposing (style)
import Html.Events exposing (onClick)
import Http
import Json.Decode as Decode exposing ((:=))
import Json.Decode.Extra exposing ((|:))
import Task
@dfcarpenter
dfcarpenter / README
Created January 21, 2016 22:20 — forked from mremond/README
Phoenix Elixir framework with ejabberd - Tutorial
Please read original blog post for reference:
http://blog.process-one.net/embedding-ejabberd-into-an-elixir-phoenix-web-application/
@dfcarpenter
dfcarpenter / test.ex
Last active January 15, 2016 21:13
Elixir service
Users.newusers
|> elem(1)
|> Map.get("Items")
|> Poison.encode
|> elem(1)
|> File.write("/dir/users.json")
#response from dynamodb after first function
<?php
/*
Template Name: Experiences List
*/
get_header();
?>
<div id="primary" class="content-area">
<main id="main" role="main">
<div class="experiences">
@dfcarpenter
dfcarpenter / decode.ex
Created September 25, 2015 20:12
decoding
iex(1)> decode = "bm9uY2U9Y2JlYTQ1NGQyYjNiYmQyZTI1OTQ2YzNkYT\nViOTM5OWYmcmV0dXJu\nX3Nzb191cmw9aHR0cCUzQSUyRiUyRmZvcnVtcy5zdHJpbmdpZnkuY29tJTJG\nc2Vzc2lvbiUyRnNzb19sb2dpbg==\n"
"bm9uY2U9Y2JlYTQ1NGQyYjNiYmQyZTI1OTQ2YzNkYT\nViOTM5OWYmcmV0dXJu\nX3Nzb191cmw9aHR0cCUzQSUyRiUyRmZvcnVtcy5zdHJpbmdpZnkuY29tJTJG\nc2Vzc2lvbiUyRnNzb19sb2dpbg==\n"
iex(2)> Base.decode64! decode
** (ArgumentError) non-alphabet digit found:
(elixir) lib/base.ex:111: Base.dec64/1
(elixir) lib/base.ex:518: Base."-do_decode64/2-lbc$^0/2-0-"/3
(elixir) lib/base.ex:518: Base.do_decode64/2
iex(2)> Base.url_decode64! decode
** (ArgumentError) non-alphabet digit found: