Skip to content

Instantly share code, notes, and snippets.

View Zacaria's full-sized avatar
🦀

Zacaria Chtatar Zacaria

🦀
View GitHub Profile
@Zacaria
Zacaria / threshold.js
Created June 2, 2016 09:50
Find the upper closest element in an array
var max = 20;
var array = [10, 23, 5, 40, 19, 24];
var closest = array.filter(function(elem) {
return elem >= max;
}).sort().reverse().pop();
@Zacaria
Zacaria / jsonReader.js
Created June 9, 2016 12:35
read all json files in a folder
var jsons = require('require-dir')('./json');
console.log(jsons);
@Zacaria
Zacaria / promise.js
Created June 9, 2016 12:38
Transform thunk into promise
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
};
@Zacaria
Zacaria / randomcolor.js
Created July 19, 2016 14:19
Random color
function randomColor() {
return '#' + Math.floor(Math.random() * 16777215).toString(16);
}
@Zacaria
Zacaria / Reduce
Last active November 23, 2016 13:31
Reactive thinking : http://reactivex.io/learnrx/
function() {
var movieLists = [
{
name: "New Releases",
videos: [
{
"id": 70111470,
"title": "Die Hard",
"boxarts": [
{ width: 150, height:200, url:"http://cdn-0.nflximg.com/images/2891/DieHard150.jpg" },
@Zacaria
Zacaria / gulpfile.js
Created December 3, 2016 18:25
Basic Gulpfile
'use strict';
var gulp = require('gulp');
var browserSync = require('browser-sync');
var nodemon = require('gulp-nodemon');
gulp.task('default', ['browser-sync'], function () {
});
gulp.task('browser-sync', ['nodemon'], function() {
@Zacaria
Zacaria / package.json
Created December 23, 2016 23:34
api dev on openshift
{
"name": "api",
"version": "0.0.1",
"description": "myAPI",
"main": "./bin/www.js",
"scripts": {
"start": "node_modules/.bin/pm2 start dist/bin/www.js -i max",
"serve": "nodemon src/bin/www.js --exec babel-node",
"clean": "rm -rf dist/ && mkdir dist",
"deploy-patch": "npm version patch && npm run deploy",
@Zacaria
Zacaria / index.html
Last active December 28, 2016 10:51
Flex layout sticky head and foot
<section class="bloc">
<div class="title">
<h1>Titre</h1>
</div>
<div class="content">
<div class="content-title">
titre content
</div>
<div class="button-container">
Some button
@Zacaria
Zacaria / asyncSeries.js
Created December 29, 2016 14:12
async.series implementation
// Create async function array
const eFcts = ['f1', 'f2','f3'].map((url) =>
(err, cb) =>
setTimeout(() => {
cb(err, 'async ' + url)
}, 100)
);
// Wraps runner to keep track of results
const series = (pFcts, pDone) => {
@Zacaria
Zacaria / index.html
Created January 5, 2017 14:06 — forked from anonymous/index.html
JS Bin // source http://jsbin.com/haruja
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div id="app"></div>
<script src="https://fb.me/react-15.1.0.js"></script>