Skip to content

Instantly share code, notes, and snippets.

View sandipb's full-sized avatar

Sandip Bhattacharya sandipb

View GitHub Profile
View .bashrc.kube_gcp_proxy.sh
export GCLOUD_TUNNEL_PID=/tmp/gcloud-tunnel-pid
function proxy_bastion() {
local BASTION_HOST="bastion-instance"
local GCP_ZONE="us-east4-a"
[[ -f $GCLOUD_TUNNEL_PID ]] && echo "File $GCLOUD_TUNNEL_PID exists. A previous tunnel might be active. Aborting." && return
set -x
gcloud compute ssh $BASTION_HOST --zone=$GCP_ZONE --verbosity=warning --tunnel-through-iap --ssh-flag='-D1080 -N' &
View install_vscode_extensions.sh
#!/usr/bin/env bash
EXTENSIONS=(
# General
ms-vscode-remote.vscode-remote-extensionpack
ms-vscode-remote.remote-ssh
stkb.rewrap
tomsaunders-code.workspace-explorer
# Golang
golang.go
@sandipb
sandipb / decrypt_pdf.sh
Created May 10, 2023 21:25
Script to decrypt PDFs using qpdf. Will ask for password only if needed.
View decrypt_pdf.sh
#!/bin/bash
set -e -o pipefail
usage() {
cat <<HELP
USAGE: $0 PDF_FILE [OUTPUT_DIR|OUTPUT_FILE]
Decrypts given pdf file usingh qpdf by prompting for a password.
@sandipb
sandipb / route.sh
Created April 22, 2023 06:58
How to enable a linux host to route between two lans
View route.sh
#!/bin/bash
# $PRIVATE_IF is private lan, $PUBLIC_IF is public lan
# the interface which is connected to the interface.
# The default route of this host is already set via this interface
PUBLIC_IF=enp1s0
# The interface connecting to the internal lan, which needs this host to be a router to the Internet
PRIVATE_IF=enp2s0
@sandipb
sandipb / create new django project.sh-session
Last active March 13, 2023 17:52
Creating new django project
View create new django project.sh-session
$ mkdir dtemp
$ cd dtemp
$ poetry init
This command will guide you through creating your pyproject.toml config.
Package name [dtemp]: Django Test
@sandipb
sandipb / age_sorted_names.pp
Created July 20, 2022 13:31
Puppet sort hash
View age_sorted_names.pp
$data = [
{'name'=> 'emily', 'age'=> 6},
{'name'=> 'john', 'age'=> 5},
{'name'=> 'jade', 'age'=> 4},
{'name'=> 'grant', 'age'=> 2},
]
function age_sorted_names($ar) >> Array {
$ar.map |$idx, $entry| {
[$entry['age'], $entry['name']]
@sandipb
sandipb / README.md
Last active May 5, 2022 02:46
Fix cups-pdf not printing PDFs with restrictions
View README.md
@sandipb
sandipb / playbook.yml
Created September 27, 2021 22:58
Get non-matching kernels on all hosts using ansible
View playbook.yml
---
- hosts: ubuntu
gather_facts: yes
vars:
kernel_does_not_match: "{{ (ansible_distribution == 'Ubuntu') and ( ansible_kernel != '5.4.0-86-generic') }}"
output_path_local: /tmp/host_kernels
tasks:
- block:
- name: Add matching host to file
@sandipb
sandipb / Description.md
Last active August 5, 2020 10:35
Example code to use the Golang httprouter library
@sandipb
sandipb / newcert.sh
Created June 21, 2020 11:37
Bash script to generate new server certificates and private key, for the OpenSSL Certificate Authority guide by Jamie
View newcert.sh
#!/bin/bash
# set -x
set -e
cd $(dirname $0)
# The path to the homebrew install on mac. Change to point to your own installation
OPENSSL="/usr/local/Cellar/openssl@1.1/1.1.1g/bin/openssl"
NAME=${1:?Need a hostname for generating certs}
DAYS=375
export SAN="DNS:$NAME"