Skip to content

Instantly share code, notes, and snippets.

View escherlies's full-sized avatar
🎯
Focusing

Enrico Scherlies escherlies

🎯
Focusing
View GitHub Profile
@escherlies
escherlies / ProgressBar.elm
Created March 1, 2023 09:36
An ascii progress bar in Elm
-- | An ascii progress bar.
-- | Should be used with a monospace font.
-- | Renders like this:
-- |
-- | [============ ]
-- |
-- | or half steps
-- |
-- | [======- ]
-- |
@escherlies
escherlies / Context.elm
Created February 24, 2023 09:58
An Elm context type that can be run everywhere. Like a Reader.
module Context exposing (..)
type Context a b
= WithContext (a -> b)
withContext : (a -> b) -> Context a b
withContext =
WithContext
@escherlies
escherlies / bash-template.sh
Created February 23, 2023 18:43
Bash template script
#!/bin/bash
# If anything goes south anywhere, exit with error code 1
set -euo pipefail
# The directory of the file
BASEDIR=$(realpath $(dirname "$0"))
{-| Helper function to partially apply an "infix" a function. Same as flip but is more comprehensable for some cases, imho.
Unfortunatly you can not to partial function application with infix functions, let a lone use any function as infix.
So this is not possible in elm, which is unfortunate because the Haskell way is much more tacit.
-- Haskell, not possible in elm
List.map (- 10) [ 10, 20, 30 ] --> [0,10,20]
module Context exposing (..)
import Element exposing (Color, Element, el, rgba, text)
import Element.Background
import Element.Font
import UI.Theme exposing (Appereance(..))
{-| Lang Module
-}
@escherlies
escherlies / CV.md
Last active February 28, 2023 17:33

Enrico Scherlies | B.Eng | Berlin

Full-Stack Engineer | Elm, TypeScript | Functional Programming

I am a full-stack engineer with six years of web app experience.

I love functional programming and my split keyboard with Colemak(-DH).

Work Experience

@escherlies
escherlies / SlowMo Messages Algorithm.md
Last active May 5, 2018 19:21
Algorithm for Showing a constant stream of incoming messages, buffered and display with a delay to optimise reading.

When developing a React and Firebase powered realtime chat app, a goal was to stretch the incoming messages so that each message is displayed 500ms after another exept the first message, which is displayed instantly. This ensueres readability as it flattens out peaks of incoming messages.

First, the Complete Snipped:

const SLOMO_DELAY = 500
const INITIAL_STATE = {
  shouldScroll: true,
  editChat: false,
  showModal: false,
@escherlies
escherlies / JS through WordPress Plugin.md
Last active March 13, 2018 18:17
Implement your JavaScript App into Wordpress through creating a Plugin with PHP

As a JS Developer I wanted to integrate my (React) App into a Wordpress Site. After researching and trying different solutions I ended up creating my own plugin with a function which handles everything. It also adds a shortcode that can now easily insertet in any WP page or post. As it is a plugin, it is easy to maintain.

This is a slightly generalized version of my plugin im using for my react app:

<?php
/*