Skip to content

Instantly share code, notes, and snippets.

View arehmandev's full-sized avatar
🎯
Focusing

Abdul Rehman arehmandev

🎯
Focusing
  • Capgemini
  • London, UK
View GitHub Profile
package main
import "fmt"
func main() {
intslice := [][]int{[]int{1}, []int{2}}
// Grow
for index, value := range intslice {
@arehmandev
arehmandev / main.go
Last active February 25, 2022 08:29
Doing a git clone of a tag in Go - the easy way
package main
import (
"log"
"gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4"
)
@arehmandev
arehmandev / reverse.go
Created September 28, 2017 13:59
Reverse a string (2 different ways) in go
package main
import (
"fmt"
"strings"
)
var (
word = "test"
reversedstringarray []string
@arehmandev
arehmandev / main.go
Created October 3, 2017 15:00
Remove duplicates in a slice
func removeDuplicates(elements []string) []string { // change string to int here if required
// Use map to record duplicates as we find them.
encountered := map[string]bool{} // change string to int here if required
result := []string{} // change string to int here if required
for v := range elements {
if encountered[elements[v]] == true {
// Do not add duplicate.
} else {
// Record this element as an encountered element.
@arehmandev
arehmandev / consul.groovy
Last active February 25, 2022 08:28
Store keyvalue pair in Consul using groovy (java Ecwid/consul-api)
@Grab( 'com.ecwid.consul:consul-api:1.2.4' )
import com.ecwid.consul.v1.*
client = new ConsulClient("172.20.20.10:8500")
setvalue("Abskey", "Absvalue")
println getvalue("Abskey")
variable "subnets" {
type = list(any)
default = ["subnet-a", "subnet-b", "subnet-c"]
}
variable "instances" {
default = {
TEST1 = {
sg = ["example1"]
@arehmandev
arehmandev / main.tf
Created August 11, 2021 01:10
example of tf map manipulation
locals {
virtual_machines = {
"test-services1" = {
vm_instance_group = "instance-group-services"
},
"test-services2" = {
vm_instance_group = "instance-group-services"
},
"test-cpu" = {
@arehmandev
arehmandev / Dockerfile
Created July 1, 2019 21:16
Quick docker in docker
FROM debian:stretch-slim
RUN apt-get update -y && apt install -y curl && \
curl -LO https://download.docker.com/linux/debian/dists/stretch/pool/stable/amd64/containerd.io_1.2.6-3_amd64.deb && apt install -f -y ./containerd.io_1.2.6-3_amd64.deb && \
curl -LO https://download.docker.com/linux/debian/dists/stretch/pool/stable/amd64/docker-ce-cli_18.09.7~3-0~debian-stretch_amd64.deb && apt install -f -y ./docker-ce-cli_18.09.7~3-0~debian-stretch_amd64.deb && \
curl -LO https://download.docker.com/linux/debian/dists/stretch/pool/stable/amd64/docker-ce_18.09.7~3-0~debian-stretch_amd64.deb && apt install -f -y ./docker-ce_18.09.7~3-0~debian-stretch_amd64.deb && \
rm -rf *.deb
@arehmandev
arehmandev / manage-openvpn-nopass.sh
Last active September 5, 2019 11:23
No pass when using -a
#!/bin/bash
#
# Copyright (c) 2013 Nyr. Released under the MIT License.
# Copyright (c) 2019 Fabrice Triboix
set -eu
###################
# Parse arguments #
@arehmandev
arehmandev / .zshrc
Last active August 19, 2019 14:26
terraform aliases
function tfinit () {
if [ -z "${1}" ]; then
terraform init
else
terraform init -backend-config=${1}
fi
}
function tfplan () {
if [ -z "${1}" ]; then