Skip to content

Instantly share code, notes, and snippets.

@gaspaonrocks
gaspaonrocks / introrx.md
Created January 29, 2019 10:25 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
const { hasOwnProperty } = Object.prototype.hasOwnProperty;
/**
* inlined Object.is polyfill to avoid requiring consumers ship their own
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
*/
function is(x, y) {
// SameValue algorithm
if (x === y) {
// Steps 1-5, 7-10
@gaspaonrocks
gaspaonrocks / example-test.js
Last active July 21, 2018 11:38
using mock-fs with jest to assert the result of file system operations in a sync manner
import mock from 'mock-fs';
import fs from 'fs';
import fileHandler from '../utils/fileHandler';
beforeEach(() => {
// Creates an in-memory file system
mock({
'/test': {
'note.md': 'hello world!'
}
@gaspaonrocks
gaspaonrocks / cloudSettings
Last active April 23, 2018 09:11 — forked from caedes/cloudSettings
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-04-23T09:11:43.377Z","extensionVersion":"v2.9.0"}
@gaspaonrocks
gaspaonrocks / correction_gist.js
Created August 16, 2017 09:09
test SportHeroesGroup
function fixGpsTrack(gpsTrack) {
// Make sure trackpoints are chronologically sorted by date
// il n'y a pas besoin de réaffecter gpsTrack.
gpsTrack.sort(function (trackpointA, trackpointB) {
return trackpointB.timestamp - trackpointA.timestamp;
});
// Remove incomplete trackpoints
gpsTrack.filter(function (trackpoint) {
return trackpoint.lat && trackpoint.lon && trackpoint.timestamp;
const mongoose = require('mongoose');
const express = require('express');
const faker = require('faker');
var app = express();
var userSchema = new mongoose.Schema({
email: {
type: String,
required: true,
let http = require('http');
let url = require('url');
let port = 3000;
let server = http.createServer((request, response) => {
var page = url.parse(request.url).pathname;
console.log(page);
response.writeHead(200, {
'Content-Type': 'text/plain'
body {
display: flex;
flex-direction: column;
}
div {
background-color: grey;
text-align: center;
width: 50%;
margin: auto;
process.stdin.resume()
process.stdin.setEncoding('utf8')
function isANumber(age){
return !isNaN(age);
}
console.log('Hello ! What\'s your age ? ')
process.stdin.on('data', (age) => {
if (isANumber(age) === true && age <= 99) {
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>