Skip to content

Instantly share code, notes, and snippets.


Robin Gruenke eimfach

View GitHub Profile
JoelQ /
Last active Jun 14, 2022
Short exercises to learn how generic types and type variables work in Elm.

Generic Elm types exercises

A series of exercises to get a feel for how generic types and type variables work in Elm. For each of these, you are given some code that is not compiling. Your task is to get it compiling. You can change the body of the function but not the signature. No cheating with Debug.todo or infinite recursions either 😉

JoelQ /
Last active Mar 12, 2022
Elm Type Glossary

Elm Types Glossary

There's a lot of type terminology and jargon going around when discussing types in Elm. This glossary attempts to list some of the most common type terms along with synonyms, terms from other language communities, examples, and links to more detailed articles on each topic.

fnky /
Last active Aug 9, 2022
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
View How to make zsh like fish
1. Install oh-my-zsh
sh -c "$(wget -O -)"
2. Clone necessary plugins.
git clone git:// $ZSH_CUSTOM/plugins/zsh-autosuggestions
git clone ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search
git clone ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
3. Add plugins to ~/.zshrc as
plugins = ( [plugins...] zsh-autosuggestions zsh-history-substring-search zsh-syntax-highlighting)
dtipson / IO plus Array & Promise helpers.js
Last active Oct 1, 2019
Bare bones FP type utility lib so we can play around with functions that capture the composition of DOM read/writes, but in a pure way
View IO plus Array & Promise helpers.js
// Let's make it possible to create pure functions even when we're
// dealing with impure operations that would have side effects!
// First we'll need a "Type" that can contain a (sometimes impure) function
function IO(fn) {
if (!(this instanceof IO)) {//make it simpler for end users to create a type without "new"
return new IO(fn);
this.runIO = fn;//IO now provides an extra control layer that allows the composition of unexecuted effects
yang-wei /
Last active Jun 20, 2022
Elm Destructuring (or Pattern Matching) cheatsheet

Should be work with 0.18

Destructuring(or pattern matching) is a way used to extract data from a data structure(tuple, list, record) that mirros the construction. Compare to other languages, Elm support much less destructuring but let's see what it got !


myTuple = ("A", "B", "C")
myNestedTuple = ("A", "B", "C", ("X", "Y", "Z"))
paulirish /
Last active Aug 10, 2022
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
View gist:c78768f9837afb8eef74
def f(diff, n):
This function returns the new difficulty.
period_count = (n + 1) // 100000
return max(diff + 2**(period_count - 1), 5000)
diff = 6232935860523 # starting diffculty
blocknumber = 200000 # starting blocknumber
numberOfBlocks2years = 2*365*24*60*60/15
nolanlawson / protips.js
Last active Jul 21, 2022
Promise protips - stuff I wish I had known when I started with Promises
View protips.js
// Promise.all is good for executing many promises at once
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");
patrickarlt /
Last active Mar 25, 2020
ES 7 async/await demo!
babel github-es6.js -o github.js --optional runtime --experimental