Skip to content

Instantly share code, notes, and snippets.

View FlorianBELLAZOUZ's full-sized avatar

Florian Bellazouz FlorianBELLAZOUZ

View GitHub Profile
@FlorianBELLAZOUZ
FlorianBELLAZOUZ / times.js
Created April 13, 2017 12:37
run a function x times
const times = (func,n)=>{for(var i=n;i>0;i--)func(n-i)}
@FlorianBELLAZOUZ
FlorianBELLAZOUZ / bitSize.js
Created April 13, 2017 06:12
Get the bitsize of a int 32bits
const bitSize = num=>num===0?1:Math.floor(Math.log(num)/Math.log(2))+1
@FlorianBELLAZOUZ
FlorianBELLAZOUZ / centerpopupwindow.js
Last active February 7, 2017 16:48
open a center pop window
const popup= (url, title, w, h)=>{
var y = window.outerHeight / 2 + window.screenY - ( h / 2)
var x = window.outerWidth / 2 + window.screenX - ( w / 2)
return window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + w + ', height=' + h + ', top=' + y + ', left=' + x);
}
@FlorianBELLAZOUZ
FlorianBELLAZOUZ / cloneDeep.js
Last active December 2, 2016 16:54
A quick clone deep function
const cloneDeep = (obj, clone={})=>{
for(var i in obj)
clone[i] = typeof obj[i] === "object" ? cloneDeep(obj[i], obj[i].constructor()) : obj[i];
return clone;
}
module.exports={
entry: {
'bundles/client.specs': __dirname+'/client/unitTest/client.specs.js',
'bundles/E2E.specs':__dirname+'/client/E2ETest/E2E.specs.js',
'bundles/main':__dirname+'/client/lib/Director.js',
'../bin/kaaashop':[__dirname+'/client/panel.js'] // <-- only this with a libraryTarget commonjs
},
output: {
path: __dirname + '/client',
filename: '[name].bundle.js',
[
{ "button": "scroll_down", "modifiers": ["ctrl"], "command": "null" },
{ "button": "scroll_up", "modifiers": ["ctrl"], "command": "null" },
{ "keys": ["ctrl+h"], "command": "move", "args": {"by": "characters", "forward": false} },
{ "keys": ["ctrl+l"], "command": "move", "args": {"by": "characters", "forward": true} },
{ "keys": ["ctrl+k"], "command": "move", "args": {"by": "lines", "forward": false} },
{ "keys": ["ctrl+j"], "command": "move", "args": {"by": "lines", "forward": true} },
{ "keys": ["shift+ctrl+h"], "command": "move", "args": {"by": "characters", "forward": false, "extend": true} },
{ "keys": ["shift+ctrl+l"], "command": "move", "args": {"by": "characters", "forward": true, "extend": true} },
@FlorianBELLAZOUZ
FlorianBELLAZOUZ / app.ts
Last active December 29, 2015 16:11
Basic bootstarp for Angular 2.0
// app/app.ts
import {bootstrap} from 'angular2/platform/browser';
import {Component} from 'angular2/core';
@Component({
selector:"app",
template:"<h1>coucou</h1>"
})
class TodoApp {}
@FlorianBELLAZOUZ
FlorianBELLAZOUZ / angular2.sublime-project
Last active December 29, 2015 16:20 — forked from benatkin/Global.sublime-settings
sublime-project - excluding file or directory
{
"folders":
[
{
"path": "*",
"folder_exclude_patterns": [".git", "node_modules"],
"file_exclude_patterns":["*.js","*.js.map"]
}
]
}
@FlorianBELLAZOUZ
FlorianBELLAZOUZ / fibonacci.js
Created November 20, 2015 18:34
minimal fibonacci ( arrow function ) - 25 o
f=n=>n<=1?n:f(n-2)+f(n-1)
f(10) // return 55
@FlorianBELLAZOUZ
FlorianBELLAZOUZ / convertiseurSeconde
Last active November 17, 2015 11:38
Convertir secondes en chaines de cratère, exemple : convetiseurSeconde(50403) == "1j 11h 0m 3s"
function convertiseurSeconde(secondes){
var d = [["s",60],["m",60],["h",24],["j",30],["m",12],["a",100],["s",10],["m",Infinity]];
var cur = 0, out = "";
return ((function (last){
out = Math.floor(last)%d[cur][1]+d[cur][0]+" "+out;
if(last >= d[cur][1]) arguments.callee((cur++,last / d[cur][1]));
})(secondes),out);
}