Skip to content

Instantly share code, notes, and snippets.

View toan2406's full-sized avatar
🥕

Toan Nguyen toan2406

🥕
  • Ho Chi Minh city, Vietnam
View GitHub Profile

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
@toan2406
toan2406 / latency.txt
Created July 28, 2021 08:21 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@toan2406
toan2406 / Post.re
Last active July 14, 2020 06:39
A Post component which fetches and displays title
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)
@toan2406
toan2406 / PhantomTypeReasonML.md
Created January 30, 2020 08:44 — forked from busypeoples/PhantomTypeReasonML.md
Phantom types in ReasonML

Phantom types in ReasonML

Introduction

"A phantom type is a parametrised type whose parameters do not all appear on the right-hand side of its definition..." Haskell Wiki, PhantomType

The following write-up is intended as an introduction into using phantom types in ReasonML.

Taking a look at the above definition from the Haskell wiki, it states that phantom types are parametrised types where not all parameters appear on the right-hand side. Let's try to see if we can implement a similar example as in said wiki.

@toan2406
toan2406 / spotify-terminal.md
Last active September 13, 2019 15:33
Spotify with mopidy and ncmpcpp on OSX

Mopidy

  • Server that streams music from cloud services like Spotify
  • Install here
brew tap mopidy/mopidy
brew install mopidy

Better Diablo II Experience

Resolution

  • Resolution of 800x600 can be changed in-game option
  • To prevent stretch in wide-screen, go to your graphic card control panel (eg. NVIDIA Control Panel), in Adjust desktop size and position, select GPU in Perform scaling on

Savegame Sync

  • Install Dropbox
. .
';;,. ::'
,:::;,,' :ccc,
,::c::,,,,. :cccc,
,cccc:;;;;;. cllll,
,cccc;.;;;;;, cllll;
;cccc; .;;;;;;. coooo;
;llll; ,:::::'loooo;
;llll: ':::::loooo:
:oooo: .::::llodd:

Usage

Refresh

  • Edit file :e
  • Refresh NERDTree R

Comment

  • Comment lines ,c<space> ,cm
  • Comment selected ,cc
  • Uncomment ,cu
/*
* Cold observable:
* produce values upon each subscription
*/
const coldObs$ = Rx.Observable.interval(1000)
/*
* Warm observable:
* share the value source to all subscriptions,

Design Patterns