Skip to content

Instantly share code, notes, and snippets.

View artyom's full-sized avatar

Artyom Pervukhin artyom

View GitHub Profile
@artyom
artyom / chat.go
Created March 12, 2016 22:06
Example of interactive terminal in Go
package main
import (
"fmt"
"io"
"log"
"os"
"golang.org/x/crypto/ssh/terminal"
)
@artyom
artyom / osx-ramdisk.sh
Last active March 14, 2016 17:20
Create ramdisk on OS X (run as root), eject disk in GUI to remove
#!/bin/sh -eu
NUMSECTORS=$(($1*1024*1024/512))
MYDEV=$(hdiutil attach -nomount ram://$NUMSECTORS)
diskutil eraseVolume HFS+ "ramdisk-${1}mb" $MYDEV

Convert .cer certificate exported from Keychain.app to PEM format:

openssl x509 -inform der -outform pem -in moonist-ca.cer -out moonist-ca.pem

Convert .p12 bundle (certificate + key) exported from Keychain.app to PEM format:

openssl pkcs12 -in grafana.p12 -out grafana.pem -nodes

Then split resulting pem file into two separate files (certificate and key) using text editor.

package main
import (
"archive/zip"
"flag"
"log"
"net/http"
"golang.org/x/tools/godoc/vfs/httpfs"
"golang.org/x/tools/godoc/vfs/zipfs"
@artyom
artyom / .gitconfig
Last active November 26, 2015 13:37
Use https://bitbucket.org/ private repo urls with git in non-interactive way
[core "https://bitbucket.org"]
askPass = /path/to/bitbucket-auth.sh
@artyom
artyom / gist:e74aff739e22f5e67a7c
Created October 13, 2015 10:00
Slideshare blocks digitalocean's networks replying with javascript causing infinite loop (url requested is http://t.co/qDDamgwHqg)
HTTP/1.1 301 Moved Permanently
cache-control: private,max-age=300
content-length: 0
date: Tue, 13 Oct 2015 09:59:14 GMT
expires: Tue, 13 Oct 2015 10:04:14 GMT
location: http://bit.ly/1hAFSku
server: tsa_b
set-cookie: muc=dd7ffcf9-e1d8-4a0c-bcc3-01dbf7957cd5; Expires=Sun, 24 Sep 2017 09:59:14 GMT; Domain=t.co
x-connection-hash: df197fe166368d00bd02df1f5bf32980
x-response-time: 13
@artyom
artyom / boltdb-issue-324.go
Created August 13, 2015 14:35
Illustration of inconsistency of Put semantics: https://github.com/boltdb/bolt/issues/324
package main
import (
"encoding/binary"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
# Server
redis_version:2.8.19
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:7d72a0444cafea73
redis_mode:standalone
os:Linux 3.16.0-0.bpo.4-amd64 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.7.2
@artyom
artyom / mangos-test-fail.txt
Created January 13, 2015 10:01
go test github.com/gdamore/mangos/test run 10 times in a row, go version go1.4 linux/amd64. On last run process stuck and I killed it with ABRT to get trace.
--- FAIL: TestBusTCP (0.38s)
common_test.go:500: Address tcp://127.0.0.1:39093, 5 Cases
common_test.go:149: Jan 12 01:56:23.664: Id 3: Sent all 7 messages
common_test.go:154: Jan 12 01:56:23.666: Id 0: Got dup message #4 from 2
common_test.go:154: Jan 12 01:56:23.666: Id 0: RecvHook failed
common_test.go:149: Jan 12 01:56:23.668: Id 4: Sent all 7 messages
common_test.go:149: Jan 12 01:56:23.668: Id 2: Sent all 7 messages
common_test.go:149: Jan 12 01:56:23.670: Id 1: Sent all 7 messages
common_test.go:149: Jan 12 01:56:23.670: Id 0: Sent all 7 messages
common_test.go:149: Jan 12 01:56:23.670: Id 0: Testing complete