Skip to content

Instantly share code, notes, and snippets.

View Akagi201's full-sized avatar
🎯
Focusing

Bob Liu Akagi201

🎯
Focusing
View GitHub Profile
@Akagi201
Akagi201 / router.pi-1.md
Created October 16, 2016 14:27 — forked from snakevil/router.pi-1.md
使用树莓派3B打造超强路由之一:初装

使用树莓派3B打造超强路由之一:初装

新款的树莓派3B功能之丰富,性能之强悍,让我垂涎。考虑到家里的网件 WNDR3700v2 也服役四年有余了。还是败了一个树莓派3B回来打造成新的路由。

WARNING 本文所有指令均仅供参考,切勿无脑复制粘贴!

〇 安装系统

package main
import (
"net/http"
)
type SingleHost struct {
handler http.Handler
allowedHost string
}
@Akagi201
Akagi201 / script.go
Created May 15, 2016 05:11 — forked from msoap/script.go
Run Go program as script
//usr/bin/env go run $0 "$@"; exit
package main
import (
"fmt"
"os"
)
func main() {
fmt.Println("Hello world!")

Live Transcoding

This is a collection of working commandline examples to show how one could use FFMpeg and VLC for live transcoding of video streams. All examples have been tested on OSX 10.7.5 with FFMPeg 1.1.3 and VLC 2.0.5 in early 2013.

Documentation links

@Akagi201
Akagi201 / proxy_copy.go
Created April 14, 2016 03:49 — forked from jbardin/proxy_copy.go
Go TCP Proxy pattern
package proxy
import (
"io"
"log"
"net"
)
func Proxy(srvConn, cliConn *net.TCPConn) {
// channels to wait on the close event for each connection
@Akagi201
Akagi201 / server.go
Created March 24, 2016 06:04 — forked from elithrar/server.go
Custom Handlers and Avoiding Globals in Go Web Applications - http://elithrar.github.io/article/custom-handlers-avoiding-globals/
package main
import (
"fmt"
"log"
"net/http"
"html/template"
"github.com/gorilla/sessions"
@Akagi201
Akagi201 / concurrency-in-go.md
Created March 13, 2016 03:58 — forked from kachayev/concurrency-in-go.md
Channels Are Not Enough or Why Pipelining Is Not That Easy
@Akagi201
Akagi201 / generate-articles.py
Created February 20, 2016 06:02 — forked from jaden/generate-articles.py
A script that generates 5000 test posts for Hugo benchmarks
# Create specified number of articles for Hugo benchmarks
from datetime import datetime
import random
import string
from sys import argv
def generateWord():
length = random.randint(1, 10)
word = ''.join(random.choice(string.letters) for _ in range(length))
@Akagi201
Akagi201 / conn_pool_implementation.go
Last active February 3, 2016 00:50 — forked from rday/gist:3504712
ConnectionPool Implementation
/**
This function creates a connection to the database. It shouldn't have to know anything
about the pool, It will be called N times where N is the size of the requested pool.
*/
func initCirrusConnections() (interface{}, error) {
dbserver, _ := configFile.GetString("default", "dbserver")
dbuser, _ := configFile.GetString("default", "dbuser")
dbpass, _ := configFile.GetString("default", "dbpass")
db := autorc.New("tcp", "", dbserver, dbuser, dbpass)
@Akagi201
Akagi201 / conn_pool.go
Created February 3, 2016 00:41 — forked from rday/gist:3504674
Abstract wrapper to allow connection pools
type InitFunction func() (interface{}, error)
type ConnectionPoolWrapper struct {
size int
conn chan interface{}
}
/**
Call the init function size times. If the init function fails during any call, then
the creation of the pool is considered a failure.