Skip to content

Instantly share code, notes, and snippets.

@gerep
gerep / channel.go
Created February 28, 2016 16:53
On buffered channels, all read operations will not block if the buffer is not empty and the write operation if the buffer is not full
// This code will return a deadlock error.
// Since the channel c is unbuffered, the write operation c<-42 (writing 42 to the channel) will block.
package main
func main() {
c := make(chan int)
c <- 42
val := <-c
println(val)
package main
import (
"fmt"
"io/ioutil"
"sort"
"strings"
)
func main() {
package main
import (
"fmt"
"time"
)
type Ball struct{ hits int }
func main() {
@gerep
gerep / xml.go
Last active March 17, 2016 02:06
package main
import (
"encoding/xml"
"fmt"
)
//<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
type Envelope struct {
XMLName xml.Name `xml:"soap12:Envelope"`
built-in streaming replication
http://repmgr.org/
http://slony.info/ :: http://pgfoundry.org/projects/skytools/
http://bucardo.org/ :: http://www.postgresql.org/docs/current/static/high-availability.html
http://momjian.us/main/writings/pgsql/replication.pdf :: http://wiki.postgresql.org/wiki/Streaming_Replication
http://wiki.postgresql.org/wiki/Binary_Replication_Tutorial :: http://repmgr.org/
http://www.postgresql.org/docs/current/static/warm-standby.html#SYNCHRONOUS-REPLICATION :: https://github.com/omniti-labs/mimeo
https://wiki.postgresql.org/wiki/Replication%2C_Clustering%2C_and_Connection_Pooling#Replication
http://www.slideshare.net/MasaoFujii/builtin-replication-in-postgresql
package main
import (
"code.google.com/p/go-tour/tree"
"fmt"
)
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int) {
package main
import (
"errors"
"html/template"
"io/ioutil"
"log"
"net/http"
"regexp"
)
package main
import "fmt"
// The dumb way to deal with SOAP requests
func userRequest(userId string) string {
template := soapify(userTemplate)
return fmt.Sprintf(template, userId)
}
#! /usr/bin/env bash
#
# search [file(s)]
#
# This script will read the files passed as parameters and those files
# will contain a list of IPs separated by lines and will search for
# each of those IPs in both omg-switch log files
#
# When no argument is passed, it will open the page on the current branch
package main
import "fmt"
func main() {
primes := []int{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97}
p := binarySearch(primes, 59)
fmt.Println("O número 11 esta na posição ", p)
}