Skip to content

Instantly share code, notes, and snippets.

View shivanshs9's full-sized avatar
🔥
Unlimited Code Works! ⚔️

Shivansh Saini shivanshs9

🔥
Unlimited Code Works! ⚔️
View GitHub Profile
{{/*
Because of Helm bug (https://github.com/helm/helm/issues/3001), Helm converts
int value to float64 implictly, like 2748336 becomes 2.748336e+06.
This breaks the output even when using quote to render.
Use this function when you want to get the string value only.
It handles the case when the value is string itself as well.
Parameters: is string/number
*/}}
{{- define "stringOrNumber" -}}
@shivanshs9
shivanshs9 / postgres_user_create.sql
Created February 27, 2025 13:51
Postgres script to create read-write and read-only users
/* Create Read-write PSQL user and DB */
CREATE DATABASE yourdbname;
CREATE USER youruser WITH ENCRYPTED PASSWORD 'yourpass';
GRANT ALL PRIVILEGES ON DATABASE yourdbname TO youruser;
/* Create Read-only user for db $DB */
CREATE ROLE rouser WITH LOGIN PASSWORD 'yourpass'
@shivanshs9
shivanshs9 / bash_vars.fish
Created February 13, 2025 06:49
Fish function to export env vars from bash-like command output. Basically, equivalent to source command but with support of var=value.
function set-env --description "Runs the command and sets the environment variables from the output. Kinda like source, but with additional support of var=value"
if not set -q argv[1]
echo "set-env: no command specified"
return 1
end
set cmd "$argv[1]"
eval "$cmd" | while read -l line
if test -z "$line"
continue
end
@shivanshs9
shivanshs9 / patch-argo-notif-cm.yaml
Created May 29, 2024 14:38
Adds git commit author + message to deployment notification with this ArgoCD patch
---
apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-notifications-cm
namespace: argocd
data:
template.app-deployed: |
email:
subject: New version of an application {{.app.metadata.name}} is up and running.
@shivanshs9
shivanshs9 / gh_pr.sh
Created March 5, 2024 06:22
Approve/Raise/Check a Github PR
#!/bin/bash
set -e
# Function to display help
display_help() {
echo "Usage: $0 [command] [args]"
echo "Command:"
echo " approve Approves the specified PR in format of URL"
echo " create Creates a new PR from specified args"
echo "Options:"
#!/bin/bash
set -e
# Function to display help
display_help() {
echo "Usage: $0 [options] org repo"
echo "Options:"
echo " -d, --default-branch BRANCH Set the default branch for the repository"
echo " -t, --teams TEAMS Set repository access permissions for specified teams"
echo " -j, --rule-json JSON Set ruleset for the repository"
@shivanshs9
shivanshs9 / caddyl4.Dockerfile
Last active December 31, 2023 15:32
Bastion for private EKS with Caddy reverse proxy
# syntax=docker/dockerfile:1
FROM golang:1.21-alpine AS builder
RUN apk add --no-cache git ca-certificates
RUN go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
RUN xcaddy build --with github.com/mholt/caddy-l4 --output /usr/bin/caddy && chmod +x /usr/bin/caddy
FROM alpine:3.15
RUN apk add --no-cache ca-certificates mailcap
RUN apk add bash
{
"description": "TheFaker NFT minted for DCX training",
"external_url": "https://shivanshs9.me",
"image": "https://avatars.githubusercontent.com/u/8217199?v=4",
"name": "TheFaker",
"attributes": []
}
@shivanshs9
shivanshs9 / gh_migrate_init.sh
Created September 1, 2023 10:31
Bitbucket to Github migration
#!/bin/bash
# How to use?
## bash gh_migrate_init.sh competition-service
GITHUB_ORG="coindcx-app"
JIRA="IDOPS-153"
SOURCE_FOLDER="coindcx-api-help"
prepare_repo() {
#!/bin/sh
# Assume sudo by default
[ $(id -u) -eq 0 ] || exec sudo $0 $@
for bin in /var/lib/rancher/k3s/data/**/bin/; do
[ -d $bin ] && export PATH=$PATH:$bin:$bin/aux
done
set -x