Skip to content

Instantly share code, notes, and snippets.

View filewalkwithme's full-sized avatar
😜

maicon filewalkwithme

😜
View GitHub Profile
@filewalkwithme
filewalkwithme / sample_wol.lua
Created June 4, 2012 00:01
Lua Wake-On-Lan Script
function split(str, pat)
local t = {}
local fpat = "(.-)" .. pat
local last_end = 1
local s, e, cap = str:find(fpat, 1)
while s do
if s ~= 1 or cap ~= "" then
table.insert(t,cap)
end
last_end = e+1
@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;
@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 / 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 / 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 / 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
package main
import (
"context"
"log"
"sync"
"time"
)
var wg sync.WaitGroup
package main
import (
"context"
"log"
"sync"
"time"
)
var wg sync.WaitGroup
@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}
@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,}))`)