Skip to content

Instantly share code, notes, and snippets.

rick tait rickt

Block or report user

Report or block rickt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rickt
rickt / tcpgobclient.go
Created Jun 23, 2014
example CLIENT code that connects to a TCP socket & sends GOB-encoded data
View tcpgobclient.go
package main
// use this with tcpgobserver.go
import (
"encoding/gob"
"fmt"
"log"
"net"
)
@rickt
rickt / tcpgobserver.go
Created Jun 23, 2014
example SERVER code that listens on a TCP socket & receives GOB-encoded data
View tcpgobserver.go
package main
// use this with tcpgobclient.go
import (
"encoding/gob"
"fmt"
"net"
)
@rickt
rickt / palindrome.go
Last active Aug 29, 2015
palindrome tester
View palindrome.go
package main
import (
"fmt"
"os"
)
// func main
func main() {
var s string = os.Args[1]
@rickt
rickt / asynchttpget.go
Last active Aug 29, 2015
example of how to do asynchronous http gets
View asynchttpget.go
package main
import (
"fmt"
"net/http"
"time"
)
var urls = []string{
"http://rickt.org",
@rickt
rickt / check-if-jpeg.go
Last active Aug 29, 2015
check if a file really is a JPEG or not
View check-if-jpeg.go
package main
import (
"fmt"
"image"
"image/jpeg"
"os"
)
func checkIsJPEG(filename string) error {
@rickt
rickt / randomstring.go
Created Jun 20, 2014
generate a random string
View randomstring.go
package main
import (
"crypto/rand"
"fmt"
)
func main() {
fmt.Printf("randstring = %s\n", rand_str(5)) // change "5" to be whatever length string you need
@rickt
rickt / url-escaping.go
Created Jun 20, 2014
how to properly escape URLs in go
View url-escaping.go
package main
import (
"fmt"
"net/url"
)
func main() {
var Url *url.URL
@rickt
rickt / analytics-dumper.go
Last active Apr 8, 2016
example Go code showing how to download reporting data from Google Analytics using the Core Reporting API (updated 2015)
View analytics-dumper.go
//
// 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 (
View regexpswitch.go
package main
import "fmt"
import "regexp"
var email = regexp.MustCompile(`^[^@]+@[^@.]+\.[^@.]+$`)
var shortPhone = regexp.MustCompile(`^[0-9][0-9][0-9][.\-]?[0-9][0-9][0-9][0-9]$`)
var longPhone = regexp.MustCompile(`^[(]?[0-9][0-9][0-9][). \-]*[0-9][0-9][0-9][.\-]?[0-9][0-9][0-9][0-9]$`)
func main() {
@rickt
rickt / isascii.go
Last active Aug 29, 2015
check to see if something is ASCII or not
View isascii.go
package main
import "fmt"
func isASCII(s string) bool {
for _, c := range s {
if c > 127 {
return false
}
}
You can’t perform that action at this time.