Skip to content

Instantly share code, notes, and snippets.

View kshitij10496's full-sized avatar

Kshitij Saraogi kshitij10496

View GitHub Profile
@kshitij10496
kshitij10496 / ergast.sql
Created December 6, 2021 15:54
SQL commands to create DB tables on PostgreSQL
CREATE TABLE circuits(
circuitId INTEGER NOT NULL PRIMARY KEY,
circuitRef VARCHAR(255) NOT NULL,
name VARCHAR(255) NOT NULL,
location VARCHAR(255) DEFAULT NULL,
country VARCHAR(255) DEFAULT NULL,
lat NUMERIC(8,5) DEFAULT NULL,
lng NUMERIC(10,6) DEFAULT NULL,
alt INTEGER DEFAULT NULL,
url VARCHAR(255) NOT NULL UNIQUE
@kshitij10496
kshitij10496 / pg_random_integer.sql
Created May 28, 2021 15:27
[Postgres] Helper function to generate random integer in a range
-- Helper function to generate random integer in a range.
-- Extremely useful for generating mock data for testing.
CREATE OR REPLACE FUNCTION RANDOM_BETWEEN(low INT ,high INT)
RETURNS INT AS
$$
BEGIN
RETURN floor(random()* (high-low + 1) + low);
END;
$$ language 'plpgsql' STRICT;
@kshitij10496
kshitij10496 / Makefile
Last active March 25, 2021 15:00
Minimalistic help recipe for Makefiles
.PHONY: help
help: ## Show this help.
@echo "Targets:"
@grep -E '^[a-zA-Z\/_-]*:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\t%-20s: %s\n", $$1, $$2}'
@kshitij10496
kshitij10496 / diffy_traffic.sh
Created July 11, 2019 08:17
Bash Script for sending traffic to diffy instance for the example Docker image.
#!/usr/bin/env bash
echo "Send some traffic to your Diffy instance"
declare -a endpoints=("success" "noise" "regression" "noisy_regression")
declare -a values=("mixpanel" "twitter" "airbnb" "paytm" "baidu")
for i in {1..10}
do
for k in "${endpoints[@]}"
do
for v in "${values[@]}"
do
@kshitij10496
kshitij10496 / pvp.py
Created April 26, 2019 18:40
Jena's MTP Code
import numpy as np
import matplotlib.pyplot as plt
def plot(x, y, deg, well):
'''
x, y are the inputs (porosity and permeability) respectively.
deg = degree of the ploynomial best-fit curve.
well = name of the well.
'''
z = np.polyfit(x, y, deg)
@kshitij10496
kshitij10496 / build.sh
Created January 26, 2019 12:57 — forked from isacikgoz/build.sh
Simple bash script for cross-compiling Go code for release
#!/bin/bash
#
APP_VER="0.3"
BUILD_ARCH_AMD64="amd64"
BUILD_ARCH_ARM64="arm64"
BUILD_ARCH_ARM="arm"
BUILD_ARCH_x86="386"
@kshitij10496
kshitij10496 / docker-compose.yml
Created January 17, 2019 16:15
[Postgres with Docker]: Data Persistence
version: '3'
services:
postgres:
image: postgres:11.1-alpine
container_name: shadowsDB
environment:
POSTGRES_DB: "league_of_shadows"
POSTGRES_USER: "batman"
POSTGRES_PASSWORD: "blueflower"
@kshitij10496
kshitij10496 / docker-compose.yml
Created January 17, 2019 15:58
[Postgres with Docker]: Loading data into DB
version: '3'
services:
postgres:
image: postgres:11.1-alpine
container_name: shadowsDB
environment:
POSTGRES_DB: "league_of_shadows"
POSTGRES_USER: "batman"
POSTGRES_PASSWORD: "blueflower"
@kshitij10496
kshitij10496 / 2.sql
Created January 17, 2019 15:52
[Postgres with Docker] Table Insertion SQL
INSERT INTO members (name, bio) VALUES (E'Ra\'s al Ghul', E'He is the founder of The League of Shadows.');
INSERT INTO members (name, bio) VALUES ('Bruce Wayne', E'Batman\'s secret identity is Bruce Wayne, an American billionaire, playboy, philanthropist, and owner of Wayne Enterprises.');
INSERT INTO members (name, bio) VALUES ('Talia al Ghul', E'She is the daughter of Ra\'s al Ghul.');
INSERT INTO members (name, bio) VALUES ('Bane', E'Bane was once a member of The League until he was excommunicated by Ra\'s al Ghul.');
@kshitij10496
kshitij10496 / 1.sql
Created January 17, 2019 15:51
[Postgres with Docker] Table Creation SQL
CREATE TABLE IF NOT EXISTS members (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
bio TEXT
);