Skip to content

Instantly share code, notes, and snippets.

Avatar

Jesse Dearing jessedearing

View GitHub Profile
View README.md

This is a call to the RDS API to create new instances of MySQL. One of the things I've found really helpful is that as a staticly typed language, Go gives me reliable parameter autocomplete (via https://github.com/nsf/gocode) so I can pretty easily look up parameters to the *Input and *Output structs in all editors that have the integration In my case vim-go.

Amazon's Go API has a few quriks (like the pointers for everything needing the aws.String and aws.Bool convenience functions), but once you get into it flows easily.

Since the AWS functions are all in interfaces, I can mock github.com/aws/aws-sdk-go/service/rds/rdsiface using https://github.com/maxbrunsfeld/counterfeiter and write expectations in my unit tests.

@jessedearing
jessedearing / profile.go
Created Jan 5, 2017
Have go dump a stack trace on USR1
View profile.go
package main
import (
"os"
"os/signal"
"runtime/pprof"
"syscall"
)
func main() {
View analyze.go
package main
import (
"database/sql"
"fmt"
"log"
"os"
"path/filepath"
"regexp"
"sync"
View file_block.rb
File.open(‘hello.txt’, ‘r’) do |f|
while line = f.gets
puts line
end
end
View FileTryResource.java
try(FileInputStream input = new FileInputStream(“file.txt”)) {
int data = input.read();
while(data != -1) {
System.out.print((char) data);
data = input.read();
}
}
View typical_defer.go
connection, err := net.Dial("tcp", "example.com:80")
if err != nil {
// Do something to handle the error
return
}
defer connection.Close()
View ssh_and_find_process.go
sshClient, err := setUpSSHClient(host)
if err != nil {
log.Panic(err)
}
defer sshClient.Close()
lsofOut, err := runCmd(sshClient, "sudo lsof -i tcp:"+port+" | tail -1 | awk '{ print $2; }'")
lsofOut = strings.Trim(lsofOut, "\n\r ")
if err != nil {
log.Panic(err)
View capture_host_port.go
db, err := sql.Open("mysql", user+":"+password+"@tcp("+host+":3306)/information_schema")
if err != nil {
log.Fatal(err)
}
defer db.Close()
hostWithPort := getHost(db)
if hostWithPort == nil {
log.Println("Could not find query with that ID")
return
View keybase.md

Keybase proof

I hereby claim:

  • I am jessedearing on github.
  • I am jessed (https://keybase.io/jessed) on keybase.
  • I have a public key ASDHcM5dilzf0pRTuwAcQfzaPVtA7X4eT_hnyRk8ztRYcgo

To claim this, I am signing this object:

View rep.go
package main
import (
"fmt"
"log"
_ "github.com/go-sql-driver/mysql"
"github.com/jmoiron/sqlx"
)