Skip to content

Instantly share code, notes, and snippets.

@junftnt
junftnt / custom_json.go
Created Dec 7, 2018 — forked from mdwhatcott/custom_json.go
Example of implementing MarshalJSON and UnmarshalJSON to serialize and deserialize custom types to JSON in Go. Playground: http://play.golang.org/p/7nk5ZEbVLw
View custom_json.go
package main
import (
"bytes"
"encoding/json"
"fmt"
"strconv"
)
func main() {
@junftnt
junftnt / go
Created Dec 6, 2018 — forked from yaxinr/go
invoke(call) struct method in golang
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"}
@junftnt
junftnt / translate.go
Created Dec 5, 2018 — forked from hvoecking/translate.go
Golang reflection: traversing arbitrary structures
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
//
@junftnt
junftnt / main.go
Created Nov 26, 2018 — forked from pteich/main.go
Example for using go's sync.errgroup together with signal detection signal.Notify to stop all running goroutines
View main.go
package main
import (
"fmt"
"time"
"golang.org/x/sync/errgroup"
"context"
"os"
"syscall"
"os/signal"
@junftnt
junftnt / graceful.go
Created Nov 8, 2018 — forked from peterhellberg/graceful.go
*http.Server in Go 1.8 supports graceful shutdown. This is a small example.
View graceful.go
package main
import (
"context"
"log"
"net/http"
"os"
"os/signal"
"time"
)
@junftnt
junftnt / clean-up-boot-partition-ubuntu.md
Created Sep 21, 2018 — forked from ipbastola/clean-up-boot-partition-ubuntu.md
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64
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
@junftnt
junftnt / compile_mysql.md
Created Sep 14, 2018 — forked from jaircuevajunior/compile_mysql.md
Compile MySQL 5.7 from source
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 \
@junftnt
junftnt / mysql_replication_autostart.sh
Created Sep 7, 2018 — forked from thomasvs/mysql_replication_autostart.sh
This script automates the process of starting a Mysql Replication on 1 master node and N slave nodes. More details on how it works at http://blog.ditullio.fr/2016/04/30/initialize-mysql-master-slave-replication-script/
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
#=============================================================================
You can’t perform that action at this time.