Skip to content

Instantly share code, notes, and snippets.

View udhos's full-sized avatar
👾
Wondering

udhos

👾
Wondering
  • São Paulo, Brazil
View GitHub Profile
@udhos
udhos / gobetween.service
Created May 17, 2018 17:40
gobetween.service
$ more gobetween.service
[Unit]
Description=Gobetween Load Balancer Service
[Service]
Type=simple
User=root
WorkingDirectory=/home/cliqruser
ExecStart=/home/cliqruser/gobetween -c /home/cliqruser/gobetween.toml
@udhos
udhos / playbook-staticweb.yml
Last active May 17, 2018 21:49
ansible/playbook-staticweb.yml
Usage:
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -e 'host_key_checking=False' -i ansible/hosts ansible/playbook-staticweb.yml --key-file keyfile --extra-vars repo_crede
ntials=user:pwd
more ansible/hosts
---
- hosts: Web
vars:
workspace: "{{ lookup('env','WORKSPACE') }}"
tasks:
@udhos
udhos / golang_tcplistener_setdeadline.go
Created May 25, 2018 20:59
golang_tcplistener_setdeadline
package main
import (
"log"
"net"
"time"
)
func main() {
@udhos
udhos / go-build.sh
Created June 5, 2018 00:50 — forked from sivel/go-build.sh
Ansible Binary Golang Module
go build helloworld.go
GOOS=windows GOARCH=amd64 go build helloworld.go
@udhos
udhos / github-and-go-forking-pull-requests-and.html
Last active October 19, 2018 22:16
github-and-go-forking-pull-requests-and.html
Question: how do you handle pull requests from different GitHub repositories?
Source: github-and-go-forking-pull-requests-and.html
1. Fork the repository github.com/orig/cooltool to github.com/fork/cooltool
2. Get the original repository: go get github.com/orig/cooltool
3. Add a remote to your forked repository: git remote add fork https://github.com/fork/cooltool.git
@udhos
udhos / apigee-load-balancing-spec
Created November 26, 2018 14:06
apigee-load-balancing-spec
swagger: '2.0'
info:
version: "0.0.12"
title: Load Balancing
description: |
Load Balancing API
basePath: /load-balancing
@udhos
udhos / github_token_golang
Created November 28, 2018 15:33
github token + go
1 Generate GITHUB TOKEN here https://github.com/settings/tokens
2 export GITHUB_TOKEN=xxx
3 git config --global url."https://${GITHUB_TOKEN}:x-oauth-basic@github.com/mycompany".insteadOf "https://github.com/mycompany"
4 go get (...)
# forward connections from src=* to remote_host:8001 to localhost:8002
ssh -R \*:8001:localhost:8002 user@remote_host
How can I listen on ports 80 and 443? Do I have to run as root?
On Linux, you can use setcap to grant your binary the permission to bind low ports:
$ sudo setcap cap_net_bind_service=+ep /path/to/your/binary
@udhos
udhos / makecert.sh
Created December 14, 2018 13:31 — forked from jim3ma/makecert.sh
Golang TLS server and client
#!/bin/bash
# call this script with an email address (valid or not).
# like:
# ./makecert.sh joe@random.com
mkdir certs
rm certs/*
echo "make server cert"
openssl req -new -nodes -x509 -out certs/server.pem -keyout certs/server.key -days 3650 -subj "/C=DE/ST=NRW/L=Earth/O=Random Company/OU=IT/CN=www.random.com/emailAddress=$1"
echo "make client cert"
openssl req -new -nodes -x509 -out certs/client.pem -keyout certs/client.key -days 3650 -subj "/C=DE/ST=NRW/L=Earth/O=Random Company/OU=IT/CN=www.random.com/emailAddress=$1"