Instantly share code, notes, and snippets.

View custom_json.go
package main
import (
"bytes"
"encoding/json"
"fmt"
"strconv"
)
func main() {
View go
package myreflect
import (
"fmt"
"reflect"
)
// Invoke - firstResult, err := invoke(AnyStructInterface, MethodName, Params...)
func Invoke(any interface{}, name string, args ...interface{}) (reflect.Value, error) {
method := reflect.ValueOf(any).MethodByName(name)
View reflection1_4.go
type Foo struct {
A int `tag1:"First Tag" tag2:"Second Tag"`
B string
}
func main() {
sl := []int{1, 2, 3}
greeting := "hello"
greetingPtr := &greeting
f := Foo{A: 10, B: "Salutations"}
View translate.go
// Traverses an arbitrary struct and translates all stings it encounters
//
// I haven't seen an example for reflection traversing an arbitrary struct, so
// I want to share this with you. If you encounter any bugs or want to see
// another example please comment.
//
// The MIT License (MIT)
//
// Copyright (c) 2014 Heye Vöcking
//
View main.go
package main
import (
"fmt"
"time"
"golang.org/x/sync/errgroup"
"context"
"os"
"syscall"
"os/signal"
View graceful.go
package main
import (
"context"
"log"
"net/http"
"os"
"os/signal"
"time"
)
View clean-up-boot-partition-ubuntu.md

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r 
View binlog-streamer.sh
#!/bin/bash
mysqlbinlog56=/store/mysql-5.6.23-linux-glibc2.5-x86_64/bin/mysqlbinlog
mysqlclient=/store/mysql-5.6.23-linux-glibc2.5-x86_64/bin/mysql
pidfile=/var/run/binlogstream.pid
binlogdir=/store/binlogstreamer/binlogs
binlogprefix=mysql-bin
mysqluser=tester
mysqlpass=tester
mysqlmaster=10.72.100.236
View compile_mysql.md
  1. Download build-tools
apt-get install build-essential cmake -y
  1. Configure the compiler
cmake \
-DWITH_BOOST=/usr/local/src/mysql-5.7.19/boost/boost_1_59_0 \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql57 \
View mysql_replication_autostart.sh
#!/bin/bash
#title : replication-start.sh
#description : This script automates the process of starting a Mysql Replication on 1 master node and N slave nodes.
#author : Nicolas Di Tullio
#date : 20160706
#version : 0.2
#usage : bash mysql_replication_autostart.sh
#bash_version : 4.3.11(1)-release
#=============================================================================