Skip to content

Instantly share code, notes, and snippets.

View xeoncross's full-sized avatar

David Pennington xeoncross

View GitHub Profile
@xeoncross
xeoncross / config.js
Created August 4, 2019 04:03 — forked from mccahill/config.js
Example of a node OAuth (Twitter) and OAuth2 (Google Calendar) client that works with the version 3 Express framework. This assumes you have a config.js file holding the keys and secrets
module.exports = {
'HOSTPATH': 'http://your.host.here',
'PORT': 80,
'EXPRESS_SESSION_SECRET': '123456',
'TWITTER_CONSUMER_KEY': 'your-consumer-key-here',
'TWITTER_CONSUMER_SECRET': 'your-secret-here',
'GOOGLE_APP_ID': 'your-app-id-here',
'GOOGLE_CONSUMER_SECRET': 'your-consumer-secret-here',
};
@xeoncross
xeoncross / dump.go
Created April 17, 2019 18:23 — forked from janhalfar/dump.go
golang reflection games
func dump(v reflect.Value, path string) {
switch v.Type().Kind() {
case reflect.Interface:
if v.Elem().Type().Kind() == reflect.Interface {
fmt.Println(path, ":", "merry xmas an interface")
} else {
dump(v.Elem(), path)
}
case reflect.Int, reflect.Int64, reflect.Float64:
fmt.Println(path, ":", "it is a number", v.String())
package main
import (
"fmt"
"reflect"
)
//function types
type mapf func(interface{}) interface{}
@xeoncross
xeoncross / serve.go
Created April 14, 2019 20:38 — forked from paulmach/serve.go
Simple Static File Server in Go
/*
Serve is a very simple static file server in go
Usage:
-p="8100": port to serve on
-d=".": the directory of static files to host
Navigating to http://localhost:8100 will display the index.html or directory
listing file.
*/
package main
@xeoncross
xeoncross / call_method_with_reflection.go
Created March 27, 2019 21:31 — forked from tkrajina/call_method_with_reflection.go
Golang, call method (and fill arguments) with reflection
package main
import (
"fmt"
"reflect"
)
type Aaa struct {
a string
}
@xeoncross
xeoncross / slice_exists.go
Created March 13, 2019 21:42 — forked from r6m/slice_exists.go
golang check if item exists in slice
package main
import(
"fmt"
"reflect"
)
func main() {
items := []int{1,2,3,4,5,6}
fmt.Println(SliceExists(items, 5)) // returns true
@xeoncross
xeoncross / graceful.go
Created March 13, 2019 14:56 — forked from peterhellberg/graceful.go
*http.Server in Go 1.8 supports graceful shutdown. This is a small example.
package main
import (
"context"
"log"
"net/http"
"os"
"os/signal"
"time"
)
package main
import (
"fmt"
"math/rand"
"sync"
"time"
)
type DataEvent struct {
@xeoncross
xeoncross / list_directory.go
Created February 8, 2019 15:04 — forked from manigandand/list_directory.go
List files in a directory using golang
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
)
@xeoncross
xeoncross / enc.go
Created December 30, 2018 18:16 — forked from hbakhtiyor/enc.go
AES GCM Encryption/Decryption with Chunking Example in Golang, using OpenSSL
package main
import (
"bufio"
"bytes"
"encoding/hex"
"fmt"
"io"
"os"