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 / 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 / spool_Oracle_table.sh
Last active April 22, 2020 15:26
Script to spool Oracle table content to a file
#!/bin/bash
#
# [Gist](https://gist.github.com/fibo/6807322)
#
## Configuration
#
# Don' t forget to edit filename and query, see below.
#
@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
@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 / Crivello.pl
Created September 12, 2011 22:48
Crivello Perl
use strict;
use Math::Prime::XS ':all';
my $l = $ARGV[0];
my @primes = primes($l);
my $p1 = $primes[-2];
my $p2 = pop @primes;
@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 / 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 / oracle.t
Last active May 11, 2016 12:54
Test Oracle connection
# [Gist](https://gist.github.com/fibo/5901819)
#
## How to launch
# $ prove oracle.t
use strict;
use warnings;
use DBI;
use File::Spec;
use Test::More;