Skip to content

Instantly share code, notes, and snippets.

View rlucha's full-sized avatar

Rob Lucha rlucha

View GitHub Profile

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 / 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
@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
--

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?

// 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);
/* 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` */
/* 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 =
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)
(defn fib [a b] (lazy-seq (cons a (fib b (+ b a)))))
(reduce +
(filter even?
(take-while #(< % 4000000) (fib 1 2))))
function* fib(a, b) {
let c = 0
yield a
yield b
while (true) {
c = a + b
a = b
b = c
yield c