Skip to content

Instantly share code, notes, and snippets.

View tjmonsi's full-sized avatar

Toni-Jan Keith Monserrat tjmonsi

View GitHub Profile
@tjmonsi
tjmonsi / gist:2c324bc3bf9373ff6df5fcc8df235693
Last active January 30, 2020 12:03
Database Structure
Firebase
// database-name
// - data
// - $id
// - data-itself
// - lists
// - list-name
// - $parent-ids-for-querying
// - list-of-ids
@tjmonsi
tjmonsi / Promise.any.md
Created August 13, 2019 05:50
A short introduction on Promise.any

A Short introduction on Promise.any

Promise.any allows us to have a list of promises to be executed, and once one of them finishes, it quickly resolves it. If all of them fails, it throws an exception and executes the reject part with a list of all exceptions.

Project.race can do this right?

Project.race does a similar thing but with one difference. If one of the promises return an error, it will reject immediately even if there's at least one promise that is resolved, regardless if the the resolved project comes first or not.

How do we do it before?

#standardSQL
-- counts top fonts that are locally hosted
WITH
response_bodies AS (
SELECT * FROM `httparchive.sample_data.response_bodies_desktop_1k`
-- UNION ALL
-- SELECT * FROM `httparchive.sample_data.response_bodies_mobile_1k`
),
#standardSQL
-- counts the local() inside @font-face
WITH
response_bodies AS (
SELECT * FROM `httparchive.sample_data.response_bodies_desktop_1k`
-- UNION ALL
-- SELECT * FROM `httparchive.sample_data.response_bodies_mobile_1k`
),
#standardSQL
-- counts the font-families used
WITH
response_bodies AS (
SELECT * FROM `httparchive.sample_data.response_bodies_desktop_1k`
UNION ALL
SELECT * FROM `httparchive.sample_data.response_bodies_mobile_1k`
),
#standardSQL
-- counts the number of usage of FontFace API
WITH
response_bodies AS (
SELECT * FROM `httparchive.sample_data.response_bodies_desktop_1k`
-- UNION ALL
-- SELECT * FROM `httparchive.sample_data.response_bodies_mobile_1k`
),
#standardSQL
-- counts the number of pages given number of font-face
WITH
response_bodies AS (
SELECT * FROM `httparchive.sample_data.response_bodies_desktop_1k`
UNION ALL
SELECT * FROM `httparchive.sample_data.response_bodies_mobile_1k`
),
#standardSQL
-- counts font-display value usage
WITH
response_bodies AS (
SELECT * FROM `httparchive.sample_data.response_bodies_desktop_1k`
UNION ALL
SELECT * FROM `httparchive.sample_data.response_bodies_mobile_1k`
),
#standardSQL
-- counts the font types
WITH
summary_requests AS (
SELECT * FROM `httparchive.sample_data.summary_requests_desktop_1k`
UNION ALL
SELECT * FROM `httparchive.sample_data.summary_requests_mobile_1k`
),
@tjmonsi
tjmonsi / popular_hosts_fonts.sql
Last active June 26, 2019 12:24
Counts the sites that delivers hosted fonts