Skip to content

Instantly share code, notes, and snippets.

View fibo's full-sized avatar
🎼
Working from everywhere

Gianluca Casati fibo

🎼
Working from everywhere
View GitHub Profile
@fibo
fibo / browser-language-codes.js
Created July 21, 2019 17:19 — forked from wpsmith/browser-language-codes.js
JS: Object of Browser Language Codes
// <![CDATA[
var langCodes = {
"af": "Afrikaans",
"sq": "Albanian",
"ar": "Arabic (Standard)",
"ar-dz": "Arabic (Algeria)",
"ar-bh": "Arabic (Bahrain)",
"ar-eg": "Arabic (Egypt)",
"ar-iq": "Arabic (Iraq)",
"ar-jo": "Arabic (Jordan)",
@fibo
fibo / cache.js
Last active June 10, 2023 10:20
Service Worker implementing stale-while-revalidate caching strategy.
/* global caches, fetch, self */
// Fill here with your cache name-version.
const CACHE_NAME = 'my-cache-v1'
// This is the list of URLs to be cached by your Progressive Web App.
const CACHED_URLS = [
'/',
'/bundle.js',
'/manifest.json',
'/register.js',
@fibo
fibo / README.md
Last active December 3, 2020 13:59
Flatten an array of arbitrarily nested arrays of values into a flat array of values. e.g. [[1,2,[3]],4] -> [1,2,3,4].

flattenArray

Flatten an array of arbitrarily nested arrays of values into a flat array of values

Usage

// Both CommonJS and ES6 import syntaxes are supported
// import flattenArray from './flattenArray'
const flattenArray = require('./flattenArray')
@fibo
fibo / server.js
Created June 28, 2017 22:02
meteo server yahoo weather
var express = require('express')
var weather = require('yahoo-weather')
var app = express()
app.get('/', (req, res) => {
res.send('hello')
})
app.get('/:city', (req, res) => {
@fibo
fibo / generate_taxonomy.js
Last active March 2, 2017 22:36
Problem: array of streams. There are two input CSV files streamed to one output JSON file stream. THe code works, but what about scaling the number of inputs? Solution: reduce an array of streams.
#!/usr/bin/env node
const fs = require('fs')
const path = require('path')
/**
* Converts a tree path to number
*
* BE.2.8 -> 2 + 100 * 8 + 100^2 * 0 + 100^3 * 0
*
@fibo
fibo / Microservice-component-definition.md
Last active April 28, 2016 09:47
is a set of requirements that define a microservice component pluggable in an API gateway

Microservice component

is a set of requirements that define a microservice component pluggable in an API gateway

Definition

A Microservice component is a [microservice][microservices] that serves a [REST API][REST] behind an API Gateway. The API Gateway is, for instance, binded to domain api.example.org and it must serve resources over https. The chosen technology is [nginx][nginx] but can be any reverse proxy.

Coding Guidelines

README Driven Development

From Tom Preston-Werner's article,

Write your Readme first.

Create a README.md in your repository root folder and write there all information

@fibo
fibo / Website-component-definition.md
Last active June 30, 2016 10:21
is a set of requirements that define a webapp pluggable in a website

Website component

is a set of requirements that define a report component pluggable in a console site

Definition

A Website component is a Single-page application embedded in a web site, for instance console.example.org.

The main web site is a container: it provides an authentication layer for users, and an access token to fetch

@fibo
fibo / springer-free-maths-books.md
Created December 28, 2015 20:05 — forked from bishboria/springer-free-maths-books.md
Springer have made a bunch of maths books available for free, here are the direct links