Skip to content

Instantly share code, notes, and snippets.

Avatar
:bowtie:
workin' on some stuff

Francesc Campoy campoy

:bowtie:
workin' on some stuff
View GitHub Profile
@campoy
campoy / parallel.go
Last active Aug 29, 2015
Mandelbrot snippets from github.com/campoy/mandelbrot, for a post on blog.campoy.cat
View parallel.go
func fillImg(m *img) {
// init a WaitGroup with the number of pixels of the image
var wg sync.WaitGroup
wg.Add(m.h * m.w)
for i, row := range m.m {
for j := range row {
// Every pixel is computed in a different goroutine
// and the counter is decreased once it's done.
go func(i, j int) {
View main.go
package main
import "github.com/campoy/cooltool/server"
func main() {
server.Run()
}
@campoy
campoy / notfound.html
Last active Aug 29, 2015
A small web server with a customized 404 page showed in two different ways, wrapping the ResponseWriter or wrapping the Handler
View notfound.html
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>404 - not found</title>
<style>
* {
padding: 0;
margin: 0;
View file.go
package main
import "fmt"
func main() {
fmt.Println("this is a test for Medium")
}
@campoy
campoy / main.go
Last active Dec 16, 2015
Small sample app on using goauth2
View main.go
// Short example showing how to get an oauth2 token using a .pem key and how the token should be added
// to the http requests.
package main
import (
"fmt"
"io/ioutil"
"net/http"
"code.google.com/p/goauth2/oauth/jwt"
@campoy
campoy / wat.js
Created Sep 13, 2013
What do you think this will log?
View wat.js
var foo = 1;
func bar() {
if (!foo) {
var foo = 10;
}
console.log(foo);
}
bar();
@campoy
campoy / commands.go
Last active Dec 28, 2015
Running concurrently a list of commands
View commands.go
package main
type Command interface {
Run() error
}
func RunAll(cmds []Command) error {
for _, cmd := range cmds {
err := cmd.Run()
if err != nil {
@campoy
campoy / after.go
Created Dec 6, 2013
Goimports example
View after.go
package main
import (
"fmt"
"math"
"code.google.com/p/go.tools/present"
)
var doc present.Doc
@campoy
campoy / gotourtodo.md
Last active Jan 2, 2016
TODO list for the new go tour
View gotourtodo.md

TODO

Features:

  • Page navigation with Right/left instead of Page Up/down (@mattetti)
  • Allow navigation from the editor (egon)
  • Responsive design
  • Keep the sliders on place after changing page/module (cookies?)

Bugs:

@campoy
campoy / app.go
Created Nov 18, 2016
Go Echo Server on Flex with Endpoints
View app.go
// Copyright 2016 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// Sample endpoints demonstrates a Cloud Endpoints API.
package main
import (
"encoding/json"
"fmt"