Skip to content

Instantly share code, notes, and snippets.

View srfrog's full-sized avatar
🇵🇷
Boricua

Señor Gus srfrog

🇵🇷
Boricua
View GitHub Profile

Principles of Adult Behavior

  1. Be patient. No matter what.
  2. Don’t badmouth: Assign responsibility, not blame. Say nothing of another you wouldn’t say to him.
  3. Never assume the motives of others are, to them, less noble than yours are to you.
  4. Expand your sense of the possible.
  5. Don’t trouble yourself with matters you truly cannot change.
  6. Expect no more of anyone than you can deliver yourself.
  7. Tolerate ambiguity.
  8. Laugh at yourself frequently.

Keybase proof

I hereby claim:

  • I am srfrog on github.
  • I am srfrog (https://keybase.io/srfrog) on keybase.
  • I have a public key ASAAGtgPqOgSsY0PvVuAdUpec1AKieAS18W13ozkGA9bBAo

To claim this, I am signing this object:

@srfrog
srfrog / README.md
Created August 4, 2016 08:26 — forked from leonardofed/README.md
A curated list of AWS resources to prepare for the AWS Certifications


A curated list of AWS resources to prepare for the AWS Certifications

A curated list of awesome AWS resources you need to prepare for the all 5 AWS Certifications. This gist will include: open source repos, blogs & blogposts, ebooks, PDF, whitepapers, video courses, free lecture, slides, sample test and many other resources.


Index:

@srfrog
srfrog / asymmetric.go
Created April 4, 2016 04:09 — forked from cryptix/LICENSE
example of using JWT for http authentication in go
package main
// using asymmetric crypto/RSA keys
import (
"crypto/rsa"
"fmt"
"io/ioutil"
"log"
"net/http"
func (e *EncoderJSON) Decode(reader io.Reader, v interface{}) error {
// suggested by dsal@IRC
r := &io.LimitedReader{reader, e.MaxBodySize}
err := json.NewDecoder().Decode(v)
if err != nil && r.N == 0 {
return ErrBodyTooLarge
}
return err
}
func (e *EncoderJSON) Decode(reader io.Reader, v interface{}) error {
r := io.LimitReader(reader, e.MaxBodySize+1)
b, err := ioutil.ReadAll(r)
if err != nil {
return err
}
if int64(len(b)) > e.MaxBodySize {
return ErrBodyTooLarge
}
return json.Unmarshal(b, v)
@srfrog
srfrog / gist:e3ecf0fe10d5a7a11997
Created August 1, 2014 22:49
StringSlice is used to scan Postgresql's arrays into Go's string arrays
// StringSlice is used to scan Postgresql's arrays into Go's string arrays
type StringSlice []string
func (s *StringSlice) Scan(src interface{}) error {
b, ok := src.([]byte)
if !ok {
return error(errors.New("Scan src was not []bytes"))
}
// removes all quotes and nesting
// XXX: this assumes "{} are not part of the values
@srfrog
srfrog / gist:dd47071d401810a37e5d
Created July 30, 2014 08:19
find if a method is defined within an struct saved as interface{}
v := reflect.ValueOf(self.collection)
if m := v.MethodByName("Create"); m.IsValid() {
handler := m.Interface().(func(ResponseWriter, *Request))
self.Route("POST", "", handler)
}