Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

select table_id, round(sum(size_bytes)/(1024*1024*1024),2) as size_GB
FROM `PROJECT.DATASET.__TABLES__`
group by table_id
union all
select table_id, round(sum(size_bytes)/(1024*1024*1024),2) as size_GB
FROM `PROJECT.DATASET.__TABLES__`
group by table_id
SELECT date,
case when date = (select max(date) from `chrome-ux-report.materialized.metrics_summary`) then "Latest" else "Historical" end as latest,
origin,
slow_fcp,avg_fcp,fast_fcp,
slow_lcp,avg_lcp,fast_lcp,
small_cls,medium_cls,large_cls
FROM `chrome-ux-report.materialized.metrics_summary`
WHERE origin in (
"https://www.example.cz",
@paveljasek
paveljasek / Budget Guard pro jeden účet (CZ)
Last active February 8, 2018 13:59
Adwords Script to check yesterday campaign performance
// Budget Guard hlídá, zda se některé kampaně přiblížily využití denního rozpočtu
// Upravte nastavení a naplánujte si denní spouštění skriptu v Google AdWords
// Autor: Pavel Jašek, jasek@google.com
// Nastavení: upravte práh citlivosti a obsah e-mailu
var threshold = 0.9; // Hranice pro překročení rozpočtu. 0.9 = 90 %
var recepients = "jasek@google.com";
var subject = "Kampaně včera překročily 90 % rozpočtu";
var header = "Ahoj,<br>následující kampaně překročily 90 % nastaveného rozpočtu. Zkontroluj je, prosím, ať se nepřipravuješ o další výkon!<br><br>";
#LyX 2.1 created this file. For more info see http://www.lyx.org/
\lyxformat 474
\begin_document
\begin_header
\textclass book
\begin_preamble
\usepackage{multirow,array}
\end_preamble
\use_default_options true
\maintain_unincluded_children false
// This AdWords Script makes sure that keywords are managed in exact and broad match modifier campaigns.
// Whenever the script finds an adgroup, keyword or ad text in exact match campaign that was not already
// copied into broad match modifier campaign, it does that and labels the entity accordingly.
// Broad match campaigns need to be created at first place.
// Customize the BidModifier to update bids for broad match ad groups [line 20] and identification of your campaigns [lines 15, 19 and 26]; 
// jasek@google.com
// Known issues: if you have ads with tracking templates, custom parameters or mobile final URLs, please check lines 116-118
// Known issues: if you have keywords with final URLs, please check line 91
library(igraph)
# how to extract the list from JavaScript object on https://poradci.cz/
# for (p in poradci) {jeden = poradci[p]; for (kdo in jeden[1]) {j = jeden[0]; k = jeden[1][kdo];console.log("'",poradci[k][0].trim(), "', '", j , "'")}}
# Pavel Jašek, Twitter: @paveljasek
# last update: Dec 18, 2016
poradci <- graph( c(
@paveljasek
paveljasek / Delete first line
Created October 6, 2016 09:24
Delete first line of a file
# Get rid of the first line in a file
sed '1d' change_history.csv > change_history_v2.csv
@paveljasek
paveljasek / Shopping XML to CSV
Last active August 29, 2016 20:51
Itemize shopping XML feed into CSV tabular format
# xmlutils are required: https://github.com/knadh/xmlutils.py
# basically you need to install it on unix via pip command
pip install xmlutils
# xml2csv takes an xml file, reads tags that correspond to the desired element and output a csv file delimited by the parameter
# delimiter is changes from comma to semicolon as some items can have titles including commas
xml2csv --input sample.xml --output sample.csv --tag "item" --delimiter ";"
@paveljasek
paveljasek / Number of product items in a XML
Created August 29, 2016 09:12
Count number of product items in a XML feed
# Search for lines including a string and count number of these lines
grep -o '<item>' feed.xml | wc -l
# case insensitive string replace of BRAND to BRAND_XXX
# also creates a backup file
sed -i.bak s/[bB][rR][aA][nN][dD]/BRAND_XXX/g overlapping.csv