Skip to content

Instantly share code, notes, and snippets.

@farhany
farhany / step5-main.go
Created April 3, 2018 04:04 — forked from chadlung/step5-main.go
Go: Simple, Easy, Fast - Building a Go (golang) REST Service with Gorilla - Step 5: http://www.giantflyingsaucer.com/blog/?p=5635
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"github.com/gorilla/mux"
)
@farhany
farhany / golang-request
Created April 5, 2018 17:45 — forked from kendellfab/golang-request
Golang Example for adding custom headers to a request.
client := &http.Client{]
req, err := http.NewRequest("POST", "http://example.com", bytes.NewReader(postData))
req.Header.Add("User-Agent", "myClient")
resp, err := client.Do(req)
defer resp.Body.Close()
// Source https://stackoverflow.com/questions/10385551/get-exit-code-go
package utils
import (
"bytes"
"log"
"os/exec"
"syscall"
)
@farhany
farhany / byte_to_str.go
Created April 18, 2018 22:57
Convert []byte to string in Golang
func BytesToString(data []byte) string {
return string(data[:])
}
@farhany
farhany / GitHub curl.sh
Created June 19, 2018 19:50 — forked from Integralist/GitHub curl.sh
Download a single file from a private GitHub repo. You'll need an access token as described in this GitHub Help article: https://help.github.com/articles/creating-an-access-token-for-command-line-use
curl --header 'Authorization: token INSERTACCESSTOKENHERE' \
--header 'Accept: application/vnd.github.v3.raw' \
--remote-name \
--location https://api.github.com/repos/owner/repo/contents/path
# Example...
TOKEN="INSERTACCESSTOKENHERE"
OWNER="BBC-News"
REPO="responsive-news"
@farhany
farhany / Python3 Virtualenv Setup.md
Created July 6, 2018 18:54 — forked from pandafulmanda/Python3 Virtualenv Setup.md
Setting up and using Python3 Virtualenv on Mac

Python3 Virtualenv Setup

Requirements
  • Python 3
  • Pip 3
$ brew install python3
@farhany
farhany / termbin-encrypted-data.md
Created November 25, 2018 03:42 — forked from schmich/termbin-encrypted-data.md
Sharing encrypted data via termbin.com with only netcat and OpenSSL

Single file

Source

  • cat /foo/bar/file.txt | openssl enc -aes-256-cbc -base64 | nc termbin.com 9999
  • Enter password twice (quickly), note termbin.com URL

Destination

  • curl -s http://termbin.com/{id} | openssl enc -aes-256-cbc -base64 -d > file.txt
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: monitoring-influxdb
namespace: kube-system
spec:
replicas: 1
template:
metadata:
labels:
@farhany
farhany / kubespray_ansible_hosts.ini
Last active May 9, 2019 19:12
inventory/mycluster/hosts.ini
# ## Configure 'ip' variable to bind kubernetes services on a
# ## different ip than the default iface
# ## We should set etcd_member_name for etcd cluster. The node that is not a etcd member do not need to set the value, or can set the empty string value.
[all]
ubu1 ansible_host=192.168.4.139 ip=192.168.4.139 etcd_member_name=etcd1
ubu2 ansible_host=192.168.4.133 ip=192.168.4.133 etcd_member_name=etcd2
ubu3 ansible_host=192.168.4.113 ip=192.168.4.113 etcd_member_name=etcd3
# node4 ansible_host=95.54.0.15 # ip=10.3.0.4 etcd_member_name=etcd4
# node5 ansible_host=95.54.0.16 # ip=10.3.0.5 etcd_member_name=etcd5
# node6 ansible_host=95.54.0.17 # ip=10.3.0.6 etcd_member_name=etcd6
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: admin-user