Skip to content

Instantly share code, notes, and snippets.

package repo
import (
"fmt"
"regexp"
"strings"
)
type Repo struct {
// The path of the Repoisotry. This could be
package repo
import (
"testing"
)
func BenchmarkIsRemote(b *testing.B) {
repos := []Repo{
{Path: "git://github.com/foo/far"},
{Path: "git://github.com/foo/far.git"},
@aodin
aodin / gist:9493340
Created March 11, 2014 19:34
Insert to PostGres
package main
import (
"database/sql"
"log"
_ "github.com/lib/pq"
)
func connect(driver string, credentials string) *sql.DB {
package main
import (
"log"
"sync"
"time"
)
// Global wait group
var jobs sync.WaitGroup
# Description:
# Get the top news item from HN
#
# Commands:
# hubot hn - Return the top item on HN
module.exports = (robot) ->
robot.respond /hn( me)?$/i, (msg) ->
story = hnTopStory(msg)
console.log story
@aodin
aodin / gamma.jl
Created April 26, 2016 17:05
Plotting the Gamma distribution sampling from it as a normalized histogram
# Plotting the Gamma distribution and sample as a normalize histogram
using Distributions
using Gadfly
pdf(d::Gamma, x) = (x ^ (d.α - 1) * e ^ (-x / d.α)) / (d.θ ^ d.α * gamma(d.α))
n = 500
g = Gamma(2., 2.)
@aodin
aodin / fabfile.py
Created July 14, 2016 23:26 — forked from arikfr/fabfile.py
re:dash fabfile
#!/usr/bin/env python
# vim: ts=4:sw=4:expandtab:autoindent:
import os
import sys
import requests
import filecmp
from fabric.context_managers import hide, settings, prefix
from fabric.api import sudo, task, run, cd, env
from fabric.contrib.console import confirm
from fabric.colors import green
@aodin
aodin / sql_results.go
Created December 16, 2016 18:06
Go's SQL Results Must Be Closed
package main
import "database/sql"
import "log"
import _ "github.com/lib/pq"
func main() {
conn, err := sql.Open("postgres", "user=aaronoellis dbname=bar sslmode=disable")
if err != nil {
log.Fatal(err)
@aodin
aodin / sql_benchmark.go
Created December 16, 2016 18:09
SQL Benchmark Test for Go
package main
import (
"database/sql"
"encoding/json"
"log"
"net/http"
"os"
"time"
@aodin
aodin / onion.sql
Created December 16, 2016 18:11
Onion SQL Schema
CREATE TABLE things_versioned (
id integer not null,
name varchar not null,
version timestamp with time zone default now(),
PRIMARY KEY (id, version)
)
CREATE VIEW things AS
SELECT
DISTINCT ON (id)