Skip to content

Instantly share code, notes, and snippets.

View artyom's full-sized avatar
🌴
On vacation

Artyom Pervukhin artyom

🌴
On vacation
View GitHub Profile
@artyom
artyom / drivesize.go
Created March 2, 2014 13:31
Get drive size in Go @ linux
package main
import (
"fmt"
"log"
"os"
"syscall"
"unsafe"
)
@artyom
artyom / sshd.go
Created March 24, 2014 15:12 — forked from nictuku/sshd.go
package main
import (
"fmt"
"io"
"io/ioutil"
"log"
"code.google.com/p/go.crypto/ssh"
"code.google.com/p/go.crypto/ssh/terminal"
package nettimeout
import (
"net"
"time"
)
// Listener wraps a net.Listener, and gives a place to store the timeout
// parameters. On Accept, it will wrap the net.Conn with our own Conn for us.
type Listener struct {
@artyom
artyom / bug_test.go
Last active August 29, 2015 14:00
chef-golang http request parameters bug illustration (https://github.com/marpaia/chef-golang/issues/13)
package bug
import (
"fmt"
"log"
"net/http"
"net/http/httptest"
"net/url"
)
@artyom
artyom / t.go
Created May 16, 2014 05:39
Go flag supports both 'long' and 'short' options
package main
import (
"flag"
"fmt"
)
func main() {
n := 42
flag.IntVar(&n, "num", n, "your number ('long' option)")
@artyom
artyom / gist:927134f52032d79162b5
Created May 21, 2014 15:47
runit, runsv: detach old service, run new one
# find /etc/sv/foo -type f -executable -print0 | xargs -r0 awk 'FNR==1{print "\n$ cat ", FILENAME}{print}'
$ cat /etc/sv/foo/log/run
#!/bin/sh -eu
exec 2>&1
LOGDIR=/tmp/foo-log
test -d $LOGDIR || mkdir -p $LOGDIR
exec svlogd $LOGDIR
$ cat /etc/sv/foo/run
package main
import (
"database/sql"
"errors"
"fmt"
_ "github.com/bmizerany/pq"
"os"
"regexp"
"strings"
@artyom
artyom / pg-json-select.go
Created August 7, 2014 09:03
Unmarshal Postgresql's json type in Go
package main
import (
"database/sql"
"encoding/json"
"fmt"
"log"
_ "github.com/lib/pq"
)
@artyom
artyom / conf.go
Created October 27, 2014 18:54
Apply options from configuration file given by command line flag, then override it with another command line flags.
package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"github.com/artyom/autoflags"
@artyom
artyom / skype-analyze.go
Created November 9, 2014 17:14
Program to calculate total month call duration from skype csv detail files
package main
import (
"encoding/csv"
"fmt"
"io"
"log"
"os"
"time"
)