Skip to content

Instantly share code, notes, and snippets.

View sayden's full-sized avatar

Mario Castro sayden

View GitHub Profile
@sayden
sayden / helloWebServer.go
Last active September 23, 2015 07:42
A simple hello world web server that accepts one param. Written in Go
//hello.go
package main
import (
"encoding/json"
"fmt"
"net/http"
)
func handler(writer http.ResponseWriter, request *http.Request) {
@sayden
sayden / ObserverDesignPattern.go
Created December 14, 2015 22:45
Observer Pattern in Golang
package main
import "fmt"
//Listener is a
type Listener struct {
ID int
}
//ListenerInterface is an
@sayden
sayden / ca.md
Last active May 7, 2018 11:26
How to create self signed certificates that doesn't warn clients

How to create self signed certificates that doesn't warn clients (by installing the PEM file)

Create the root certificate (done once)

Create the password protected root certificate key and self sign this certificate

openssl genrsa -des3 -out rootCA.key 2048
openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pem
@sayden
sayden / time_after.go
Last active August 17, 2018 21:07
timeAfter
package time_profile
import "time"
func timeAfter() chan struct{} {
ch := make(chan struct{})
go timeAfterGoroutine(ch)
return ch
@sayden
sayden / time_after_test.go
Created August 17, 2018 21:06
time after test
package time_profile
import "testing"
func Benchmark_TimeAfter(b *testing.B) {
ch := timeAfter()
for n := 0; n < b.N; n++ {
ch <- struct{}{}
}
package time_profile
import "time"
func newTimer() chan struct{} {
ch := make(chan struct{})
go func(ch chan struct{}) {
waitduration := 5000 * time.Millisecond
package time_profile
import "testing"
func Benchmark_NewTimer(b *testing.B) {
ch := newTimer()
for n := 0; n < b.N; n++ {
ch <- struct{}{}
}
package main
import (
"github.com/thehivecorporation/log"
"math/rand"
"time"
)
func main() {
ch := make(chan struct{})
package main
import (
"encoding/json"
"github.com/thehivecorporation/log"
"net/http"
"time"
)
type res struct {
package main
import (
"context"
"encoding/json"
"github.com/juju/errors"
"github.com/thehivecorporation/log"
"net/http"
"time"
)