Skip to content

Instantly share code, notes, and snippets.

package main
import (
"context"
"log"
"sync"
"time"
)
var wg sync.WaitGroup
@gerep
gerep / main.go
Created November 24, 2017 23:10 — forked from hnakamur/main.go
A go example to stop a worker goroutine when Ctrl-C is pressed (MIT License)
package main
import (
"fmt"
"os"
"os/signal"
"time"
"golang.org/x/net/context"
)
package main
import (
"context"
"log"
"sync"
"time"
)
var wg sync.WaitGroup
@gerep
gerep / postgres_queries_and_commands.sql
Created November 14, 2017 19:36 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- 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%'
package main
import (
"fmt"
"log"
"net/http"
"html/template"
"github.com/gorilla/sessions"
package main
import (
"net/http"
"database/sql"
"fmt"
"log"
"os"
)
@gerep
gerep / httpbenchmark.go
Last active May 6, 2016 12:36 — forked from luisbebop/httpbenchmark.go
http benchmark tool
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")
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 }
package main
import (
"fmt"
"bufio"
"net"
"io"
)
func main() {
@gerep
gerep / weird.rb
Created November 5, 2013 15:52 — forked from jimweirich/weird.rb
def foo(a=:default, b)
puts "a=#{a}, b=#{b}"
end
foo(:value)
foo(:x, :y)