Skip to content

Instantly share code, notes, and snippets.

sdkks sdkks

  • Singapore
Block or report user

Report or block sdkks

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sdkks
sdkks / add-to-bashrc.sh
Created Oct 2, 2018
How to add solarized dark colors to your theme if your terminal doesn't have `theming` support
View add-to-bashrc.sh
# Old school way of setting Solarized Dark Theme for WSL MinTTY theme
echo -ne '\eP\e]10;#839496\a' # Foreground -> base0
echo -ne '\eP\e]11;#002B36\a' # Background -> base03
echo -ne '\eP\e]12;#DC322F\a' # Cursor -> red
echo -ne '\eP\e]4;0;#073642\a' # black -> Base02
echo -ne '\eP\e]4;8;#002B36\a' # bold black -> Base03
echo -ne '\eP\e]4;1;#DC322F\a' # red -> red
echo -ne '\eP\e]4;9;#CB4B16\a' # bold red -> orange
echo -ne '\eP\e]4;2;#859900\a' # green -> green
echo -ne '\eP\e]4;10;#586E75\a' # bold green -> base01 *
@sdkks
sdkks / get-fingerprint.sh
Created Sep 27, 2018
How to get MD5 fingerprints of your SSH keys
View get-fingerprint.sh
$ find . -name '*.pub' | xargs -I%% bash -c 'echo $1 - $(ssh-keygen -EMD5 -lf $1)' -- %%
> ./analytics.pub - 2048 MD5:dc:3d:8f:ab:58:1a:f8:a7:70:d0:35:37:24:fd:d2:26 username@laptop (RSA)
@sdkks
sdkks / README.md
Last active Oct 8, 2018
Make Couchbase 5.5 Server Image with Debian Jessie on GCP using Packer
View README.md

Requirements

  1. Packer from hashicorp
  2. Service account with necessary permissions (account.json), if unsure just make it project owner for dev purposes.
  3. Modify the couchbase.json with necessary parameters for yourself. Ideally it should have pd-ssd disk type and at least 4GB ram.

More info: https://www.packer.io/intro/getting-started/build-image.html

@sdkks
sdkks / README.md
Last active Mar 27, 2020
How to SSH to Kubernetes Pod with SSH ProxyCommand using socat
View README.md

Requirements

  1. socat
  2. kubectl with proper ~/.kube/config that can connect to your cluster
  3. Working knowledge of kubectl client
  4. OpenSSH client

How does it work?

  1. kubectl does port forwarding to sshd port of your pod. I'm using pm2 process managed to keep my services alive in my workstation container. If you have only sshd, easiest to use is dropbear
  2. ProxyCommand of OpenSSH client uses socat to redirect two way fd - to forwarded port of kubectl
  3. Voila! You are in
@sdkks
sdkks / README.md
Last active Sep 22, 2018
Windows how to copy paste like Mac OSX terminal using Alt instead of CMD in Linux Terminal Emulators with AHK AutoHotKey
View README.md

HOW TO

Why

Copy Paste (CTRL+C) command doesn't work for Linux terminals as CTRL+C is used for SIGINT signal to stop/interrupt works on Linux shell.

Prerequisites

You are on Windows but need to have Linux shell like bash or zsh and using one of popular terminal emulators

Steps

  1. Download and Install AHK (AutoHotKey) // https://autohotkey.com/
  2. Put copy-paste.ahk anywhere in your machine and double click after saving it.
  3. Voila, now Alt + C (same position as CMD + C) will work just like Macbook on most of Linux Terminal emulators on Windows (tested with Cmder, MinTTY, Hyper.JS)
@sdkks
sdkks / .profile.ps1
Last active Sep 15, 2018
How to use Hyper.JS with PowerShell to Connect to your Kubernetes (K8S) Workstation Terminal
View .profile.ps1
Set-PSReadlineOption -EditMode Emacs
$env:KUBECONFIG="c:\Users\<your path to special kubeconfig for your gke/eks/aks cluster>\kube-config"
kubectl get pod | Select-String "ws-" | Select-String "Running" | %{ "$_".split(" ")[0]} | %{kubectl exec -ti $_ -- su - said}
@sdkks
sdkks / .vacuum-nodes.sh
Created Jul 14, 2018
Vacuum journalctl of nodes in your inventory
View .vacuum-nodes.sh
#!/usr/bin/env bash
exitCode(){
case $1 in
0)
echo "Completed with success"
;;
*)
echo "Exited with failure: $1"
;;
@sdkks
sdkks / simpleHttpServer.sh
Created Jul 14, 2018
Run HTTP server from working directory with this function - to be added into your shell .zshrc / .bashrc
View simpleHttpServer.sh
http(){
python3 <(<<EOF
#!/usr/bin/env python3
from http.server import SimpleHTTPRequestHandler, test
import argparse
class InlineHandler(SimpleHTTPRequestHandler):
@sdkks
sdkks / git-cheatsheet.md
Last active Jul 3, 2018
Git Cheat-Sheet With Examples
View git-cheatsheet.md

Git Basics

This is WIP, evolving over time. Feel free to comment for errors/suggestions.

It's more of personal notes, comes with no guarantees or responsibility.

Always think twice before pushing a risky change.

Legend:

$ means it's your command prompt, don't enter $, only what is right to it. Lines in gray blocks that don't start with $ are output from commands.

@sdkks
sdkks / bash-template.sh
Last active May 15, 2019
Bash template for less buggy and easy to debug scripts
View bash-template.sh
#!/usr/bin/env bash
# Bash strict mode
# Error on undefined variable: -u
# Exit on ERR: -e
# Functions inherit ERR traps: -E
# Exit on pipe failures: -o pipefail
set -eEuo pipefail
# Directory of this script
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
You can’t perform that action at this time.