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
@FGRibreau
FGRibreau / match-when.js
Created December 29, 2015 09:45
match-when - Pattern matching for modern JavaScript - https://github.com/FGRibreau/match-when
[2, 4, 1, 2].map(match({
[when(1)]: "one",
[when(2)]: "two",
[when()]: "many"
}));
// [ 'two', 'many', 'one', 'two' ]
@FGRibreau
FGRibreau / keybase.md
Created October 26, 2015 13:58
keybase.md

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 5979 F08D 8622 0A90 8A68 AA2B 33AF 768D F5E0 57AA

To claim this, I am signing this object:

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)