Skip to content

Instantly share code, notes, and snippets.

@rickt
rickt / palindrome.go
Last active August 29, 2015 14:02
palindrome tester
package main
import (
"fmt"
"os"
)
// func main
func main() {
var s string = os.Args[1]
@rickt
rickt / tcpgobserver.go
Created June 23, 2014 16:54
example SERVER code that listens on a TCP socket & receives GOB-encoded data
package main
// use this with tcpgobclient.go
import (
"encoding/gob"
"fmt"
"net"
)
@rickt
rickt / tcpgobclient.go
Created June 23, 2014 16:55
example CLIENT code that connects to a TCP socket & sends GOB-encoded data
package main
// use this with tcpgobserver.go
import (
"encoding/gob"
"fmt"
"log"
"net"
)
@rickt
rickt / displaytimeindifftz.go
Created July 14, 2014 22:51
example go code to load/print a time in another TZ
package main
import (
"fmt"
"time"
)
const (
datelayout string = "2006-01-02 15:04:05"
)
@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 / 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 / analyticsdumper.go
Last active April 11, 2020 16:19
example Go code showing how to download reporting data from Google Analytics using the Core Reporting API, a Google service account + oauth2 (UPDATE: go here http://code.rickt.org/post/142445693275/updated-golang-code-to-query-ga-data-via-the instead)
package main
import (
"fmt"
"golang.org/x/oauth2"
"golang.org/x/oauth2/jwt"
"google.golang.org/api/analytics/v3"
"io/ioutil"
"log"
"time"
@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"