Skip to content

Instantly share code, notes, and snippets.

View arunksaha's full-sized avatar

Arun Saha arunksaha

View GitHub Profile
@arunksaha
arunksaha / vpc_example.go
Created December 18, 2021 01:34
A golang example to work with the AWS VPCs using AWS SDK V2
// A golang example to work with the AWS VPCs using AWS SDK V2.
// By Arun Saha.
//
// This example demonstrates the following CRUD operations:
// - Creating VPC (with a primary CIDR)
// - Reading or getting VPCs
// - Getting all VPCs
// - Getting a specific VPC
// - Reading attributes in the VPC object
// - Update VPC
@arunksaha
arunksaha / vpc_example.py
Last active December 18, 2021 01:36
AWS VPC operations with Python SDK
# A python example to work with the AWS VPCs. This example
# demonstrates the following CRUD operations:
# - Creating VPC
# - Getting or retrieving VPC
# - Reading attributes in the VPC object
# - Update VPC
# - Update Tags
# - Update Secondary CIDRs
# - Deleting VPC
@arunksaha
arunksaha / inheritance_cpp.cpp
Created October 26, 2021 19:57
inheritance-4
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <memory>
using namespace std;
// An abstract (base) class to model a logging interface with two APIs.
class LoggerInterface {
@arunksaha
arunksaha / inheritance_golang.go
Created October 26, 2021 19:56
inheritance-3
package main
import (
"bufio"
"fmt"
"log"
"os"
"reflect"
)
@arunksaha
arunksaha / inheritance_usage.go
Last active October 26, 2021 19:53
inheritance-2
var loggers []LoggerInterface
loggers = append(loggers, &InMemoryLogger{})
loggers = append(loggers, makeLocalLogger(filename))
// We can log the same messages in both loggers in the following way.
var testMessages = []string{
"Hello, World!",
"abracadabra",
"Sayonara!",
}
// LocalLogger saves the log messages in a file.
type LocalLogger struct {
LoggerInterface
filename string
file *os.File
}
func (this *LocalLogger) Log(mesg string) {
fmt.Fprintln(this.file, mesg)
}
func makeLocalLogger(filename string) *LocalLogger {