Skip to content

Instantly share code, notes, and snippets.

View siakaramalegos's full-sized avatar
🦄

Sia siakaramalegos

🦄
View GitHub Profile
@siakaramalegos
siakaramalegos / crux_by_shopify_theme.sql
Last active September 6, 2024 14:57
CrUX/HTTPArchive query for aggregated performance by Shopify theme (sampled)
# Shopify themes passing core web vitals
CREATE TEMP FUNCTION IS_GOOD (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS (
good / (good + needs_improvement + poor) >= 0.75
);
CREATE TEMP FUNCTION IS_POOR (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS (
poor / (good + needs_improvement + poor) > 0.25
);
CREATE TEMP FUNCTION IS_NON_ZERO (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS (
@siakaramalegos
siakaramalegos / cwv_tech_report_shopify.sql
Last active July 22, 2024 06:25
CrUX data by technology for Shopify stores only
# UPDATE THIS EACH MONTH
DECLARE _YYYYMMDD DATE DEFAULT '2023-07-01';
CREATE TEMP FUNCTION IS_GOOD(good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS (
SAFE_DIVIDE(good, good + needs_improvement + poor) >= 0.75
);
CREATE TEMP FUNCTION IS_NON_ZERO(good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS (
good + needs_improvement + poor > 0
@siakaramalegos
siakaramalegos / run_queries.sh
Last active August 5, 2022 18:14
Runs queries on BigQuery and outputs results to local CSV files
#!/bin/bash
#
# Converts BigQuery SQL to CSV.
#
# Usage:
#
# Before starting, install the BigQuery CLI, bq https://cloud.google.com/sdk/docs/install
#
# 1. Find all your queries and output the list of files into query_list.txt:
# `find almanac.httparchive.org/sql/2022/mobile-web/*.sql > query_list.txt`
@siakaramalegos
siakaramalegos / getLCPdetails.js
Last active June 29, 2021 23:39
Custom metric for getting LCP image details
function getLcpElement() {
return new Promise((resolve) => {
new PerformanceObserver((entryList) => {
const lcpCandidates = entryList.getEntries();
const naiveLcpEntry = lcpCandidates[lcpCandidates.length - 1];
resolve(naiveLcpEntry);
}).observe({ type: "largest-contentful-paint", buffered: true });
}).then(({ startTime, element, url, size, loadTime, renderTime }) => {
let attributes = [];
@siakaramalegos
siakaramalegos / index.html
Created November 25, 2020 19:21
basic html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hi from Netlify</title>
</head>
<body>
<h1>My first Netlify deploy 💌</h1>
</body>
@siakaramalegos
siakaramalegos / debug.txt
Created November 24, 2020 19:47
DEBUG=* netlify dev output for eleventy project
2020-11-24T19:42:19.111Z Eleventy Directories:
Input: .
Data: _data
Includes: _includes
Layouts: undefined
Output: _site
Template Formats: html,njk
Verbose Output: false
2020-11-24T19:42:19.140Z Eleventy:EleventyFiles Searching for: [ './**/*.html', './**/*.njk', '!./_site/**', '!./node_modules/**', '!./package-lock.json', '!./.DS_Store', '!./.netlify/**', '!./_site/**', '!./_includes/**', '!./_data/**' ]
2020-11-24T19:42:19.147Z Eleventy:TemplateWriter Found: [ './src/index.html', './src/_includes/layout.njk' ]
@siakaramalegos
siakaramalegos / prettier.md
Last active January 12, 2022 00:41
Adding Prettier to a project

Adding Prettier to a Project

Basic steps for adding Prettier to a project and setting up a pre-commit hook when not using any other linter. Most of these steps can be found in the docs and through other links in the docs.

  1. Install prettier:
$ npm install --save-dev --save-exact prettier
  1. Create an empty config file to let tools know you're using Prettier:
@siakaramalegos
siakaramalegos / choose-a-tron.markdown
Last active November 12, 2020 23:33
CHOOSE-A-TRON
@siakaramalegos
siakaramalegos / Dev-api-summary.md
Last active November 23, 2019 21:42
Dev.to API summary for possible Bridgy integration
@siakaramalegos
siakaramalegos / webmentions.njk
Created November 22, 2019 21:06
Version of my webmentions nunjucks file used when writing my post about Webmentions and Eleventy
<div class="webmentions content-grid-sibling" id="webmentions">
{% set mentions = webmentions | getWebmentionsForUrl(metadata.url + webmentionUrl) %}
{% set reposts = mentions | webmentionsByType('repost-of') %}
{% set repostsSize = reposts | size %}
{% set likes = mentions | webmentionsByType('like-of') %}
{% set likesSize = likes | size %}
{% set replies = mentions | webmentionsByType('in-reply-to') %}
{% set repliesSize = replies | size %}