Skip to content

Instantly share code, notes, and snippets.

View vijayparikh's full-sized avatar

Vijay Parikh vijayparikh

View GitHub Profile
-- DateDiff function that returns the difference between two timestamps in the given date_part (weeks, months, etc) as an integer
-- This behaves like the DateDiff function in warehouses like Redshift and Snowflake, which count the boundaries between date_parts
CREATE OR REPLACE FUNCTION datediff (date_part VARCHAR(30), start_t TIMESTAMP, end_t TIMESTAMP)
RETURNS INT AS $diff$
DECLARE
years INT = 0;
days INT = 0;
hours INT = 0;
minutes INT = 0;
@sverrirs
sverrirs / AdsInlineTag.rb
Last active October 1, 2020 23:34
How to create a Jekyll custom tag that injects Google Ads into posts
# http://www.createdbypete.com/articles/create-a-custom-liquid-tag-as-a-jekyll-plugin/
class AdsInlineTag < Liquid::Tag
def initialize(tag_name, input, tokens)
super
@input = input
end
def lookup(context, name)
lookup = context
name.split(".").each { |value| lookup = lookup[value] }