Skip to content

Instantly share code, notes, and snippets.

View Basemm's full-sized avatar

Basem Mostafa Basemm

View GitHub Profile
@Basemm
Basemm / readLineSync.js
Last active December 28, 2020 05:08
Read file line by line "synchronous"
/**
* Read file line by line "synchronous"
*
* require nodejs ~0.11, run with "node --harmony"
*
* Example:
*
* var readLineSync = require('./readLineSync');
*
*
@Basemm
Basemm / gist:8789091
Last active August 29, 2015 13:55
Array Shuffle
arrayShuffle = (arr, numOfSwaps = arr.length / 2) ->
#copy array
newArr = arr.slice(0)
for i in [0...numOfSwaps]
rnd1 = Math.floor( Math.random() * arr.length )
rnd2 = Math.floor( Math.random() * arr.length )
#swap elements
buf = newArr[rnd1]