Skip to content

Instantly share code, notes, and snippets.

View songjiayang's full-sized avatar
🏃‍♂️
keep going

songjiayang songjiayang

🏃‍♂️
keep going
View GitHub Profile
@songjiayang
songjiayang / cmd.go
Last active May 31, 2019 02:55
cmd.go
cmd := exec.Cmd{
Path: command,
}
cmd.Stdout = os.Stdout
// start app
if err := cmd.Start(); err != nil {
log.Panic(err)
}
@songjiayang
songjiayang / gitconfig
Created May 7, 2019 06:07
go get with git rather than http
[http "https://git.xx.com"]
sslVerify = false
[url "git@git.xx.com:"]
insteadOf = http://git.xx.com
@songjiayang
songjiayang / README.md
Created December 14, 2018 01:40 — forked from tombigel/README.md
How to Change Open Files Limit on OS X and macOS Sierra (10.8 - 10.12)

How to Change Open Files Limit on OS X and macOS

This text is the section about OS X Yosemite (which also works for macOS Sierra) from https://docs.basho.com/riak/kv/2.1.4/using/performance/open-files-limit/#mac-os-x

The last time i visited this link it was dead (403), so I cloned it here from the latest snapshot in Archive.org's Wayback Machine https://web.archive.org/web/20170523131633/https://docs.basho.com/riak/kv/2.1.4/using/performance/open-files-limit/

Mac OS X

To check the current limits on your Mac OS X system, run:

@songjiayang
songjiayang / format.tmpl
Last active April 9, 2018 09:50
golang time format in template
{{ define "wechat.default.message" }}
{{ range .Alerts }}
告警级别:{{ .Labels.severity }}
告警类型:{{ .Labels.alertname }}
故障主机: {{ .Labels.instance }}
告警主题: {{ .Annotations.summary }}
告警详情: {{ .Annotations.description }}
触发时间: {{ .StartsAt.Format "2006-01-02 15:04:05" }}
{{ end }}
{{ end }}
package main
import (
"crypto/md5"
"fmt"
)
func main() {
nodes := []string{
"192.168.1.1:9090", "192.168.1.2:9090", "192.168.1.3:9090", "192.168.1.4:9090", "192.168.1.5:9090",
{{ define "wechat.default.message" }}
告警级别:{{ .CommonLabels.severity }}
告警类型:{{ .GroupLabels.alertname }}
故障主机: {{ .CommonLabels.instance }}
告警主题: {{ .CommonAnnotations.summary }}
告警详情: {{ .CommonAnnotations.description }}
{{- end }}
@songjiayang
songjiayang / multiple-messges.tmpl
Last active March 6, 2018 06:44
WeChat receiver message custom template
{{ define "wechat.default.message" }}
{{ range .Alerts }}
告警级别:{{ .Labels.severity }}
告警类型:{{ .Labels.alertname }}
故障主机: {{ .Labels.instance }}
告警主题: {{ .Annotations.summary }}
告警详情: {{ .Annotations.description }}
======
{{ end }}
{{ end }}

Routes

小心地使用 Match(Rails 3 已实现)

Rails 3 提供了 match 方法供我们自定义 routes,然而我们要小心使用它以避免“跨站脚本攻击”(XSS Attack)。比如像这样的 routes:

注:(r3 代表 Rails 3,r4 代表 Rails 4)

# routes.rb

Simple Starting Point

创建 Model

var Person = Backbone.Model.extend();
@songjiayang
songjiayang / mcbbs_robot.rb
Created October 14, 2014 03:05
A robot for http://www.mcbbs.net/forum.php download source.
require 'mechanize'
require 'csv'
class McbbsRobot
def initialize
@agent = Mechanize.new
@cache_data = Array.new
@nodes = Array.new
end