Skip to content

Instantly share code, notes, and snippets.

@rickt
rickt / query-arma3-server.go
Last active August 29, 2015 14:10
example Go code to pull stats from an Arma 3 server via the RCON protocol
package main
import (
"flag"
"fmt"
steam "github.com/kidoman/go-steam"
"sort"
)
var addresses = []string{
@rickt
rickt / smtp-send.go
Last active December 30, 2015 10:39
HOW-TO: send email via SMTP with Go.
package main
import (
"crypto/tls"
"fmt"
"log"
"net"
"net/mail"
"net/smtp"
)
@rickt
rickt / blowfish.go
Last active December 30, 2015 10:59
example code to blowfish encrypt/decrypt, using Go.
package main
import (
"crypto/cipher"
"fmt"
"go.crypto/blowfish"
)
func blowfishChecksizeAndPad(pt []byte) []byte {
// calculate modulus of plaintext to blowfish's cipher block size
@rickt
rickt / japan-timebot-simple.go
Last active March 4, 2016 07:17
simple appengine go app that prints out the current time in Japan, Los Angeles & London/UTC
// http://japan-timebot-simple.appspot.com
package japantime
import (
"fmt"
"net/http"
"time"
)
@rickt
rickt / slackminisniffer.go
Created March 5, 2016 00:32
slack mini "sniffer", connects to slack and outputs the messages received over the slack websocket
package main
import (
"fmt"
"github.com/nlopes/slack"
)
func main() {
// create new slack object & connect
api := slack.New("TOKEN_REDACTED")
api.SetDebug(true)
rtm := api.NewRTM()
@rickt
rickt / analytics-dumper.go
Last active April 8, 2016 02:48
example Go code showing how to download reporting data from Google Analytics using the Core Reporting API (updated 2015)
//
// EDIT: this code is now old
// i have recently (april 2016) updated it to use the new golang.org/x/oauth2 lib
// you can get the new analytics dumper at the below url:
// https://gist.github.com/rickt/d839564155cac15d59b6027668d8cb64
//
package main
import (
@rickt
rickt / slackaccessloglooker.go
Created August 5, 2016 04:15
call the slack team.accessLogs API to output which of your Slack users are not using a desktop or mobile Slack app
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"strings"
"time"
)
@rickt
rickt / slackweatherbot.go
Created August 20, 2018 17:31
A weatherbot for Slack written in go
package slackweatherbot
import (
owm "github.com/briandowns/openweathermap"
"golang.org/x/net/context"
"google.golang.org/appengine"
"google.golang.org/appengine/log"
"google.golang.org/appengine/urlfetch"
"net/http"
"os"
package main
// https://rickt.org/2019/01/08/playing-with-g-suite-mdm-mobile-device-data-using-go/
import (
"context"
"errors"
"flag"
"fmt"
"github.com/dustin/go-humanize"
#
# Example fluentd config file for nginx access log injection into Google Bigquery
# collecting nginx access log
<source>
@type tail
tag accesslogs-rickts-dev-box
path /var/log/nginx/access.log
format apache
buffer_type file