Skip to content

Instantly share code, notes, and snippets.

@ericchiang
ericchiang / vagrant-scp
Last active August 29, 2015 14:09 — forked from geedew/vagrant-scp
#!/bin/sh
# Change these settings to match what you are wanting to do
FILE=/File/To/Copy
SERVER=localhost
PATH=/Where/To/Put/File
OPTIONS=`vagrant ssh-config | awk -v ORS=' ' '{print "-o " $1 "=" $2}'`
scp ${OPTIONS} $FILE vagrant@$SERVER:$PATH
@ericchiang
ericchiang / vagrant-scp
Last active August 29, 2015 14:10 — forked from geedew/vagrant-scp
#!/bin/sh
# Change these settings to match what you are wanting to do
FILE=/File/To/Copy
SERVER=localhost
PATH=/Where/To/Put/File
OPTIONS=`vagrant ssh-config | grep -v -e '^$' | awk -v ORS=' ' '{print "-o " $1 "=" $2}'`
scp ${OPTIONS} $FILE vagrant@$SERVER:$PATH
@ericchiang
ericchiang / docker_build.go
Last active August 29, 2015 14:10
Docker remote api example
package main
import (
"archive/tar"
"bytes"
"io"
"log"
"net"
"net/http"
"net/http/httputil"
@ericchiang
ericchiang / https_server.go
Created November 28, 2014 15:09
Golang HTTPS server
package main
import (
"net/http"
"strings"
)
/*
Generate cert.pem and key.pem with:
@ericchiang
ericchiang / http_round_robinner.go
Created November 28, 2014 16:01
HTTP Proxy Pass
package main
import (
"log"
"net/http"
"net/http/httputil"
"net/url"
"sync"
)
@ericchiang
ericchiang / Dockerfile
Created December 4, 2014 19:46
Docker in a container
sudo docker run -d \
--name graphite \
-p 80:8888 \
-p 2003:2003 \
-p 8125:8125/udp \
hopsoft/graphite-statsd
@ericchiang
ericchiang / flock.go
Last active September 19, 2023 20:26
Golang Flock
package main
// #include <sys/file.h>
import "C"
import (
"fmt"
"os"
"os/exec"
)
@ericchiang
ericchiang / uuid.go
Last active August 29, 2015 14:12
uuid
package main
import (
"crypto/rand"
"fmt"
"io"
)
func uuid() (string, error) {
b := make([]byte, 16)
package main
import (
"fmt"
"go/ast"
"go/parser"
"go/token"
"os"
"path/filepath"
"strings"
package main
import (
"encoding/json"
"fmt"
"log"
)
var data = `
{"menu": {