layout: blog title: Explore Memoization date: 2019-07-18T16:20:16.898Z author: Toan Nguyen Gia authorAvatar: /img/uploads/t0d8dq73q-u9hr7hu1m-706d3758d60e-512.jpeg image: /img/uploads/deco-iskusstvoa-helix.jpg tags:
- Tech
- Javascript
layout: blog title: Explore Memoization date: 2019-07-18T16:20:16.898Z author: Toan Nguyen Gia authorAvatar: /img/uploads/t0d8dq73q-u9hr7hu1m-706d3758d60e-512.jpeg image: /img/uploads/deco-iskusstvoa-helix.jpg tags:
| // Paste in browser console and run | |
| async function deleteStaleBranches(delay=500) { | |
| var stale_branches = document.getElementsByClassName('js-branch-delete-button'); | |
| for (var i = 0; i < stale_branches.length; i++) | |
| { | |
| stale_branches.item(i).click(); | |
| await new Promise(r => setTimeout(r, delay)); | |
| } | |
| } |
Fortunatly we could use pre-built gccemacs right now.
Those two repos did the greate job for us.
https://github.com/twlz0ne/nix-gccemacs-darwin
https://github.com/twlz0ne/nix-gccemacs-sierra
Here is the tutorial:
| // Import memoize from lodash fp package - it is convention in EH project | |
| import memoize from 'lodash/fp/memoize'; | |
| // in lodash functional programming, memoize only have 1 argument | |
| // this is code to changed to original API which support keyResolver | |
| const memoizeWithResolver = memoize.convert({ fixed: false }); | |
| const keyResolver = (...args) => JSON.stringify(args);// Just sample code, you can choose method which you prefer | |
| const withMemo = memoizeWithResolver((a,b) => doSomethingWith(a,b), keyResolver) |
| open Relude.Globals; | |
| module R = Relude; | |
| let (>>=) = IO.(>>=); | |
| let fetchPostById: string => IO.t(string, string) = | |
| id => | |
| Fetch.fetch("https://jsonplaceholder.typicode.com/posts/" ++ id) | |
| |> Js.Promise.then_(Fetch.Response.text) |
| // A demonstration of sorting objects with Ord instances | |
| // equals :: Setoid a => a ~> a -> Boolean | |
| // lte :: Ord a => a ~> a -> Boolean | |
| /* | |
| * Data Constructors, and their Setoid and Ord instances | |
| */ | |
| // I'm using the daggy library to make constructors https://github.com/fantasyland/daggy | |
| const daggy = require('daggy') |
| // void operator | |
| void 0 // returns undefined | |
| void (0) // returns undefined | |
| void 'abc' // returns undefined | |
| void {} // returns undefined | |
| void (1 === 1) // returns undefined | |
| void (1 !== 1) // returns undefined | |
| void anyfunction() // returns undefined |
This is a walkthrough of how to set up Visual Regression Testing with Jest for an application created with create-react-app.
The following walkthrough uses React as an example, but the approach should work for any modern frontend library! I assume it can be used with Angular, Vue, Cycle.js and more.
This gist walks you through a create-react-app application as an example of how to set up Visual Regression Testing in Jest using libraries I wrote recently which enable this: jsdom-screenshot, jest-transform-css and jest-transform-file.
| keycode 8 = | |
| keycode 10 = 1 exclam | |
| keycode 11 = 2 at at | |
| keycode 12 = 3 numbersign | |
| keycode 13 = 4 dollar dollar | |
| keycode 14 = 5 percent | |
| keycode 15 = 6 asciicircum | |
| keycode 16 = 7 ampersand braceleft | |
| keycode 17 = 8 asterisk bracketleft | |
| keycode 18 = 9 parenleft bracketright |