Skip to content

Instantly share code, notes, and snippets.

@chespinoza
chespinoza / playing.go
Created September 2, 2013 04:57
Playing with Go data structures...
package main
import (
"fmt"
"math/rand"
"time"
)
type Cc struct {
name string
@chespinoza
chespinoza / avbyhour.go
Created September 2, 2013 13:48
Approach to get Average values by hour in a slice of structs with Golang
package main
import (
"fmt"
"math/rand"
"time"
)
type Acc struct {
name string
package main
import (
"fmt"
"log"
"math/rand"
"time"
)
type Snapshot struct {
@chespinoza
chespinoza / jetty.txt
Created September 11, 2013 04:25
Jetty Test
cespinoza@xanadu ~ $ ab -n 100000 -c 1000 -t 1 -k -g out.dat http://127.0.0.1:3000/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Finished 3907 requests
Server Software: Jetty(7.6.1.v20120215)
@chespinoza
chespinoza / revel.txt
Created September 11, 2013 04:26
Revel test
cespinoza@xanadu ~ $ ab -n 100000 -c 1000 -t 1 -k -g out.dat http://127.0.0.1:9000/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Finished 1034 requests
Server Software:
@chespinoza
chespinoza / web2py.txt
Created September 11, 2013 04:28
Apache-Web2py
cespinoza@xanadu ~ $ ab -n 100000 -c 1000 -t 1 -k -g out.dat http://127.0.0.1/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Finished 166 requests
Server Software: Apache/2.2.22
// Given a query string "?to=email&why=because&first=John&Last=smith"
// getUrlVar("to") will return "email"
// getUrlVar("last") will return "smith"
// Slightly more concise and improved version based on http://www.jquery4u.com/snippets/url-parameters-jquery/
function getUrlVar(key){
var result = new RegExp(key + "=([^&]*)", "i").exec(window.location.search);
return result && unescape(result[1]) || "";
}
(defn make-greetings
[hello]
{:pre [(string? hello) (< (count hello) 10)] ; pre-validation guards
:post [(string? %)]} ; result validation
(fn [name]
(str hello " " name "!")))
@chespinoza
chespinoza / firstclassfunctions.go
Created August 5, 2014 15:25
Uhmm Go have first class functions
// Playing with functions
// This is really useful
package main
import "fmt"
func greet() {
fmt.Println("Hello!")
}
func farewell() {
@chespinoza
chespinoza / main.go
Created February 17, 2016 15:49
Marshaling in go
package main
import (
"encoding/json"
"fmt"
"log"
"time"
)
type User struct {