Skip to content

Instantly share code, notes, and snippets.

View rupeshdabbir's full-sized avatar
🎯
Focusing

Rupesh Dabbir rupeshdabbir

🎯
Focusing
View GitHub Profile
@rupeshdabbir
rupeshdabbir / squirt.js
Created March 29, 2017 19:31 — forked from joelpt/squirt.js
Manually calculate the square root of a number with Javascript
// The Babylonian Method
// http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method
// @param n - the number to compute the square root of
// @param g - the best guess so far (can omit from initial call)
function squirt(n, g) {
if (!g) {
// Take an initial guess at the square root
g = n / 2.0;
}
var d = n / g; // Divide our guess into the number
@rupeshdabbir
rupeshdabbir / System Design.md
Created July 25, 2017 14:12 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@rupeshdabbir
rupeshdabbir / cloudSettings
Last active May 29, 2020 22:04 — forked from alexhawkins/nativeJavaScript.js
Implementation of Native JavaScript Methods (forEach, Map, Filter, Reduce, Every, Some)
{"lastUpload":"2020-05-29T22:04:24.612Z","extensionVersion":"v3.4.3"}
@rupeshdabbir
rupeshdabbir / functional_context.md
Created November 5, 2020 18:46
functional context

Problem

The current approach to functional programming only takes into consideration one piece of data going through the pipeline. This approach makes a lot of sense when you have a very linear flow, where we mutate the data along the way. The code doesn't hold well when we need to create another piece of data and keep the original data to use downstream.

A simple example would be:

const consolidateFilters = (fieldSet) => {
  const value = concatFiltersAndParameters(fieldSet)
 return flow([set('filters', value), omit('parameters')])(fieldSet)