Skip to content

Instantly share code, notes, and snippets.

View junxie6's full-sized avatar
🐢
Push the limits of what's possible. Today.

Jun Hsieh junxie6

🐢
Push the limits of what's possible. Today.
View GitHub Profile
@junxie6
junxie6 / uploader.go
Created December 1, 2016 21:39 — forked from taylorhughes/uploader.go
A lightly modified excerpt from Cluster's streaming media upload server, which encodes video on the fly as it is uploaded.
func EncodeStreamingVideo(streamingFile io.Reader, request ShouldCanceler) (*os.File, error) {
outputFilename := generateFilename("mp4")
// Actually start the command.
cmd := exec.Command("ffmpeg",
// Read input from stdin.
"-i", "-",
// ... environment-specific ffmpeg options ...
"-y", outputFilename)
@junxie6
junxie6 / bench_test.go
Created March 16, 2017 19:10 — forked from jochumdev/bench_test.go
Go RPC Benchmarks, encoding/gob seems to be the fastest RPC encoder for Go.
// Copyright 2013 René Kistl. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package srpc
import (
"errors"
"fmt"
"github.com/pcdummy/skynet2/rpc/bsonrpc"
@junxie6
junxie6 / logger.go
Created May 1, 2017 05:25 — forked from JalfResi/logger.go
Golang HTTP Handler request/response logger
func logger(prefix string, h http.Handler) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Save a copy of this request for debugging.
requestDump, err := httputil.DumpRequest(r, false)
if err != nil {
log.Println(err)
}
log.Println(prefix, string(requestDump))
@junxie6
junxie6 / gittp.go
Created June 11, 2017 18:25 — forked from shanzi/gittp.go
A simple Git Http Server in go
/*
gittip: a basic git http server.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright 2014 Chase Zhang <yun.er.run@gmail.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
@junxie6
junxie6 / 256 colors.md
Created October 11, 2017 05:57 — forked from limingjie/256 colors.md
256 colors in putty, tmux/screen and vim

#256 colors in putty, tmux/screen and vim There is a detailed answer on stackoverflow. If you are looking for a short one, here it is.

  • putty

    Set Connection -> Data -> Terminal-type string to xterm-256color

  • tmux

Add this line to ~/.tmux.conf

package main
import (
"fmt"
"log"
"net/http"
"html/template"
"github.com/gorilla/sessions"
@junxie6
junxie6 / translate.go
Created January 29, 2018 07:37 — forked from hvoecking/translate.go
Golang reflection: traversing arbitrary structures
// 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
//
@junxie6
junxie6 / Makefile
Created February 18, 2018 18:46 — forked from eliasson/Makefile
Example Makefile for small projects in golang
PACKAGES := \
github.com/eliasson/foo \
github.com/eliasson/bar
DEPENDENCIES := github.com/eliasson/acme
all: build silent-test
build:
go build -o bin/foo main.go
#!/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
@junxie6
junxie6 / mysql_replication_autostart.sh
Created September 15, 2018 16:42 — 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/
#!/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
#=============================================================================