Skip to content

Instantly share code, notes, and snippets.

View edbizarro's full-sized avatar
🎲
Crunching data

Eduardo Bizarro edbizarro

🎲
Crunching data
View GitHub Profile
@jtalmi
jtalmi / dbt_linter.py
Last active March 15, 2022 20:41
dbt linter -- check for unique/not_null tests and description/columns
#!/usr/bin/env python3
"""
CI script to check:
1. Models have both a unique and not_null test.
2. Models have a description and columns (i.e. a schema.yml entry)
"""
import json
import logging
import os
import subprocess
@eduardorost
eduardorost / merge-schemas.scala
Last active December 19, 2023 09:36
Merge Schema with structs
import org.apache.spark.SparkConf
import org.apache.spark.sql.SparkSession
import org.apache.spark.sql.types._
import org.slf4j.{Logger, LoggerFactory}
object Main {
val logger: Logger = LoggerFactory.getLogger(this.getClass)
private lazy val sparkConf: SparkConf = new SparkConf()
.setMaster("local[*]")
#!/usr/bin/env python3
'''Script to autogenerate dbt commands for changed models against a chosen git branch,
with support for fully refreshing models with specific tags.
Usage:
$ python3 dbt_run_changed.py --target_branch master --target dev --commands [run, test] --full_refresh_tags [full_refresh]
Assume model1 and model2 are changed models and model2 is tagged with "full_refresh". The script will generate three dbt commands:
1. dbt run --target dev --model model2 --full-refresh
@drewbanin
drewbanin / example_model.sql
Created July 24, 2019 23:14
Rollup materialization on Snowflake
-- models/example_model.sql
{{ config(
materialized='rollup',
rollups={
"hourly": "date_trunc('hour', event_time)",
"daily": "date_trunc('day', event_time)"
},
aggregates={
WITH RECURSIVE traversed (id, name, path, `left`, `right`) AS (
SELECT id,
name,
CAST(JSON_ARRAY(id) AS JSON),
`left`,
`right`
FROM binary_tree
WHERE id = 1
UNION
SELECT b.id,
@Billz95
Billz95 / .php_cs.dist
Last active January 15, 2024 02:58
A Customised fixer for PHP-CS-Fixer to use `prettier`'s php plugin to pre-process the code before getting analysed by other fixers. This would enable `php-cs-fixer` to take advantage of `prettier`'s ability of managing long line.
<?php
require_once __DIR__.'/relative/path/to/PrettierPHPFixer/File';
return PhpCsFixer\Config::create()
->registerCustomFixers([
(new PrettierPHPFixer()),
])
->setRules([
'Prettier/php' => true,
@edbizarro
edbizarro / .php_cs
Last active April 13, 2019 22:02
PHP CS FIXER for Laravel projects (inspired by https://gist.github.com/joaorobertopb/a979f2f970e0ccbef6a2ab1a47a71fff)
<?php
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' =>
[
'align_equals' => true,
@bearloga
bearloga / druid-csv-spec_country-all.json
Last active June 25, 2019 05:48
Druid ingestion spec for gzipped CSV data
{
"type": "index_hadoop",
"spec": {
"ioConfig": {
"type": "hadoop",
"inputSpec": {
"paths": "hdfs://analytics-hadoop/tmp/gsc-all.csv.gz",
"type": "static"
}
},
@NiFNi
NiFNi / check_nano_node.sh
Last active March 17, 2018 12:40
Check if a local nano node with RPC enabled is reachable. If not send an email.
# Before usage make sure to have a working mail setup.
# If you are not sure what that means and you run Ubuntu just run "apt install mailutils" and
# choose following settings (be sure to replace example.com with your domain):
# General type of mail configuration?: Internet Site
# System mail name: example.com
# Root and postmaster mail recipient: username
# Other destinations to accept mail for: $myhostname, example.com, mail.example.com, localhost.example.com, localhost
# Force synchronous updates on mail queue?: No
# Local networks: 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
@sebastiencs
sebastiencs / volume.sh
Last active February 13, 2024 11:19
Script to get volume notification with dunst http://imgur.com/a/qWgAw
#!/bin/bash
# You can call this script like this:
# $./volume.sh up
# $./volume.sh down
# $./volume.sh mute
function get_volume {
amixer get Master | grep '%' | head -n 1 | cut -d '[' -f 2 | cut -d '%' -f 1
}