Skip to content

Instantly share code, notes, and snippets.

@bendyorke
bendyorke / setup.md
Last active March 12, 2021 14:25
Setting up a new mac
@staltz
staltz / introrx.md
Last active September 18, 2025 20:18
The introduction to Reactive Programming you've been missing
@kuy
kuy / pre-commit
Last active November 10, 2021 03:52
git: pre-commit hook script to prevent committing FIXME code
#!/bin/sh
matches=$(git diff --cached | grep -E '\+.*?FIXME')
if [ "$matches" != "" ]
then
echo "'FIXME' tag is detected."
echo "Please fix it before committing."
echo " ${matches}"
exit 1
@evancz
evancz / Architecture.md
Last active December 21, 2022 14:28
Ideas and guidelines for architecting larger applications in Elm to be modular and extensible

Architecture in Elm

This document is a collection of concepts and strategies to make large Elm projects modular and extensible.

We will start by thinking about the structure of signals in our program. Broadly speaking, your application state should live in one big foldp. You will probably merge a bunch of input signals into a single stream of updates. This sounds a bit crazy at first, but it is in the same ballpark as Om or Facebook's Flux. There are a couple major benefits to having a centralized home for your application state:

  1. There is a single source of truth. Traditional approaches force you to write a decent amount of custom and error prone code to synchronize state between many different stateful components. (The state of this widget needs to be synced with the application state, which needs to be synced with some other widget, etc.) By placing all of your state in one location, you eliminate an entire class of bugs in which two components get into inconsistent states. We also think yo
@ismasan
ismasan / events_emitter_mixin.js
Created March 11, 2015 13:32
Simplified events emitter (JS)
/**
* Simple event dispatcher
*
* Example
*
* var MyConstructor = function () {
* var self = this
* var count = 0
* setInterval(function () {
* self.emit('tick', {count: count})
@CMCDragonkai
CMCDragonkai / http_streaming.md
Last active September 23, 2025 21:29
HTTP Streaming (or Chunked vs Store & Forward)

HTTP Streaming (or Chunked vs Store & Forward)

The standard way of understanding the HTTP protocol is via the request reply pattern. Each HTTP transaction consists of a finitely bounded HTTP request and a finitely bounded HTTP response.

However it's also possible for both parts of an HTTP 1.1 transaction to stream their possibly infinitely bounded data. The advantages is that the sender can send data that is beyond the sender's memory limit, and the receiver can act on

wifi.setmode(wifi.STATION)
wifi.sta.config("SSID","password")
-- Send POST when buttons A or B pressed
PIN_BUTTON_A = 3 -- GPIO0
PIN_BUTTON_B = 4 -- GPIO1
TIME_ALARM = 25 -- 0.025 second, 40 Hz
gpio.mode(PIN_BUTTON_A, gpio.INPUT, gpio.PULLUP)
import Html exposing (..)
import Html.App exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Html.Attributes exposing (..)
import Http
import Task exposing (Task)
import Json.Decode as Json exposing ((:=))
type Msg
@pdamoc
pdamoc / Pong.elm
Last active October 16, 2016 20:07
Pong Example
-- See this document for more information on making Pong:
-- http://elm-lang.org/blog/pong
import Color exposing (..)
import Collage exposing (..)
import Element exposing (..)
import Keyboard
import Text
import Time exposing (..)
import Window exposing (Size)
import Html.App as App

This document has moved!

It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.