Monthly Archives: April 2017

Combinations of a String

Implement a function that prints all possible combinations of a string. A string “12” is the same as string “21” function combine($instr, $outstr, $index) { for ($i = $index; $i < strlen($instr); $i++) { $outstr = $outstr . $instr[$i]; echo … Continue reading

Posted in Algorithms | Leave a comment

Simulate a debounce function

http://obscurejavascript.tumblr.com/post/115595038489/debounce-in-javascript var debounce = function(callback, delay) { var timeout = null; return function() { var args = arguments, context = this; clearTimeout(timeout); timeout = setTimeout(function() { callback.apply(context, args); }, delay); }; };

Posted in Javascript | Leave a comment

Debounce and Throttle in Javascript

Throttle: the original function be called at most once per specified period. Example: while window resizing Debounce: the original function be called after the caller stops calling the decorated function after a specified period. Example: Validating contents of a text … Continue reading

Posted in Javascript | Comments Off on Debounce and Throttle in Javascript

Trulia On Site Questions

1) How does Oauth work ? 2) Explain journey of a URL ? 3) How does caching work in a CDN? How do you push a new file out to CDN? 4) Emulate the throttle function() // Allow callback to … Continue reading

Posted in Javascript | Leave a comment

IIFE in Javascript (Immediately Invoked Function Expression)

http://benalman.com/news/2010/11/immediately-invoked-function-expression/

Posted in Javascript | Leave a comment

How to achieve static variable in javascript

2 Ways : 1) Make use of the fact that functions are objects and can have properties (Even using “this” instead of uniqueID inside the function will do) function uniqueID() { // Check to see if the counter has been … Continue reading

Posted in Javascript | Leave a comment

Given Array of positive negative numbers find 2,3 of them that sum to zero

Given an array of numbers with positive and negative, find pairs that sum to zero   a) sort the numbers b) start 2 pointers from from begin and end c) if sum is > or < = then move appropriate … Continue reading

Posted in Algorithms | Leave a comment

How does a cache work?

https://en.wikipedia.org/wiki/Cache_(computing)

Posted in Concepts | Leave a comment

How does Oauth-2 work ?

https://www.digitalocean.com/community/tutorials/an-introduction-to-oauth-2

Posted in Concepts | Leave a comment

Implement a HashMap

http://robl.co/implement-your-own-hashmap/

Posted in General | Leave a comment