Skip to content

Instantly share code, notes, and snippets.

View rviscomi's full-sized avatar

Rick Viscomi rviscomi

View GitHub Profile
from collections import defaultdict
import json
""" https://bigquery.cloud.google.com/savedquery/226352634162:ae7566b78dff4e8baf64aae5fdfa33c0
SELECT
libs.name AS library,
INTEGER(FLOOR(pages.rank / 1000) * 1000) AS bucket,
COUNT(0) AS volume
FROM
(SELECT url, lib.name AS name FROM httparchive:scratchspace.2017_04_15_js_libs WHERE lib.name IN ('jQuery', 'Google Maps', 'Bootstrap', 'Modernizr', 'Polymer', 'Angular', 'AngularJS', 'React')) AS libs JOIN
@rviscomi
rviscomi / HA pages.js
Last active June 12, 2017 19:16
Generates a query to use with BigQuery that gets the 25/50/75 percentiles of a metric over all desktop/mobile pages tables.
/* Generated by:
SELECT
SUBSTR(CONCAT('20', _TABLE_SUFFIX), 0, 10) AS date,
CASE
WHEN ENDS_WITH(_TABLE_SUFFIX, 'mobile') THEN 'mobile'
ELSE 'desktop'
END AS client
FROM
`httparchive.runs.20*`
WHERE
// getHistogramQuery('bytesJS', '2017_05_15')
getHistogramQuery = (metric, date) => `SELECT
*
FROM
(
SELECT
'desktop' AS client,
volume,
bin,
pdf,
@rviscomi
rviscomi / meetup-raffle.js
Created February 10, 2014 22:19
Selecting a Meetup attendee at random
$('#rsvp-list li').eq(Math.floor(Math.random()*149)+1).find('a').text()
@rviscomi
rviscomi / scrape-meetups.js
Created April 3, 2018 19:55
Scrapes a Meetup.com topic's "All Meetups" page to extract name, location, and membership info.
meetups = Array.from(document.querySelectorAll('.gridList-item')).map(i => {
name = i.querySelector('a span').innerText;
where = i.querySelector('span a').innerText;
members = parseInt(i.querySelector('.text--secondary').innerText.match(/([\d\,]+)/)[0].replace(',', ''));
return {name, members, where};
})
@rviscomi
rviscomi / wappalyzerbigquery.js
Last active May 2, 2018 19:11
wappalyzer to bigquery
var wappalyzer = getWappalyzer();
function run() {
for (name in wappalyzer.apps) {
const app = wappalyzer.apps[name];
app.name = name;
app.categories = app.cats.map(c => {
return wappalyzer.categories[c].name;
});
app.implies = getImplications(app);
https://www.slideshare.net/jrvis/the-state-of-performance-in-the-wordpress-ecosystem
@rviscomi
rviscomi / multi <--> single
Created June 3, 2018 18:47
Convenience functions for turning a multi-line string into concatenated single-line strings and back
concat = q => q.split('\n').map(l => `"${l}"`).join('+\n');
multi = q => q.split('\n').map(l => l.replace(/(^"|"\+$)/g, '')).join('\n');
<script type="application/ld+json">
[
{
"@context": "http://schema.org/",
"@type": "Event"
},
{
"@context": "http://schema.org/",
"@type": "Recipe"
}
@rviscomi
rviscomi / CrashCourseInCrUX.md
Last active May 7, 2019 10:52
"Crash Course in CrUX" for the PerfMatters conference, April 2019