Skip to content

Instantly share code, notes, and snippets.


Keybase proof

I hereby claim:

  • I am pedromg on github.
  • I am pedromg ( on keybase.
  • I have a public key ASAHu8RbaxCP59ycfkQTB4j1U0k8KcF7A2fmQXciodG-two

To claim this, I am signing this object:

pedromg / fibonacci_closure.go
Created Jun 21, 2017
Fibonacci closure in Golang
View fibonacci_closure.go
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
n_1, n := -1, 1
return func() int {
tmp := n
pedromg / gist:629d8309f4c8c4a39bc9
Last active Aug 29, 2015
Stripe Charge for Google AppEngine
View gist:629d8309f4c8c4a39bc9
package payment
import (
View gist:bd49e4ac4d2f3360e402
package main
import "fmt"
type Person struct {
Name string
age int // not Exported
func main() {
View gist:474a23a06d5e44509e95
import _ "net/http/pprof"
// If the app is not running an http server, one needs to start one:
go func() {
log.Println(http.ListenAndServe("localhost:8000", nil))
// Or else/then its just point the browser to:
// http://ip:port/debug/pprof/</code>
pedromg / gist:8668430
Created Jan 28, 2014
acessing sstore values
View gist:8668430
pedromg / gist:8668335
Last active Jan 4, 2016
load environment values
View gist:8668335
/* load configs. defaults to dev environment. */
func load_environment(e string) bool {
var err error
if e == "" {
e = "dev"
configs, err = sstore.ReadFile("./configs/config_"+e+".sstore")
if err != nil {
return false
pedromg / gist:8668302
Last active Jan 4, 2016
SStore struct
View gist:8668302
type SStore struct {
Name string
Descr string
Data map[string]string
pedromg / gist:7035908
Created Oct 18, 2013
Google API Ruby client, when used for Google BigQuery returns unnamed columns. This new_row_format method solves that, rebuilding the array of hashes with named keys.
View gist:7035908
def query(sql)
sql += ';' unless sql.end_with?(';')
# api call
res = @bq_client.execute(
:api_method =>,
:body_object => { "query" => sql },
:timeoutMs => BQ_TIMEOUT,
:parameters => { "projectId" => BQ_EPF_PROJECT_ID }
# return result
pedromg / gist:3045216
Created Jul 4, 2012
Rob Pike list of simplifications in Go over C++
View gist:3045216
"In the end of course it came out quite different from either C or C++. More different even
than many realize. I made a list of significant simplifications in Go over C and C++:
regular syntax (don't need a symbol table to parse)
garbage collection (only)
no header files
explicit dependencies
no circular dependencies