Skip to content

Instantly share code, notes, and snippets.

View arehmandev's full-sized avatar
🎯
Focusing

Abdul Rehman arehmandev

🎯
Focusing
  • Freelance
  • London, UK
View GitHub Profile
@arehmandev
arehmandev / 1-redditexample.go
Last active October 10, 2017 14:37
Hi buddy - gave it a go
package main
import (
"encoding/json"
"fmt"
"log"
"time"
)
// Fulldata - test
@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")
@arehmandev
arehmandev / 01-Before.json
Last active October 5, 2017 09:47
Best way of doing this?
{
"containers": [{
"path": "pathA",
"components": [{
"image": "Image1",
"name": "Name1"
}]
},
{
"path": "pathB",
@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 / struct.go
Last active October 3, 2017 09:44
Example of instantiating a nested struct and Marshalling it to JSON
package main
import (
"encoding/json"
"fmt"
"log"
)
// Deployment -
type Deployment struct {
@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 / changed.yaml
Created September 20, 2017 18:36
Changing value in yaml file in go
Charts:
name: foo
repo: foo.com
tags: realtag
@arehmandev
arehmandev / curlkube.sh
Last active September 19, 2017 14:27
Curl kubernetes apiserver (run kubectl get with curl)
#!/bin/bash
APIKEYFILE=~/.minikube/apiserver.key
APICERTFILE=~/.minikube/apiserver.crt
CAFILE=~/.minikube/ca.crt
curl https://192.168.99.100:8443/api/v1/namespaces \
--key $APIKEYFILE \
--cert $APICERTFILE \
--cacert $CAFILE
@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"
)
package main
import (
"fmt"
"gopkg.in/yaml.v2"
)
type T struct {
Charts []struct {