Skip to content

Instantly share code, notes, and snippets.

View mohamedhayibor's full-sized avatar
💭
Crawled out from Burnout, Back to Badass 💪🏾

Void mohamedhayibor

💭
Crawled out from Burnout, Back to Badass 💪🏾
View GitHub Profile
function each (array, callback) {
for (var i = 0; i < array.length; i++) {
callback(array[i]);
}
}
each([2, 6, 7], console.log); // => 2, 6, 7
function mapEach (array, callback) {
var result = [];
@mohamedhayibor
mohamedhayibor / download.js
Created December 25, 2015 00:50 — forked from mohsen1/download.js
Download Chromecast backgrounds
var https = require('https');
var fs = require('fs');
var url = 'https://raw.githubusercontent.com/dconnolly/chromecast-backgrounds/master/backgrounds.json';
Array.prototype.getLast = function() {
return this[this.length - 1];
};
function logFail(err){
console.log('Failed!');
var arr = [1, 2, 4, 7, 9, 6, 3];
function flatten() {
return [].reduce.call(arguments, function(sum, val) {
return Array.isArray(val) ? sum.concat(flatten.apply(null, val)) : sum.concat(val);
}, []);
}
function shuffle (array) {
var temp = [];
@mohamedhayibor
mohamedhayibor / springer-free-maths-books.md
Created December 29, 2015 04:11 — forked from bishboria/springer-free-maths-books.md
Springer have made a bunch of maths books available for free, here are the direct links
@mohamedhayibor
mohamedhayibor / memoize.js
Created December 29, 2015 16:21 — forked from addyosmani/memoize.js
memoize.js - a faster JavaScript memoizer
/*
* memoize.js
* by @philogb and @addyosmani
* further optimizations by @mathias
* Released under an MIT license.
*/
function memoize( fn ) {
return function () {
var args = Array.prototype.slice.call(arguments),
hash = "",
@mohamedhayibor
mohamedhayibor / LICENSE
Created December 31, 2015 21:07 — forked from shinout/LICENSE
Topological sort in JavaScript
Copyright 2012 Shin Suzuki<shinout310@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@mohamedhayibor
mohamedhayibor / introrx.md
Created January 30, 2016 22:17 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
function reverse(val) {
return val.split('').reverse().join('')
}
function add(a, b) {
var rBig, rSmall;
if ( Number(a) < Number(b) ) {
rBig = reverse(b);
rSmall = reverse(a);
} else {
@mohamedhayibor
mohamedhayibor / index.html
Created February 13, 2016 00:35 — forked from d3noob/index.html
Leaflet.FileLoader Plugin for Leaflet Maps
<!DOCTYPE html>
<html>
<head>
<title>Leaflet.FileLayer Plugin</title>
<meta charset="utf-8" />
<link
rel="stylesheet"
href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.css"
/>
<link
"use strict";
// simple fisher yates implementation
const shuffle = (deck) => {
let randomizedDeck = [];
let array = deck;
while ( array.length !== 0) {
let rIndex = Math.floor(array.length * Math.random());
randomizedDeck.push(array[rIndex]);
array.splice(rIndex, 1)
}