Skip to content

Instantly share code, notes, and snippets.

@yatishbalaji
yatishbalaji / find_bad_urls.sh
Created February 20, 2023 06:38
find all urls which doesn't have 2xx statuscode
#!/bin/bash
while IFS='' read -r line || [[ -n "$line" ]]; do
statusCode=$(curl -s -o /dev/null -I -w "%{http_code}" $line)
if [[ "$statusCode" != 2* ]]; then
echo "${statusCode},${line}"
fi
done < "$1"
# Usage: bash find_bad_urls.sh urls.txt >> failedurls.csv
@yatishbalaji
yatishbalaji / PubSub.ts
Last active September 3, 2021 12:04
custom JS pubsub
export interface IPubSubOptions {
maxListeners?: number;
}
export class PubSub {
private maxListeners: number;
private listenerCount: number;
private eventListeners: Map<string, Function[]>;
@yatishbalaji
yatishbalaji / nodecron.js
Last active March 17, 2021 05:26
node cron
#!/usr/bin/env node
const debug = require('debug');
const program = require('commander');
const bluebird = require('bluebird');
const {
GRONIT_URL, CALCULATE_TAT_GRONIT_ID, NODE_ENV,
} = require('../config/environment');
const log = (...args) => {
console.log(...args);
@yatishbalaji
yatishbalaji / cron
Last active March 17, 2021 05:28
node cron runner
#!/usr/bin/env node
const path = require('path');
require('dotenv').config({ path: path.join(__dirname, '.env') });
const program = require('commander');
let cron;
let main;
program
.version('0.0.1')
@yatishbalaji
yatishbalaji / multiDirGit
Last active January 14, 2021 12:29
Create Alias to run any command on multiple directories. EG: Used for maintaining multiple git repositories by single command
export workspace=($HOME"/projects/project1" $HOME"/projects/project2");
export multiDirExec() {
for dir in ${workspace[@]}; do
echo 'Running >>>> '$dir ' >>>> ' $1 ;
(cd "$dir" && eval "$1");
done;
}
# GET VERSION
yarn -v (or --version)
# GET HELP
yarn help
# CREATE PACKAGE.JSON
yarn init
yarn init -y // Use defaults
# cache directive for all static apps
index index.html;
ssl_certificate /etc/nginx/ssl/ssl-bundle.crt;
ssl_certificate_key /etc/nginx/ssl/star.quezx.com.key;
# maintenance mode if file maintenance_on.html present
if (-f $document_root/maintenance_on.html) {
return 503;
}
error_page 503 @maintenance;
# cache directive for all static apps
index index.html;
ssl_certificate /etc/nginx/ssl/ssl-bundle.crt;
ssl_certificate_key /etc/nginx/ssl/star.quezx.com.key;
# maintenance mode if file maintenance_on.html present
if (-f $document_root/maintenance_on.html) {
return 503;
}
error_page 503 @maintenance;
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/Users/yatish/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
projDir='~/releases'
declare -A MYMAPS=(
["partner"]='staging'
["hire"]='dev'
["manage"]='staging'
);
launchCmd=()