Skip to content

Instantly share code, notes, and snippets.

@vchub
vchub / category_filter.js
Last active December 21, 2015 19:19
Example of adding REC_CLICK event handling to reco-box. Just an idea, not suggestion for implementation
_gravity.push({type : 'recommendation',
callback: callback_fn,
numberLimit: 4,
scenarioId: "CATEGORY_PAGE",
currentItemId: "xxx",
itemOnPage: [], // [] of itemIds already displayed on the page
resultNames: ["itemId"],
// фильтр по категории
@vchub
vchub / item_page.js
Last active December 21, 2015 19:39
recommendation request and rendering
// Item page recommendation request and rendering
_gravity.push({type : 'recommendation',
callback: callback_fn,
numberLimit: 6,
scenarioId: "ITEM_PAGE",
currentItemId: "1111", // change to item_id in feed
itemOnPage: [], // [] of itemIds already displayed on the page
resultNames: ["itemId"] // item attributes present in Item Catalog (feed)
@vchub
vchub / get_reco.js
Last active December 24, 2015 15:59
// function creating a Produc block from data
gravRecoMainYmal = function(data){ console.log(data); }
// reco request
_gravity.push({type : 'recommendation',
callback: gravRecoMainYmal,
groupId: "mainpage",
groupSeq: 1,
groupSize: 1,
numberLimit: 16,

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs