Skip to content

Instantly share code, notes, and snippets.


Helder S Ribeiro hsribei

View GitHub Profile

Someone in the Elm slack channel threw out this idea of naming Msg in the past tense, and not imperatively. I thought it was an interesting idea and I adopted the practice, just to try it out. I forgot who it was, I wish I could give them credit.

Anyway, the ramifications were more than I expected, and not simply the same Msg with different names. What I started doing is naming Msg as if they were saying "This happened". So where I would say "HandleUsernameField" I might instead say "UsernameFieldChanged" or instead of "Close" I would do "XClicked". What I didnt account for was that Msg and functionality dont map one to one. So for example, if you have a Msg named Navigate, its going to be the one Msg you use whenever you want to navigate. But if you are naming Msg as paste-tense descriptions, then several different things could happen that could cause a navigation. Since many things should cause a navigation, naming Msg in the past tense leads to lots of Msg which do the same thing.

carlosmaniero / Elm.hs
Last active Oct 30, 2017
Elm architecture in Haskell: A study case
View Elm.hs
data Model = Model
{ name :: String
, gender :: String
, loading :: Bool
, homeworld :: String
} deriving (Show)
data PersonResponse = PersonResponse
{ personName :: String
IronSavior / to-function.js
Created Aug 7, 2017
JavaScript named predicate helper (Symbol#to_proc from Ruby)
View to-function.js
"use strict";
// Make predicate funtions more convenient.
// Works like Ruby's Symbol#to_proc, which is usually called with the unary & operator and a Symbol literal:
// (ruby) %w[one two three].map(&:upcase) # returns ["ONE", "TWO", "THREE"]
// (js) ['one', 'two', 'three'].map(toFn('toUpperCase')); // returns ["ONE", "TWO", "THREE"]
// (js) ['one', 'two', 'three'].map(toFn`toUpperCase`); // same as above, but called via tagged string literal
// @param name {String} Name of method
// @param ...bound_args Arguments to bind NOTE: Args cannot be bound when calling as a tagged-template
// @return {Function} Function to call named method with bound args on any object given at time of invocation
module.exports = function toFn( name, ...bound_args ){
derhuerst /
Last active Oct 3, 2018
working offline as JavaScript dev

working offline as JavaScript dev

use npm@5

npm installs large dependency trees a lot faster. this is especially noticable over slow networks.

Running npm while offline will no longer insist on retrying network requests. npm will now immediately fall back to cache if possible, or fail. (npm/npm#15666)

use node_modules/*/

View Dive

Lightning Talk proposal for ReactiveConf 2017 #ReactiveConf

Porting Prezi to Elm in 99 lines of code

Elm is a statically-typed functional programming language. Its compiler produces safe JavaScript which is guaranteed to be free of runtime exceptions. Moreover Elm is packed with a bunch of powerful abstractions which let us build visual and reactive Web applications in a few lines of code.

As an example, I show the implementation of a simple framework for building Prezi-like presentations. It's just 99 lines of code!

yoshuawuyts /
Last active May 16, 2017
Rough rust translation of the example
extern crate ssb_keys;
extern crate ssb;
extern crate mio;
extern crate pull;
const pathToSecret: String = "/tmp/ssb1-secret";
const pathToDB: String = "/tmp/ssb1/";
View Spelling.elm
port module Spelling exposing (..)
import Html exposing (..)
import Html.App as App
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import String
main =
ivar / spacemacs global search and
Last active Oct 12, 2021
spacemacs - global search and replace
View spacemacs global search and

There's a couple of ways, one way is

  • Get search results
    • Do SPC / and type in your search string
    • or SPC x S and search string - where x is your scope indicator (p for project, d for directory, etc..)
  • Once you have the occurences you want, hit C-c C-e inside the helm buffer to put all your match occurences and puts them into a special buffer called the edit buffer or something like that
  • in that buffer you can use any commands you'd normally use on a buffer
  • the C-c C-c to commit your changes.
yang-wei /
Last active Oct 19, 2021
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"))
View tryCatchSO.js
try {
function foo() {
} catch(e) {
window.location.href="[js]+" + e.message || e;