Skip to content

Instantly share code, notes, and snippets.

View se77en's full-sized avatar

Damon Zhao se77en

View GitHub Profile
// Copyright 2016 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// Command caption reads an audio file and outputs the transcript for it.
package main
import (
"fmt"
"io"
# 你可以从该 URL 下载这个配置文件: http://surge.run/config-example/ios.conf
# 用编辑器编辑后,再通过 iTunes, URL, AirDrop 或者 iCloud Drive 复制回 iOS 设备
# Version 2.0
[General]
# 日志等级: warning, notify, info, verbose (默认值: notify)
loglevel = notify
# 跳过某个域名或者 IP 段,这些目标主机将不会由 Surge Proxy 处理。(在 macOS
# 版本中,如果启用了 Set as System Proxy, 那么这些值会被写入到系统网络代理
# 设置中.)
@Mudpuppy12
Mudpuppy12 / gist:db9f2a2b4ab62babd72a1edddd4b5273
Last active May 4, 2017 15:14
Example Iris Session / Basic Auth
// main.go
package main
import (
"time"
"github.com/kataras/iris"
"github.com/kataras/iris/config"
"github.com/kataras/iris/middleware/basicauth"
"github.com/kataras/iris/middleware/logger"
@turtlemonvh
turtlemonvh / Gin.WrapHH.go
Last active June 27, 2019 08:02
A pattern for wrapping functions that accept an http handler in gin
// A wrapper that turns a http.ResponseWriter into a gin.ResponseWriter, given an existing gin.ResponseWriter
// Needed if the middleware you are using modifies the writer it passes downstream
// FIXME: Wrap more methods: https://golang.org/pkg/net/http/#ResponseWriter
type WrappedResponseWriter struct {
gin.ResponseWriter
writer http.ResponseWriter
}
func (w *WrappedResponseWriter) Write(data []byte) (int, error) {
return w.writer.Write(data)
@mrkaspa
mrkaspa / ifx.exs
Last active January 8, 2016 06:54
If else built in elixir using macros
defmodule My do
defmacro ifx(conds, [do: code1, else: code2]) do
quote do
case unquote conds do
true -> unquote code1
_ -> unquote code2
end
end
end
end
@aggrolite
aggrolite / redditbot.md
Last active January 6, 2022 13:44
Writing a reddit bot with Go and OAuth2
@ebuildy
ebuildy / docker-compose-sentry.yml
Created November 24, 2015 08:12
A simple docker-compose YML to run Sentry.
redis:
image: redis
postgres:
image: postgres:9.4
environment:
- POSTGRES_USER:sentry
- POSTGRES_PASSWORD:sentry
volumes:
- /var/data/sentry/postgre:/var/lib/postgresql/data:rw
@iamralch
iamralch / context.go
Created November 20, 2015 13:05
An example that illustrates how to work with https://godoc.org/golang.org/x/net/context
package main
import (
"bufio"
"fmt"
"os"
"strings"
"time"
"golang.org/x/net/context"
@wintercn
wintercn / yc.js
Last active April 3, 2019 17:52
ycombinator in es2015
//yc here
var y = g =>
(f=>f(f))(
self =>
g( (...args)=>self(self)(...args) )
)
//use yc
var f = y(self =>
n => n < 0 ? 0 : n + self(n-1))
@ericlagergren
ericlagergren / index.gohtml
Last active December 22, 2023 17:51
Hot-reloading / hot-swapping live template files in Go
My name is {{.Name}} and I'm {{.Age}} years old!!