Skip to content

Instantly share code, notes, and snippets.

View jeremyyeo's full-sized avatar

Jeremy Yeo jeremyyeo

View GitHub Profile
SELECT SUM(sessioncount)
FROM digitalmarketing_dbo.acquire_sessionsbychannelgeo
WHERE 1 = 1
AND reportingmonth = '2018-12-01'
AND country = 'Australia'
-- aurora: 257847
SELECT SUM(sessioncount)
FROM DigitalMarketing.Acquire.SessionsByChannelGeo
WHERE 1 = 1
@jeremyyeo
jeremyyeo / pgsql-lead-test.sql
Last active August 8, 2019 00:29
SQL check to see if the next row is different and return a value of the row if so.
CREATE TEMP TABLE IF NOT EXISTS
temp_table(
user_id character varying,
record_version numeric,
user_flag text
)
;
INSERT INTO
temp_table(user_id, record_version, user_flag)

Anheuser-Busch InBev (BUD) manufactures the popular "Corona" brand of beer and due to the recent outbreak (2020-01-01) of a virus with the same name (Coronavirus), there has been much more negative impact on their stock than other major alcoholic beverage manufacturers.

  • BUD - Budweiser, Corona, Stella Artois.
  • HEINY - Heineken, Amstel, Sol, Tiger.
  • RI.PA - Pernod Ricard, Absolut Vodka, Chivas Regal, Jacob's Creek.

The data is the adjusted closing stock prices of the respective manufacturers and has been forward filled where dates without reported data uses data from the closest previous day with reported data.

@jeremyyeo
jeremyyeo / add-swap.md
Last active January 18, 2022 22:12
Adding swap memory to Ubuntu instance
library(ggplot2)
library(dplyr)
library(readxl)
my_data <- read_excel("Downloads/File.xls") # Read excel file.
iris %>%
ggplot(aes(x = Sepal.Length, y = Sepal.Width)) +
facet_grid(Species ~ .) +
geom_line()
@jeremyyeo
jeremyyeo / main.R
Last active April 15, 2020 23:25
Loading cache from an RMarkdown doc into an interactive R session.
# Load the cached data in an interactive session.
lazyLoad("main_cache/html/data_xxxxxxxxxxxxxx") # Notice the lack of a file extension.
mean(x)
setwd("~/repos/get-results/") # Set your folder.
library(rvest)
root <- "https://www.electionresults.govt.nz/electionresults_2020_preliminary"
page <- read_html(paste0(root, "/voting-place-statistics.html"))
all_links <- page %>% html_nodes("a") %>% html_attr("href")
all_links <- gsub("\\./", "/", grep("\\.csv$", all_links, value = T))
for (l in all_links) {
file_path <- paste0(root, l)
@jeremyyeo
jeremyyeo / SessionState.py
Created April 9, 2021 11:47
Test dynamic widgets
# https://gist.github.com/tvst/036da038ab3e999a64497f42de966a92
from streamlit.report_thread import get_report_ctx
import streamlit as st
class SessionState(object):
def __init__(self, **kwargs):
"""A new SessionState object.
@jeremyyeo
jeremyyeo / main.yml
Created April 17, 2021 21:32
Installing docker with ansible
---
- name: Install packages for Docker
apt:
pkg:
- apt-transport-https
- ca-certificates
- curl
- gnupg-agent
- software-properties-common
state: present
@jeremyyeo
jeremyyeo / install-terraform.sh
Created September 21, 2021 05:37
Install terraform on macOS
#!/bin/bash
curl -sS https://releases.hashicorp.com/terraform/1.0.7/terraform_1.0.7_darwin_amd64.zip > terraform.zip &&
unzip terraform.zip &&
mv terraform /usr/local/bin/