View enphase_solar_plot.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(httr) | |
library(jsonlite) | |
library(lubridate) | |
library(tidyverse) | |
########### config | |
# | |
# my info - replace this with your enphase api key, app id, user_id |
View add-missing-datalayer-event.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var oldPush = window.dataLayer.push; | |
window.dataLayer.push = function() { | |
var states = [].slice.call(arguments, 0); | |
states.forEach(function(s) { | |
if (!s.hasOwnProperty('event')) { | |
s.event = 'default'; | |
} | |
}); | |
return oldPush.apply(window.dataLayer, states); |
View wide_to_long.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create or replace table `PROJECTNAME.DATASETNAME.performance_long` partition by DATE(timestamp) as | |
with base as ( | |
select | |
timestamp, date, event_timestamp, clientid, user_id, device_category, country, url, hostname, | |
page_path, page_title, page_referrer, type | |
from `PROJECTNAME.DATASETNAME.performance_wide` | |
) | |
,intervals as ( |
View transform_to_wide.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create or replace table `PROJECTNAME.DATASETNAME.performance_wide` partition by DATE(timestamp) as | |
/* | |
wide version of nested events table | |
*/ | |
SELECT | |
TIMESTAMP_MICROS(event_timestamp) as timestamp, | |
DATE(TIMESTAMP_MICROS(event_timestamp)) as date, |
View tdf.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(httr) | |
library(jsonlite) | |
library(ggplot2) | |
library(dplyr) | |
# url with TDF standings | |
url <- "https://sportapi.widgets.sports.gracenote.com/cycling/getresult/classificationid/2148837/languagecode/1.json?c=64&module=cycling&type=classification" | |
standings <- fromJSON(content(GET(url), "text")[[1]]) |
View GTM_track_autocomplete.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GTM custom HTML tag for tracking incomplete searches | |
// logic: if user starts typing, start a timer. Stop the timer when user is idle 2.5 seconds | |
// then push the event on the DL | |
(function() { | |
var timer, firstResult, searchText; | |
var waiting = false; | |
var waitTime = 2500; // milliseconds |
View all_join_types.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- create two tables: L and R | |
-- content of tables a "val" column with two rows. | |
-- rows in L: "left only" and "both" | |
-- rows in R: "right only" and "both" | |
with l as ( | |
select 'both' as val | |
union | |
select 'left_only' as val | |
), r as ( |
View cohort_chart.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From: https://stuifbergen.com/2018/03/cohort-analysis-with-snowplow-and-r/ | |
########## 1: get data | |
appname <- "NAME" # used as selection criterium, replace that with the name of your app | |
q <- paste0(" | |
SELECT | |
user_id, | |
TO_CHAR(CONVERT_TIMEZONE('UTC', 'Europe/Amsterdam', derived_tstamp),'YYYY ww') AS yw | |
FROM atomic.events | |
WHERE app_id = '", appname, "' AND derived_tstamp >= '2018-01-01' |
View supershort_manual.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Step 1: Download the binaries | |
https://github.com/Gulden/gulden-official/releases/tag/v2.0.0.9 | |
(choose Gulden-2.0.0.9-arm-linux-eabihf.tar.gz ) | |
Step 2: unpack the binaries on your NAS somewhere, create a data directory | |
(outside home, outside web root) | |
Step 3: create Gulden.conf file inside the data directory | |
https://g-dash.nl/manual/index.html |
View weatherdata.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# visualise weather in NL | |
# | |
# | |
# (c) Jules Stuifbergen 2018 - Creative Commons licence CC BY-SA | |
# | |
# | |
library(httr) | |
library(tidyverse) | |
library(lubridate) |