Skip to content

Instantly share code, notes, and snippets.

@zx1986
zx1986 / golang_prometheus_metric_counter.go
Created October 14, 2022 08:57 — forked from ggzeng/golang_prometheus_metric_counter.go
prometheus golang 客户端中的各类metric写法
//step1:初始一个counter, with help string
pushCounter = prometheus.NewCounter(prometheus.CounterOpts{
Name: "repository_pushes",
Help: "Number of pushes to external repository.",
})
//setp2: 注册容器
err = prometheus.Register(pushCounter)
if err != nil {
fmt.Println("Push counter couldn't be registered AGAIN, no counting will happen:", err)
@zx1986
zx1986 / nginx.conf
Created September 29, 2021 09:14
Nginx log format
log_format main '"$time_local" client=$remote_addr '
'host=$host '
'method=$request_method request="$request" '
'request_length=$request_length '
'status=$status bytes_sent=$bytes_sent '
'body_bytes_sent=$body_bytes_sent '
'referer=$http_referer '
'user_agent="$http_user_agent" '
'upstream_addr=$upstream_addr '
'upstream_status=$upstream_status '
@zx1986
zx1986 / calico.yaml
Last active August 23, 2021 12:43
客製化 Calico 的部署配置,只有調整 IPv4 CIDR | calico v3.16 | 10.168.0.0/16
---
# Source: calico/templates/calico-config.yaml
# This ConfigMap is used to configure a self-hosted Calico installation.
kind: ConfigMap
apiVersion: v1
metadata:
name: calico-config
namespace: kube-system
data:
# Typha is disabled.
@zx1986
zx1986 / keybase.md
Last active December 25, 2019 15:47

Keybase proof

I hereby claim:

  • I am zx1986 on github.
  • I am zx1986 (https://keybase.io/zx1986) on keybase.
  • I have a public key ASCqNbKerBiLrrtxTJ65TAcg1FnbgE5jwxFFJfi7665UGgo

To claim this, I am signing this object:

@zx1986
zx1986 / regexCheatsheet.js
Created January 15, 2019 14:15 — forked from sarthology/regexCheatsheet.js
A regex cheatsheet 👩🏻‍💻 (by Catherine)
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"
@zx1986
zx1986 / ansible-role-test.sh
Last active September 12, 2018 05:52 — forked from geerlingguy/ansible-role-test.sh
Ansible Role Test Shim Script
#!/bin/bash
#
# Ansible role test shim.
#
# Usage: [OPTIONS] ./tests/test.sh
# - distro: a supported Docker distro version (default = "centos7")
# - playbook: a playbook in the tests directory (default = "test.yml")
# - role_dir: the directory where the role exists (default = $PWD)
# - cleanup: whether to remove the Docker container (default = true)
# - container_id: the --name to set for the container (default = timestamp)
class ScenariosController < ApplicationController
include ScenarioCopier
before_action :set_scenario, only: [:show, :copy, :edit, :tree, :update, :destroy]
respond_to :java
# GET /scenarios
def index
authorize! :index, Scenario
render json: Scenario.where(:locked => false, :university => current_user.university)
end
# GET /scenarios/1
# backup with love by sync-settings.
@zx1986
zx1986 / docker-compose.yml
Last active November 16, 2016 13:40
Redmine with Postgresql in Docker
version: '2'
services:
redmine:
image: sameersbn/redmine:3.3.1
environment:
- TZ=Asia/Taipei
- DB_ADAPTER=mysql2