Skip to content

Instantly share code, notes, and snippets.

View iShafayet's full-sized avatar

Sayem Shafayet iShafayet

View GitHub Profile
@iShafayet
iShafayet / eye-for-an-eye.js
Created February 24, 2018 16:39
Now this is what I call an eye for an eye...
let copy = list.map(i => i);
## The Problem
value = 'external'
console.log 1, value # 'external'
(someFunction = =>
console.log 2, value # 'external'
value = 'internal'
console.log 3, value # 'internal'
)()
@iShafayet
iShafayet / merge.coffee
Last active August 29, 2015 14:26
Merge two objects/arrays upto any depth, written in coffeescript
merge = (left, right) ->
return left unless (typeof left is typeof right is 'object') and right isnt null
return left unless (Array.isArray left) is (Array.isArray right)
ret = if Array.isArray left then [] else {}
for key, value of left
ret[key] = left[key]
for own key, value of right
if key of ret
ret[key] = merge ret[key], right[key]
else
@iShafayet
iShafayet / javascript-function-serializer.coffee
Created July 24, 2015 06:02
Serializing/Deserializing Javascript Functions with eval
@__deserializeFunction = __deserializeFunction = (argumentArray)->
Function.apply {}, argumentArray
@__serializeFunction = __serializeFunction = (fn)->
deSF = fn.toString()
temp = deSF.indexOf '('
temp1 = deSF.indexOf ')'
declaration = deSF.substring temp+1, temp1