Skip to content

Instantly share code, notes, and snippets.

View rlucha's full-sized avatar

Rob Lucha rlucha

View GitHub Profile
(defn fib [a b] (lazy-seq (cons a (fib b (+ b a)))))
(reduce +
(filter even?
(take-while #(< % 4000000) (fib 1 2))))
export function iterateAsync(iterable, fn, batch = 10) {
const iterator = iterable[Symbol.iterator]();
function iterate() {
const current = take(iterator, batch)
fn(current.result)
current.done
? () => {}
: window.requestAnimationFrame(iterate)
/* First time reading an OCaml/Reason/BuckleScript file? */
/* `external` is the foreign function call in OCaml. */
/* here we're saying `I guarantee that on the JS side, we have a `render` function in the module "react-dom"
that takes in a reactElement, a dom element, and returns unit (nothing) */
/* It's like `let`, except you're pointing the implementation to the JS side. The compiler will inline these
calls and add the appropriate `require("react-dom")` in the file calling this `render` */
external render : ReactRe.reactElement => Dom.element => unit =
/* from https://github.com/reasonml/reason-react/blob/master/src/reactDOMRe.re */
/* First time reading an OCaml/Reason/BuckleScript file? */
/* `external` is the foreign function call in OCaml. */
/* here we're saying `I guarantee that on the JS side, we have a `render` function in the module "react-dom"
that takes in a reactElement, a dom element, and returns unit (nothing) */
/* It's like `let`, except you're pointing the implementation to the JS side. The compiler will inline these
calls and add the appropriate `require("react-dom")` in the file calling this `render` */
// const a = _ => new Promise((resolve, reject) => resolve(2));
// const b = x => new Promise((resolve, reject) => resolve(x+10));
// a().then(m => b(m).then(z => console.log(z)));
async function fn() {
const a = await promiseWrapper(fakeNetworkFn, 10);
const b = await promiseWrapper(fakeNetworkFn, a);

Introduction to the why

At uSwitch we constantly strive to deliver better value for our customers faster. Ocassionally that means evaluating new tools and technologies. One technology that recently caught our attention is ReasonML. It promises a good, but not overly complex statically types language combined with very solid

Roberto is a recent Set the task mission.

Why use static typing?

@rlucha
rlucha / gist:101fbea2d0a5a6496b0b197e8a07791a
Created October 5, 2017 22:56
-- Scotty server example
-- {-# LANGUAGE OverloadedStrings #-}
--
-- module Main where
--
-- import Web.Scotty
-- import Control.Monad.IO.Class
--
-- import Db
--
@rlucha
rlucha / degress2meters.js
Created June 5, 2018 16:55 — forked from springmeyer/degress2meters.js
convert from long/lat to google mercator (or EPSG:4326 to EPSG:900913)
var degrees2meters = function(lon,lat) {
var x = lon * 20037508.34 / 180;
var y = Math.log(Math.tan((90 + lat) * Math.PI / 360)) / (Math.PI / 180);
y = y * 20037508.34 / 180;
return [x, y]
}
x= -77.035974
y = 38.898717

Branches

  • Delete remote branch git push --delete <remote_name> <branch_name>
  • Delte local branches not on remote anymore
  git fetch -p && for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done
  • Cherry pick files from another branch git checkout <other_branch_name> <files/to/grab in/list/separated/by/spaces> -p
@rlucha
rlucha / .zshrc
Created October 16, 2018 08:17 — forked from matthewmccullough/.zshrc
A configuration to maintain history across sessions and share it across terminals in ZShell
##############################################################################
# History Configuration
##############################################################################
HISTSIZE=5000 #How many lines of history to keep in memory
HISTFILE=~/.zsh_history #Where to save history to disk
SAVEHIST=5000 #Number of history entries to save to disk
#HISTDUP=erase #Erase duplicates in the history file
setopt appendhistory #Append history to the history file (no overwriting)
setopt sharehistory #Share history across terminals
setopt incappendhistory #Immediately append to the history file, not just when a term is killed