Skip to content

Instantly share code, notes, and snippets.

View awadhwana's full-sized avatar
Knowledge > Degree

AW awadhwana

Knowledge > Degree
View GitHub Profile
@awadhwana
awadhwana / rename_git_branch.sh
Last active March 31, 2022 14:31
Rename a git branch and update the remote.
#!/usr/bin/env sh
export NORMAL=$(tput sgr0)
export GREEN=$(tput setaf 2)
export YELLOW=$(tput setaf 3)
# rename a git branch
rename() {
old_name=$(git branch --show-current) # Git 2.22 and above:
#old_name=$(git rev-parse --abbrev-ref HEAD) # Git 2.22 lower
@awadhwana
awadhwana / main.go
Last active April 19, 2024 07:31
Golang: aes-256-cbc ecrypt/decrypt examples (with iv, blockSize)
package main
// Working example: https://goplay.space/#Sa7qCLm6w65
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"encoding/hex"
"fmt"
@awadhwana
awadhwana / init.sh
Last active May 15, 2022 08:29
A script to start the docker containers from the compose yml.
#!/bin/sh
set -e
## usage
# docker-init up -> start the containers
# docker-init -> stops the containers
# https://24ankitw.medium.com/managing-docker-containers-3d0bcc54405
command_exists() {
@awadhwana
awadhwana / docker-compose.yml
Created August 29, 2021 09:42
docker-compose for Redis with persisting storage.
version: '3'
services:
redis:
image: redis:5.0.7-alpine
container_name: 'redis'
ports:
- 6379:6379
volumes:
- data:/data
networks:
@awadhwana
awadhwana / map.go
Last active July 21, 2020 09:58
Solution for Exercises on A Tour of Go
//Exercise: Maps
//Implement WordCount.
//It should return a map of the counts of each “word” in the string s.
//The wc.Test function runs a test suite against the provided function and prints success or failure.
package main
import (
"strings"
@awadhwana
awadhwana / ec2.yml
Last active February 29, 2020 13:07
Creating EC2 instance using Ansible
- name: AWS-Docker-Ansible Setup
hosts: localhost
connection: local
gather_facts: False
vars_files:
- vars/variables.yml
tasks:
- name: Create security group
ec2_group:
@awadhwana
awadhwana / host
Created February 25, 2020 13:30
Ansible script to install docker on EC2 instance
[ec2]
*instance ip address* ansible_user=ubuntu ansible_python_interpreter=/usr/bin/python3