Skip to content

Instantly share code, notes, and snippets.

View jujhars13's full-sized avatar

Jujhar Singh jujhars13

View GitHub Profile
@jujhars13
jujhars13 / wonky-insert-script.sh
Created November 21, 2022 11:08
insert into sqlite demo
#!/bin/bash
echo "SELECT * FROM people" | sqlite3 person.sqlite
echo "INSERT INTO people (firstName,lastName)
VALUES
('john', 'marsden-"{$RANDOM_ID}"')
" | sqlite3 person.sqlite
echo "SELECT * FROM people" | sqlite3 person.sqlite
MY_NAME=nitish
@jujhars13
jujhars13 / vimNotes.sh
Created April 19, 2021 09:52
vimNotes using vim to save my notes on a weekly basis (bound to super+N)
#!/bin/bash
# inspired by Leafshade software https://www.youtube.com/watch?v=zB_3FIGRWRU&t=333s
# daily notes
#noteFilename="$HOME/Dropbox/notes/notes/note-$(date +%Y-%m-%d).md"
# weekly notes
fileDate="$(date +%Y-%m-%d)"
if [[ "$(date +%a)" != "Mon" ]]; then
fileDate="$(date -dlast-monday +%Y-%m-%d)"
fi
@jujhars13
jujhars13 / delete-ns.sh
Last active July 25, 2022 13:42
deleting kubernetes namespaces that are stuck in "Terminating..."
#!/bin/bash
# Thanks to https://medium.com/@craignewtondev/how-to-fix-kubernetes-namespace-deleting-stuck-in-terminating-state-5ed75792647e
# NB this can be dangerous, so use sparingly
export ns=broken-app; kubectl get ns "${ns}" -o json | sed s/\"kubernetes\"//g | kubectl replace --raw /api/v1/namespaces/"${ns}"/finalize -f -
@jujhars13
jujhars13 / .zshrc
Last active June 4, 2020 10:10
Create a log entry for my daily work log, a bit like workingon.co used to work. Commits changes to git
# log what I'm working on to a text file unde `$repo/<year>/<month>/<day>.md`
# change the $repo variable to point to a dir on your machine
# if the dir is a git repo then it will also commit to git, otherwise just do nothing
#
# USAGE: on "working on creating a script to make things better"
function on(){
local version="1.1.4"
local repo="/home/jujhar/proj/jujhar-daily-log"
local year=$(date +%Y)
local month=$(date +%m)
@jujhars13
jujhars13 / azOpenPortOnRg.sh
Last active June 4, 2018 20:38
To open a particular port on an Azure security group to your current IP
#!/bin/bash
# 2018-06-04 script to add your current IP address to access a specific
# $PORT on a security group
# for az cli tools install see https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest
#
# to run for your current IP address:
# NAME="mySecGroup" PORT=6379 ./azOpenPortOnRg.sh
# or to run for another IP address:
# IP=43.22.33.11 NAME="mySecGroup" PORT=6379 ./azOpenPortOnRg.sh
@jujhars13
jujhars13 / keybase.md
Created May 21, 2018 20:26
keybase.md

Keybase proof

I hereby claim:

  • I am jujhars13 on github.
  • I am jujhars13 (https://keybase.io/jujhars13) on keybase.
  • I have a public key ASAeglvTR_nhA9rKjRcQaBdkPWx6vNOBRP-mhCBos2rl_go

To claim this, I am signing this object:

# perform a fresh install of Ubuntu 17.10
# upgrade the kernel to v4.13.10
mkdir ~/kernel-v4.13.10
cd ~/kernel-v4.13.10
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.13.10/linux-headers-4.13.10-041310_4.13.10-041310.201710270531_all.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.13.10/linux-headers-4.13.10-041310-generic_4.13.10-041310.201710270531_amd64.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.13.10/linux-image-4.13.10-041310-generic_4.13.10-041310.201710270531_amd64.deb
sudo dpkg -i *.deb
@jujhars13
jujhars13 / main.go
Created February 13, 2018 08:10
Kubernetes 101 course - basic web server in Go
package main
import (
"net/http"
"strings"
"fmt"
)
func sayHello(w http.ResponseWriter, r *http.Request) {
fmt.Print("Request made to ", r.URL.Path)
message := r.URL.Path
message = strings.TrimPrefix(message, "/")
@jujhars13
jujhars13 / index.js
Last active December 2, 2020 12:25
Kubernetes 101 course - basic no-deps web server in Node
/**
* Plain Rest Web api, no external deps
* Nodejs > 14
*/
const http = require("http");
const {
port = 8080,
yourName = "Themba",
environment = "development",
} = process.env;