Skip to content

Instantly share code, notes, and snippets.

View FGRibreau's full-sized avatar
✍️
writing "#NoBullshit Tech-Lead" book https://getnobullshit.com

Francois-Guillaume Ribreau FGRibreau

✍️
writing "#NoBullshit Tech-Lead" book https://getnobullshit.com
View GitHub Profile

Keybase proof

I hereby claim:

  • I am fgribreau on github.
  • I am fgribreau (https://keybase.io/fgribreau) on keybase.
  • I have a public key whose fingerprint is 8B23 A013 21BD 8FB0 A0E1 6095 55EE 155C 4B46 0AE2

To claim this, I am signing this object:

#!/usr/bin/env bash
# exit code will be != 0 if "my-website-to-check" ssl certificate (or everything else) is invalid
wget -nv https://my-website-to-check.com > /dev/null
{
"apps": [{
"name": "My app",
"script": "server.js",
"instances": 2,
"port": 8080,
"exec_mode": "cluster_mode"
}],
"deploy": {
"production": {
@FGRibreau
FGRibreau / SingletonTester-issue.js
Created February 8, 2015 12:00
Addy Osmani - Essential JavaScript Design Patterns - Singleton issue
//This "SingletonTester" is not a valid Singleton because:
var InnerConstructor = SingletonTester.getInstance({
pointX: 5
}).constructor;
console.log(new InnerConstructor() !== new InnerConstructor()); // true
$ cat package.json | grep "test"
"test": "zsh -c 'setopt extended_glob;mocha -t 5000 -R spec **/*.test.js~node_modules/*; zsh -i'",
$ npm test
> zsh -c 'setopt extended_glob;mocha -t 5000 -R spec **/*.test.js~node_modules/*; zsh -i'
(... tests start ...)
$ cat package.json | grep "test"
"test": "mocha -t 5000 -R spec **/*.test.js~node_modules/*",
$ npm test
> mocha -t 5000 -R spec **/*.test.js~node_modules/*
/www/statwarn-monitoring-api/node_modules/mocha/lib/utils.js:494
if (!files.length) throw new Error("cannot resolve path (or pattern) '"
^
Error: cannot resolve path (or pattern) '**/*.test.js~node_modules/*'
function getBackgroundColor (user) {  
  var m = user.picture.match(/avatar\/(\w+|$)/);
  if (m && m[1]) {
    return '#' + m[1].substring(0,6);
  }
}

Bonne idée ! Quelques remarques cependant :

@FGRibreau
FGRibreau / student_question.js
Last active August 29, 2015 14:11
student_question.js
'use strict';
/**
$node perfs.js
___________________________________________________[Bench] Generating table (size=1600000) took: 593ms
sum=816028274.8700228
avg=510.01767179376424
___________________________________________________[Bench] Calculating sum took: 78ms
___________________________________________________[Bench] Sort users by rank DESC took: 2702ms
Best score user(id=1322940, score=1010, rank=0)
@FGRibreau
FGRibreau / regex.js
Last active August 29, 2015 14:06
Regex to hang on V8 engine (Chrome/NodeJS)
// The following script will hang on V8 regex engine. (It works fine on Safari Mac).
// Regex was taken from https://gist.github.com/gruber/249502
"http://www.ghislainproulx.net/Blog/2014/09/contributing-to-a-github-open-source-project-(from-a-visual-studio-developer-perspective)".replace(/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/gi, function(url){
// this will never be executed on Chrome/Node
console.log(url);
});
// Checkout your CPU consumption !
@FGRibreau
FGRibreau / trololol.js
Last active July 22, 2017 17:39
Human Benchmark
// Cleaner approach than setInterval + click.
var t = angular.element(document.querySelector('.reaction-time-test')).scope().test;
t.trials = Array.apply(null, new Array(5)).map(function(a){
var trial = t.nextTrial();
trial.result = 100;
trial.timeWaited = 3000+~~(Math.random() * 1000);
return trial;
});
t.save();