Skip to content

Instantly share code, notes, and snippets.

View Altons's full-sized avatar

Alberto Negron Altons

View GitHub Profile
@Altons
Altons / README.md
Created October 31, 2022 11:28 — forked from jeremyyeo/README.md
Building SCD-2 models using the default incremental materialization #dbt

Building SCD-2 models using the default incremental materialization

  1. Bootstrap the source / snapshot table source_users and the initial state of our scd2 table dim_users by running:
dbt run -m source_users dim_users
  1. Copy over contents of dim_users_inc.sql replacing contents in dim_users.sql (or just rename them). Then run:
@Altons
Altons / dag.py
Created August 5, 2021 11:19 — forked from adamhaney/dag.py
DBT Airflow DAG with model/graph introspection
from datetime import datetime, timedelta
import networkx as nx
from airflow import DAG
from airflow.operators import BashOperator, SubDagOperator
start_date = datetime(year=2017, month=6, day=13, hour=19, minute=0)
schedule_interval = '0 * * * 1-5'
default_args = {
@Altons
Altons / JaroWinklerStringSimilarity.sql
Created March 29, 2021 18:32 — forked from paulirwin/JaroWinklerStringSimilarity.sql
Jaro-Winkler String Similarity in T-SQL
-- Based on code here: http://www.sqlservercentral.com/articles/Fuzzy+Match/65702/
-- Modified to be used in SQL Server Database Projects or run on its own, and fixed similarity vs distance confusion
CREATE FUNCTION [dbo].JaroWinklerGetCommonCharacters(@firstWord VARCHAR(MAX), @secondWord VARCHAR(MAX), @matchWindow INT)
RETURNS VARCHAR(MAX) AS
BEGIN
DECLARE @CommonChars VARCHAR(MAX)
DECLARE @copy VARCHAR(MAX)
DECLARE @char CHAR(1)
DECLARE @foundIT BIT
@Altons
Altons / Brewfile
Last active December 16, 2024 20:21
List of most have tools for my laptop
# frozen_string_literal: true
# tap "heroku/brew"
# tap 'homebrew/bundle'
# tap 'homebrew/cask'
# tap 'homebrew/cask-versions'
# tap 'homebrew/core'
# tap "stripe/stripe-cli"
brew 'icu4c'
brew 'gcc'
@Altons
Altons / calendarHeat.R
Created February 9, 2020 10:26 — forked from aaronwolen/calendarHeat.R
Calendar Heatmap by Paul Bleicher
##############################################################################
# Calendar Heatmap #
# by #
# Paul Bleicher #
# an R version of a graphic from: #
# http://stat-computing.org/dataexpo/2009/posters/wicklin-allison.pdf #
# requires lattice, chron, grid packages #
##############################################################################
## calendarHeat: An R function to display time-series data as a calendar heatmap
@Altons
Altons / migration.rb
Created November 23, 2019 09:03 — forked from apneadiving/migration.rb
incremental invoice numbers without gap in rails + postgresql
class CreateInvoiceNumbers < ActiveRecord::Migration
def up
create_table :invoice_numbers do |t|
t.integer :year, null: false, unique: true
t.integer :next_number_within_year, null: false, default: 1
end
add_index :invoice_numbers, :year, unique: true
(2016..2045).each do |year|
@Altons
Altons / spanish_postal_code_validator.rb
Created September 16, 2019 15:53 — forked from backpackerhh/spanish_postal_code_validator.rb
Spanish postal code validator for Rails
# Usage:
#
# class MyClass < ActiveRecord::Base
# ...
# validate :postal_code, spanish_postal_code: true # default message
# validate :postal_code, spanish_postal_code: { message: '<Your message>' } # custom message
# ...
# end
#
class SpanishPostalCodeValidator < ActiveModel::EachValidator
@Altons
Altons / .editorconfig
Last active November 11, 2021 14:38
.editorconfig
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
trim_trailing_whitespace = true
charset = utf-8
GIT
remote: https://github.com/spree-contrib/spree_i18n.git
revision: 5021782dacb25c906b52925cec25494fbdd78dea
specs:
spree_i18n (3.3.2)
i18n_data
kaminari-i18n
rails-i18n
routing-filter
spree_core (>= 3.1.0, < 4.0)
@Altons
Altons / index.md
Created August 14, 2018 10:44 — forked from rstacruz/index.md
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one