Skip to content

Instantly share code, notes, and snippets.

View roberto's full-sized avatar
🍊

Roberto Soares roberto

🍊
View GitHub Profile
const setJackson = R.pipe(
R.prop("users"),
R.map(
(user) =>
R.startsWith('J', user.name)
? {...user, name: R.concat(user.name, ' Jackson')}
: user
)
)
R.pipe(
R.prop("users"),
R.sortBy(R.prop("age")),
R.take(3),
R.pluck("name")
)
const isOld = R.gt(R.__, 33)
const getOldPeople = R.pipe(
R.prop("users"),
R.filter(R.where({age: isOld}))
)
const getOldPeople = R.pipe(
R.prop("users"),
R.filter(R.propSatisfies(isOld, 'age'))
@roberto
roberto / myProp.js
Last active January 24, 2018 22:55
Currying - Simple
const myProp = (key, maybeObject) => {
if (maybeObject === undefined) {
return (object) => {
return myProp(key, object)
}
}
return maybeObject[key]
}
const increment = (key, obj) => {
return {
...obj,
[key]: obj[key] + 1
}
}
import Html exposing (text)
partition n =
break (n - 1, 0)
break (n, total) =
case n of
1 -> total + 1
n -> 1 + break(n - 1, total + 1)

10 weird tricks that React developers near you are using to create reusable components

https://www.youtube.com/watch?v=nQo0EdHNjto

  • reusable components
    • props over state
      • prop === state => problem!
    • stateless components
    • easy to unit test
  • PropTypes are serious

Blazing fast:

emacs --daemon
emacsclient .

inside terminal:

emacsclient -nw .
var schema = joi.object().keys({
things: joi.array().items(
joi.object().keys({
id: joi.string(),
name: joi.string(),
version: joi.string()
})
)
});
package main
import (
"bytes"
"flag"
"fmt"
"github.com/elazarl/goproxy"
"github.com/robertkrimen/otto"
"io"
"io/ioutil"