Instantly share code, notes, and snippets.

View FastPipeIssue.re
/* this works */
"1=2=3"
|> Js.String.split("=")
|. Js.log;
/* this works, too */
"1=2=3"
-> Js.log;
/* but this doesn't */
View READEME.md

Claim: Difficulty with interop with JS when accepting nested object param from JS to Reason

Reasonml Ver: 3.3.2

  • No problem with taking parameters from JS and matching to any type contains optional with one depth

  • But it seems to lose values wrapped by option if you have more depth like below

View rainist_holdem_heechul.py
from typing import List
from random import randint
from .core.cards import Card
from .player import Me, Other
def bet(
me: Me,
bet_players: List[Other],
View Reason-Option-Iterop-Issue.md

I wanted to make an npm module via ReasonML

  • a function need to accept objects
  • but couldn't find a way to convert an JS Object to a Reason Record (holds optional value)
// I wanted to have an npm module function like below
reasonFnExposedToJs({key1: 'blah', key2: undefined})

// and works fine with Reason side but generated argsFromJs looks like below
View ttl.jsx
const ttl = (strings, ...variables) => [strings, ...variables]
// or const ttl = (...args) => [...args]
// we are using www.styled-components.com as an example
const Adder = ({className, x, y}) => {
return (
<span className={className}> {x+y} </span>
)
}
View no-concurrency-promise.js
function printTo100(n) {
for (i in [...Array(100).keys()]){
console.log(`${n}-${i}`)
}
return Promise.resolve()
}
Promise.all(
printTo100('a'),
printTo100('b'),
View useful-commands.sh
# find a process using port 3000 via https://unix.stackexchange.com/a/106562
sudo lsof -n -i :3000 | grep LISTEN
# export env vars from a file via https://github.com/sunghyunzz
export $(cat .env | xargs)
# check the reachability of the website every 1 seconds
while true; do curl -I https://example.com/; sleep 1; done
# pipe stdout as one arg to another command
View example.js
const { hss, scene, storage, market } = require('hire-scene-stealer')
hss
.scene(scene
.url('https://google.com')
.selector('img#hplogo')
.domIndex(0) // you can skip if it's 0
.viewport(900, 700)
)
.storage(storage
View Echo.elm
port module Echo exposing (..)
import Platform exposing (program, Program)
import Json.Decode
-- importing Json.Decode is necessary for now because of https://github.com/elm-lang/elm-make/issues/127
---- MODEL ----
type alias Model =
{ crap : String }