Skip to content

Instantly share code, notes, and snippets.

View riak_wrapper.rb
class RiakWrapper
def initialize
walk_server = WalkServer.first
@client = Riak::Client.new(:protocol => "pbc", :host => walk_server.host, :pb_port => walk_server.pb_port)
end
def exists?(key, bucket_name)
bucket(bucket_name).exists?(key)
end
View weird.rb
def foo(a=:default, b)
puts "a=#{a}, b=#{b}"
end
foo(:value)
foo(:x, :y)
View server.go
package main
import (
"fmt"
"bufio"
"net"
"io"
)
func main() {
View cut_the_hope.rb
f = IO.binread("avatar.gif")
@parts = []
f.each_char.each_slice(10000).each do |s|
@parts << s.join
end
@text = ""
@parts.each { |chunk| @text << chunk }
@gerep
gerep / httpbenchmark.go
Last active May 6, 2016 — forked from luisbebop/httpbenchmark.go
http benchmark tool
View httpbenchmark.go
import (
"flag"
"fmt"
"net/http"
)
var (
n = flag.Int("n", 100, "number of GETs to run")
s = flag.Bool("s", false, "whether to use HTTPS")
c = flag.Bool("c", false, "whether to run concurrently")
View gist:67e7a258c3b9d9ca4a5a93f379c76978
package main
import (
"net/http"
"database/sql"
"fmt"
"log"
"os"
)
View server.go
package main
import (
"fmt"
"log"
"net/http"
"html/template"
"github.com/gorilla/sessions"
View postgres_queries_and_commands.sql
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
View cancel_goroutines.go
package main
import (
"context"
"log"
"sync"
"time"
)
var wg sync.WaitGroup
@gerep
gerep / main.go
Created Nov 24, 2017 — forked from hnakamur/main.go
A go example to stop a worker goroutine when Ctrl-C is pressed (MIT License)
View main.go
package main
import (
"fmt"
"os"
"os/signal"
"time"
"golang.org/x/net/context"
)