Skip to content

Instantly share code, notes, and snippets.

View filewalkwithme's full-sized avatar
😜

maicon filewalkwithme

😜
View GitHub Profile
TOKEN=token-01
CLUSTER_STATE=new
NAME_1=machine-1
NAME_2=machine-2
NAME_3=machine-3
HOST_1=10.240.0.17
HOST_2=10.240.0.18
HOST_3=10.240.0.19
CLUSTER=${NAME_1}=http://${HOST_1}:2380,${NAME_2}=http://${HOST_2}:2380,${NAME_3}=http://${HOST_3}:2380
@filewalkwithme
filewalkwithme / regex_cve.go
Last active April 19, 2018 04:42
Extract CVE numbers from a target string
package main
import (
"fmt"
"regexp"
)
func main() {
// https://cve.mitre.org/cve/identifiers/tech-guidance.html#extraction_or_parsing
var cveRegex = regexp.MustCompile(`(?i)(CVE-\d{4}-(0\d{3}|[1-9]\d{3,}))`)
@filewalkwithme
filewalkwithme / example.json
Last active March 28, 2018 20:16
Read JSON from a file, update the content and then write it to the same file again
{"hola":"mundo","number":1}
package main
import (
"context"
"log"
"sync"
"time"
)
var wg sync.WaitGroup
package main
import (
"context"
"log"
"sync"
"time"
)
var wg sync.WaitGroup
@filewalkwithme
filewalkwithme / postgres-docker.txt
Last active July 1, 2017 02:39
run a local postgres container
# How to run the container
docker run --rm --name container-name -p 5432:5432 -e POSTGRES_USER=username -e POSTGRES_DB=dbname -e POSTGRES_PASSWORD=password -v /local/path/to/data/:/var/lib/postgresql/data postgres
# How to connect via psql
psql -h 0.0.0.0 -U username -W
@filewalkwithme
filewalkwithme / run_ec2_instance.go
Created April 5, 2015 21:31
Running Amazon EC2 instances with Golang
// from: http://maicon.io/golang-running-aws-ec2-instances.html
package main
import (
"fmt"
"os"
aws "github.com/goamz/goamz/aws"
ec2 "github.com/goamz/goamz/ec2"
)
@filewalkwithme
filewalkwithme / main.go
Last active February 16, 2024 23:22
Listening multiple ports on golang http servers (using http.Handler)
package main
import (
"net/http"
)
func main() {
go func() {
http.ListenAndServe(":8001", &fooHandler{})
}()
@filewalkwithme
filewalkwithme / main.go
Created February 7, 2015 21:50
Listening multiple ports on golang http servers
package main
import (
"net/http"
)
func main() {
finish := make(chan bool)
server8001 := http.NewServeMux()
@filewalkwithme
filewalkwithme / WakeOnLan.java
Last active December 15, 2015 14:59
Java Class for Wake On Lan
/* maiconio
* http://pistach.es/
*/
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetSocketAddress;
import java.net.SocketException;