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
# 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"
@udhos
udhos / BOOGERS.BAS
Created January 20, 2019 16:10 — forked from andy5995/BOOGERS.BAS
source code for BOOGERS by Mitch Teich 1982
1 REM NOTHING
2 REM
3 REM
5 REM DATNOIDS Copyright (c) 1982 By Casey Roche
8 REM
9 SCREEN 0,0,0
10 KEY OFF:WIDTH 80:COLOR 0,1,0:CLS:PLAY"mb":COLOR 4,0:LOCATE 24,1:PRINT" "+STRING$(78,219):SOUND 1000,1:PRINT" 000000 0000 00000000 00 00 000000 00000000 000000 00000":SOUND 2000,1
80 PRINT" 0222220 022220 02222220 02 20 02222220 02222220 0222220 0222220":SOUND 1000,1:PRINT" 02 20 02 20 22 020 20 02 20 22 02 20 0220 ":SOUND 2000,1
120 PRINT" 02 20 02 20 22 0220 20 02 20 22 02 20 0220 ":SOUND 1000,1:PRINT" 02 20 02222220 22 0202020 02 20 22 02 20 0220 ":SOUND 2000,1
160 PRINT" 02 20 02 20 22 02 0220 02 20 22 02 20 0220":SOUND 1000,1:PRINT" 02 20 02 20 22 02 020 02 20 22 02 20 0220":SOUND 2000,1
@udhos
udhos / gowebhello_cloudinit
Last active February 12, 2019 14:01
gowebhello_cloudinit
#!/bin/bash
yum -y update
yum install -y git
cd /tmp
rm -rf update-golang
git clone https://github.com/udhos/update-golang
cd update-golang
./update-golang.sh
@udhos
udhos / ec2 userdata cloud-boothook
Last active February 20, 2019 15:37
ec2_userdata_cloud-boothook
https://docs.aws.amazon.com/pt_br/AWSEC2/latest/UserGuide/amazon-linux-ami-basics.html
Script de dados do usuário: Começa com #! ou Content-Type: text/x-shellscript.
Ou seja, basta:
#!/bin/bash
systemctl stop spotbq
systemctl disable spotbq
git config --global user.name udhos
git config --global user.email udhos
git config --global credential.helper 'cache --timeout=3600'
@udhos
udhos / golang anonymous struct
Created March 1, 2019 14:55
golang anonymous struct
// https://play.golang.org/p/mJYbMCxYbbK
package main
import (
"fmt"
)
func main() {
@udhos
udhos / bool2int.go
Created March 7, 2019 05:07
bool2int golang unsafe trick
// https://stackoverflow.com/a/51097467/1011695
package main
import (
"fmt"
"unsafe"
)
func main() {
@udhos
udhos / golang_list_available_module_versions
Created March 20, 2019 20:17
golang_list_available_module_versions
$ go list -m -versions rsc.io/sampler
rsc.io/sampler v1.0.0 v1.2.0 v1.2.1 v1.3.0 v1.3.1 v1.99.99
$
https://blog.golang.org/using-go-modules