Skip to content

Instantly share code, notes, and snippets.

@mattm
mattm / ad-insights-primary-key.lookml
Last active October 1, 2018 19:34
Ad Insights Primary Key
dimension: primary_key {
type: string
sql: concat(cast(${date_date} as string), ${campaign_id}, ${country}) ;;
hidden: yes
primary_key: yes
}
@mattm
mattm / facebook-ad-insights-spend.sql
Last active October 1, 2018 19:28
Facebook Ad Insights Spend
select
campaign_id,
sum(spend) as total_spend,
sum(impressions) as total_impressions,
sum(spend) / sum(impressions) * 1000 as cpm,
sum(inline_link_clicks) as link_clicks,
sum(inline_link_clicks) / sum(impressions) as ctr
from facebook_ad_insights.ad_insights
where date = '2018-10-01'
group by 1
@mattm
mattm / gist:6263032
Last active September 26, 2018 06:56
POPULATION_SIZE = 24
NUM_BITS = 64
NUM_GENERATIONS = 1000
CROSSOVER_RATE = 0.7
MUTATION_RATE = 0.001
class Chromosome
attr_accessor :genes
@mattm
mattm / base-model-macro-variable.sql
Created June 11, 2018 13:58
dbt base model macro variable
select
id,
email
from {{ source(var('base.users')) }}
@mattm
mattm / dbt-source.sql
Created June 11, 2018 13:54
dbt source macro
{% macro source(table_name) %}
{% if target.name == 'prod' %}
{{ return("preceden_heroku." ~ table_name) }}
{% else %}
{{ return(table_name) }}
{% endif %}
{% endmacro %}
@mattm
mattm / base-model.sql
Created June 11, 2018 13:50
dbt base model
select
id,
email
from {{ var('base.users') }}
@mattm
mattm / base-table.yml
Created June 11, 2018 13:48
dbt base table name
vars:
"base.users" : "users"
@mattm
mattm / available-marketing-domains.txt
Created May 24, 2018 19:25
Available Marketing Domains
AANDG
AAS
ABILENE
ABRASIVE
ACCOMPLICE
ACENTO
ACTIONSPORTS
ADAGE
ADAIR
ADAY
@mattm
mattm / com.zone
Created May 18, 2018 17:12
.com Zone File, First 100 Lines
; The use of the Data contained in Verisign Inc.'s aggregated
; .com, and .net top-level domain zone files (including the checksum
; files) is subject to the restrictions described in the access Agreement
; with Verisign Inc.
$ORIGIN COM.
$TTL 900
@ IN SOA a.gtld-servers.net. nstld.verisign-grs.com. (
1526140941 ;serial
1800 ;refresh every 30 min
@mattm
mattm / com.zone.txt
Created May 18, 2018 17:10
Zone File
; The use of the Data contained in Verisign Inc.'s aggregated
; .com, and .net top-level domain zone files (including the checksum
; files) is subject to the restrictions described in the access Agreement
; with Verisign Inc.
$ORIGIN COM.
$TTL 900
@ IN SOA a.gtld-servers.net. nstld.verisign-grs.com. (
1526140941 ;serial
1800 ;refresh every 30 min