Skip to content

Instantly share code, notes, and snippets.

View ma6174's full-sized avatar
🤣
/

ma6174 ma6174

🤣
/
View GitHub Profile
package main
import (
"flag"
"log"
"net/http"
)
type CorsHandler struct {
http.Handler
@ma6174
ma6174 / diff.go
Created August 13, 2021 10:17
diff
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
)
func main() {
package main
import (
"errors"
"log"
"math/rand"
"time"
)
type Hosts struct {
package main
import (
"encoding/binary"
"io"
"log"
"os"
)
func readInt32(rd io.Reader) (int32, error) {
@ma6174
ma6174 / main.go
Last active January 14, 2016 02:26
mgo findAndModify change _id error
package main
import (
"log"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
)
func main() {
package main
import (
"fmt"
"labix.org/v2/mgo/bson"
)
func main() {
fmt.Println(bson.ObjectId("000000000000"))
@ma6174
ma6174 / test.go
Created September 22, 2015 13:58
just a test
package main
@ma6174
ma6174 / container_init.sh
Created September 6, 2015 13:18
docker container init script
#!/bin/bash
export LC_ALL=C
sed -i 's|archive.ubuntu.com|mirrors.ustc.edu.cn|g' /etc/apt/sources.list
apt-get update
apt-get install -y tmux netcat iputils-ping curl dstat lsof mtr tcpdump axel
@ma6174
ma6174 / copy.sh
Created September 5, 2015 14:15
run a command and copy result to clipboard, or copy data from stdin.
#!/bin/bash
if [ $# -gt 0 ]; then
(echo "$ "$@ && exec $@) | tee /dev/fd/2 | pbcopy
else
tee /dev/fd/2 | perl -pe 'chomp if eof' | pbcopy
fi
package main
import (
"flag"
"fmt"
"log"
"strconv"
)
func main() {