Skip to content

Instantly share code, notes, and snippets.

View nanoninja's full-sized avatar

Vincent Letourneau nanoninja

View GitHub Profile
@nanoninja
nanoninja / ctx_handler.go
Created December 13, 2015 16:24
Go Context Handler
package main
import (
"fmt"
"golang.org/x/net/context"
"log"
"net/http"
"os"
)
@nanoninja
nanoninja / channel.go
Last active January 28, 2016 14:11
Channel Example
package main
import "fmt"
func main() {
ch := make(chan string)
go func(c chan string) {
ch <- "Hello Gopher"
}(ch)
@nanoninja
nanoninja / xml2json.php
Created February 12, 2016 07:56
PHP Encode / Decode data structures
<?php
$dom = simplexml_load_string(
'<root>
<langage>PHP</langage>
<version>7</version>
<parent>
<version>5</version>
</parent>
</root>'
@nanoninja
nanoninja / main.go
Last active July 10, 2016 09:55
Go Middleware
// Copyright 2016 Vincent Letourneau.
package main
import (
"fmt"
"net/http"
)
func AuthMiddleware(next http.Handler) http.Handler {
// Copyright 2016 The Nanoninja Authors. All rights reserved.
package main
import (
"io"
"log"
"os"
)
@nanoninja
nanoninja / service.go
Created June 16, 2016 07:37
Service Container
package service
import (
"fmt"
"sync"
)
type key int
type Service func() interface{}
@nanoninja
nanoninja / flusher.go
Created September 3, 2016 13:07
Go HTTP Flusher Example
// http.Flusher example
package main
import (
"fmt"
"net/http"
"time"
)
@nanoninja
nanoninja / jose_jwt_go_usage.md
Created September 29, 2016 14:35
JOSE - JWT Usage Examples

JOSE - JWT Usage Examples

JOSE is a comprehensive set of JWT, JWS, and JWE libraries.

jwt.io

Installation

go get github.com/SermoDigital/jose
@nanoninja
nanoninja / time_display.go
Last active July 22, 2017 14:48
Go Time Display Using Ticker
package main
import (
"fmt"
"time"
)
func main() {
TimeDisplay(true)
}
@nanoninja
nanoninja / gobot_chat.go
Last active October 21, 2016 22:32
Simple GoBot Chat
// Simple Chat Server. It does not broadcast to other people.
// It can be used to create a bot.
package main
import (
"bufio"
"fmt"
"io"
"log"
"net"