Skip to content

Instantly share code, notes, and snippets.

@jonathanlxy
jonathanlxy / generate_dates.sql
Last active September 11, 2023 14:33
Generate continuous dates between two dates in snowflake
-- Reference: https://community.periscopedata.com/t/18wkh8/generate-series-of-dates-in-snowflake
-- Documentation of SEQx(): https://docs.snowflake.net/manuals/sql-reference/functions/seq1.html
-- Since SEQx() does not guarantee gap-free sequence, row_number() needs to be used on top of SEQx()
SELECT activity_date, calendar, COUNT(1)
FROM table1 AS t1
RIGHT JOIN (SELECT row_number() OVER (ORDER BY SEQ4()) AS days
, TO_DATE(DATEADD(day, days, '2019-05-01')) AS calendar
FROM TABLE(GENERATOR(rowcount=>80)))
ON t1.activity_date = calendar
GROUP BY 1, 2
@jonathanlxy
jonathanlxy / XPS15_Ubuntu
Created May 23, 2018 22:56
Notes for configuring ubuntu on XPS 15
# Find out what's the recommended driver
ubuntu-drivers devices
# Install the driver
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt install nvidia-driver-396
# If system stays hanging while booting, change the grub default parameters
sudo vim /etc/default/grub