Skip to content

Instantly share code, notes, and snippets.

View MarkEdmondson1234's full-sized avatar
🦑
Tappity tap tap

Mark Edmondson MarkEdmondson1234

🦑
Tappity tap tap
View GitHub Profile
@MarkEdmondson1234
MarkEdmondson1234 / send_email_mailgun.R
Last active March 18, 2024 14:06
Send an email via an R function using Mailgun
#' Email a user a report is ready
#'
#' Requires an account at Mailgun: https://mailgun.com
#' Pre-verification can only send to a whitelist of emails you configure
#'
#' @param email Email to send to
#' @param mail_message Any extra info
#'
#' @return TRUE if successful email sent
#' @import httr
@MarkEdmondson1234
MarkEdmondson1234 / app.R
Last active March 14, 2024 15:42 — forked from jcheng5/app.R
Using OAuth2 with Shiny
library(shiny)
# WARNING: This sketch does not make proper use of the "state" parameter.
# Doing so usually involves using cookies, which can be done with the
# Rook package but I have not done that here. If you choose to use this
# approach in production, please check the state parameter properly!
APP_URL <- if (interactive()) {
# This might be useful for local development. If not, just hardcode APP_URL
# to the deployed URL that you'll provide a few lines below.
@MarkEdmondson1234
MarkEdmondson1234 / compareXMLtoGA.R
Last active November 11, 2023 00:25
Check 0 pageviews by comparing sitemap.XML URLs with Google Analytics visits.
library(googleAnalyticsR)
library(xml2)
library(dplyr)
ga_auth()
## date range of URLs to test
dates <- c(Sys.Date() - 30, Sys.Date())
##GA View ID
@MarkEdmondson1234
MarkEdmondson1234 / google_analytics_bigquery_user_mapping_table_customer.sql
Last active October 12, 2021 07:50 — forked from krisjan-oldekamp/google_analytics_bigquery_user_mapping_table_customer.sql
How to create a user mapping table (or Identity Graph) based on all the available user identifiers in the Google Analytics 4 BigQuery exports (like device-IDs or customer-IDs). Full article on stacktonic.com
-- Author: Krisjan Oldekamp
-- https://stacktonic.com/article/create-a-user-mapping-table-based-on-the-google-analytics-4-big-query-dataset
DECLARE
lookback_window INT64 DEFAULT 90; -- How many days to lookback into the dataset to search for IDs (compared to today)
-- Deduplicate array of struct
CREATE TEMP FUNCTION
DEDUP(val ANY TYPE) AS ((
SELECT
ARRAY_AGG(t)
FROM (
@MarkEdmondson1234
MarkEdmondson1234 / fb-ios14-email.md
Last active April 22, 2021 07:19
Facebook Marketing Partners Team response for Apple's iOS14 Privacy prompt

Hi Mark,

Yesterday (April 20, 2021), Apple confirmed it will make iOS 14.5 available to all iOS users next week, and it will start requiring apps in the App Store to obtain permission through its AppTrackingTransparency framework to “track” users across apps and websites owned by third parties for advertising and measurement purposes.

With the general availability of iOS 14.5 (week of April 26), we will begin rollout of our new advertiser experiences and measurement protocols – including Apple’s SKAdNetwork API (SKAN) and Facebook’s Aggregated Event Measurement (AEM). Once the specific date of the general availability release of 14.5 is confirmed, we will establish the rollout timing of our new experiences and communicate this timing.

You and your clients can expect to see changes in our business and advertising tools, campaign set up, targeting, delivery, measurement, and reporting, following the release of iOS 14.5 and Apple’s prompt enforcement. We are sharing a summary of these changes below, as well a

@MarkEdmondson1234
MarkEdmondson1234 / dynamicSelectShinyModule.R
Last active November 21, 2020 00:09
Shiny modules for creating dynamic SelectInputs
library(shiny)
#' Safe subset
#'
#' @param df Dataframe
#' @param column One name of column to subset within
#' @param subset Vector of entries in column to subset to
#'
#' If column not in df, returns back the df
safeSubset <- function(df, column, subset){
@MarkEdmondson1234
MarkEdmondson1234 / server.r
Created February 16, 2014 10:22
Cascading Menu System for Shiny
library(shiny)
## test dataframe
df <- data.frame(option1 = c("A","A","B","B","C","C"),
option2 = c("A1","A2","B3","B1","C2","C3"),
option3 = c(T,F,T,F,T,F),
option4 = c("a","b","c","d","e","f"))
shinyServer(function(input, output, session) {
@MarkEdmondson1234
MarkEdmondson1234 / snippet_modules.R
Last active July 17, 2020 08:37
RStudio snippet to make a shortcut for Shiny Module scaffolding
snippet module
#' ${1:module_name} UI
#'
#' Shiny Module for use with \link{${1:module_name}}
#'
#' @param id Shiny id
#'
#' @return Shiny UI
${1:module_name}UI <- function(id){
library(shiny)
dynamicSelectInput <- function(id, label, multiple = FALSE){
ns <- shiny::NS(id)
shiny::selectInput(ns("dynamic_select"), label,
choices = NULL, multiple = multiple, width = "100%")
}
@MarkEdmondson1234
MarkEdmondson1234 / auth.r
Last active February 24, 2020 22:25
Authenticate a Twitter app in R
# Refer to https://rtweet.info/