Skip to content

Instantly share code, notes, and snippets.

View tusharvikky's full-sized avatar
💭
contemplating...

Tushar Deo tusharvikky

💭
contemplating...
View GitHub Profile
@tusharvikky
tusharvikky / app.py
Created June 25, 2022 22:56
Creating shared schema multi-tenancy using python
app = FastAPI(
title="Project X",
description="Project X API",
version="1.0.0"
],
)
app.include_router(v1_router, prefix="/api/v1", dependencies=[Depends(AppOrigin)])
@tusharvikky
tusharvikky / buildspec.staging.yaml
Created March 18, 2022 20:34
Setup CD using ECR and ECS
version: 0.2
phases:
install:
commands:
- nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay2 &
- timeout 15 sh -c "until docker info; do echo .; sleep 1; done"
pre_build:
commands:
- echo Logging in to Amazon ECR...
@tusharvikky
tusharvikky / db.js
Last active February 13, 2022 19:07
NodeJs Multi-Tenant Structure
initDatabase = () => {
const sequelize = new Sequelize(
'database',
'username',
'password',
{
host: 'host',
port: 'port',
dialect: 'mysql',
pool: {
@tusharvikky
tusharvikky / aws-alb.tf
Last active January 15, 2022 23:05
Deploying your nodejs to Fargate, AWS ECS/ECR via Terraform
resource "aws_lb" "main" {
name = "${var.name}-alb-${var.environment}"
internal = false
load_balancer_type = "application"
security_groups = var.alb_security_groups
subnets = var.subnets.*.id
enable_deletion_protection = false
tags = {
@tusharvikky
tusharvikky / pyspark-setup.ipynb
Last active January 25, 2021 17:40
PySpark Setup
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import random
games_total = 0
while games_total <= 0:
print(f'How many games would you like to play?')
games_total = int(input())
for x in range(games_total):
@tusharvikky
tusharvikky / letsencrypt_2017.md
Created February 27, 2018 13:26 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two main modes to run the Let's Encrypt client (called Certbot):

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80).

In the following, we're setting up mydomain.com. HTML is served from /var/www/mydomain, and challenges are served from /var/www/letsencrypt.

@tusharvikky
tusharvikky / Linux commands
Created December 17, 2016 11:26
Linux Commands
# show top 10 biggest subdirs in the current dir.
du -sk * | sort -nr | head -10
@tusharvikky
tusharvikky / Envoy.blade.php
Created June 28, 2016 18:54
Laravel Envoy Task Runner
@servers(['staging' => 'root@192.168.0.99', 'production' => 'root@192.168.0.100'])
<?php
$app_name = 'l5eka';
$app_path = '/var/www/vhosts/'.$app_name;
$repo = 'https://github.com/vedovelli/l5eka';
$branch = 'aula4';
$github_token = ''; // GitHub OAuth token
$server_name = '192.168.0.99'; // IP ou domínio válido. Usado no nginx
@tusharvikky
tusharvikky / drop.sql
Last active June 28, 2016 07:45
Drop all tables of a DB
mysql -u<db_username> -p<db_password> -Nse 'show tables' <db_name> | while read table; do echo "SET FOREIGN_KEY_CHECKS = 0; drop table $table;"; done | mysql -u<db_username> -p<db_password> <db_name>