Skip to content

Instantly share code, notes, and snippets.

@mgagliardo91
mgagliardo91 / plotly.json
Created January 25, 2024 15:29
plotly.json
{"layout":{"title":{"text":""},"margin":{"l":16,"r":16,"b":16,"t":16},"showlegend":true,"legend":{"x":0,"y":0}},"data":[{"type":"pie","values":[588672,283320,258408,196800,177096,100848,54288,49872,29304,28800],"labels":["Product 2518","Product 1699","Product 2433","Product 1406","Product 2482","Product 2306","Product 1503","Product 1809","Product 2455","Product 44031"],"hole":0.4,"marker":{"color":["#F06292","#CE93D8","#9FA8DA","#81D4FA","#80CBC4","#A5D6A7","#E6EE9C","#FFE082","#FFAB91","#B0BEC5"]}}]}
CREATE FUNCTION public.show_all_chunks_detailed_size()
RETURNS TABLE(
hypertable text,
chunk text,
time_range tstzrange,
total_bytes bigint,
total_size text,
table_size text,
index_size text,
toast_size text,
@mgagliardo91
mgagliardo91 / Branch_Protection_Dependabot.md
Last active March 31, 2022 15:19
Branch Protection Dependabot

Branch Protection Dependabot

Adding dependabot

  1. Create a .github/dependabot.yaml file with the shape:
version: 2
updates:
  # For Node/NPM
@mgagliardo91
mgagliardo91 / clean_staging_duplicates.sql
Last active January 27, 2022 21:17
Timescale Deletions
-- The following function will work through the staging table by month and delete any data points from the staging table that
-- are duplicates of the data in the source table. This will ensure that the backfill script will not decompress chunks to upsert
-- the same exact data point. Ideally, it should reduce the amount of chunks that need to be decompressed.
CREATE OR REPLACE PROCEDURE public.clean_staging_duplicates(
tenant text
) AS $proc$
DECLARE
earliest_time timestamptz;
latest_time timestamptz;
time_range timestamptz;
@mgagliardo91
mgagliardo91 / Message_Bus_Client_Retry_Mechanism.md
Last active June 23, 2021 19:01
Message Bus Client Retry Mechanism

Message Bus Client Retry Mechanism

A recent version of the message bus client includes updates that will ensure the client will attempt to retry its connection to the server when lost.

Follow the steps below to include the enhancement:

Instructions

  1. Bump to the latest version of the message bus client
-- Extensions
CREATE EXTENSION IF NOT EXISTS timescaledb;
-- Data source
CREATE TABLE IF NOT EXISTS sources (
source_id SERIAL PRIMARY KEY,
source_key VARCHAR(64) NOT NULL,
facility_id INT NOT NULL,
description TEXT,
UNIQUE(source_key)
CREATE OR REPLACE FUNCTION pg_temp.rename_scopes(old text, new text) RETURNS void AS $$
BEGIN
UPDATE service_instance_scopes
SET label = new
WHERE label = old;
END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION pg_temp.clone_scope(existing text, newv text, descv text) RETURNS void AS $$
DECLARE
@mgagliardo91
mgagliardo91 / Jira_Schema_Migration_Plan.md
Last active January 29, 2020 12:52
Jira Schema Migration Plan

Jira Schema Migration Plan

The following migration plan should be carried out in each environment sequentially, starting with dev. It should be easy to roll-back, if any issues surface.

Stop the web service deployment and the Flink topology

Stop the descriptor using the following command:

kubectl scale deployments/injector-jira --replicas=0
@mgagliardo91
mgagliardo91 / react-ts-default-props.tsx
Created September 5, 2019 13:48
Default Props in React with TS
import React from 'react';
interface ComponentProps = {
value: string;
intValue: number;
}
// Inline
const component = ({ value = "default", intValue = 100 }: ComponentProps) => {
@mgagliardo91
mgagliardo91 / Example.java
Last active July 11, 2019 16:01
GitHub Injector Show & Tell
// Square Map Function
stream.map(new RichMapFunction<Integer, Integer>() {
@Override
public Integer map(Integer input) {
return input * input;
}
});
// Flat Map transform a string to an stream of individual characters
stream.flatMap(new RichFlatMapFunction<String, String>() {