Skip to content

Instantly share code, notes, and snippets.

# https://github.com/grafana/grafana/blob/main/pkg/services/ngalert/notifier/channels/default_template.go
#
{{ define "subject" }}[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ if gt (.Alerts.Resolved | len) 0 }}, RESOLVED:{{ .Alerts.Resolved | len }}{{ end }}{{ end }}] {{ .GroupLabels.SortedPairs.Values | join " " }}{{ end }}
{{ define "text_values_list" }}{{ $len := len .Values }}{{ if $len }}{{ $first := gt $len 1 }}{{ range $refID, $value := .Values -}}
{{ $refID }}={{ $value }}{{ if $first }}, {{ end }}{{ $first = false }}{{ end -}}
{{ else }}[no value]{{ end }}{{ end }}
{{ define "text_alert_list" }}{{ range . }}
{{ .Labels.instance}}
@Firxiao
Firxiao / create-hotspot.md
Created October 4, 2021 09:54 — forked from narate/create-hotspot.md
Create Wi-Fi Hotspot on Linux using nmcli

Create a Wi-Fi hotspot on Linux using nmcli

Original post : https://unix.stackexchange.com/a/310699

nmcli con add type wifi ifname wlan0 con-name Hostspot autoconnect yes ssid Hostspot
nmcli con modify Hostspot 802-11-wireless.mode ap 802-11-wireless.band bg ipv4.method shared
nmcli con modify Hostspot wifi-sec.key-mgmt wpa-psk
nmcli con modify Hostspot wifi-sec.psk "veryveryhardpassword1234"
@Firxiao
Firxiao / Grub2 notes.md
Last active July 7, 2021 12:53
Grub notes

clover in grub2

[workstation] /etc/grub.d $ cat 40_custom
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry 'macOS' {
insmod fat
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import os, sys
def convert(rootdir, optype='l'):
"""
目录/文件名转换成小写或大写
:param rootdir: 要转换的根目录路径
:param optype: 操作类型(小写/大写) 小写:optype = 'l' 大写:optype = 'u',默认转换成小写
@echo off
rem Start Stop VMware VMs via vmrun
cls
:: Defein VM names
set VMs=k8s-master01 k8s-node01 k8s-node02 k8s-node03
set VMLocation=C:\Users\xf\Documents\Virtual Machines\
set VMwarePATH=D:\Program Files (x86)\VMware\VMware Workstation
color 0a
TITLE VMware VMs Manager
#!/bin/bash
# rename all files and dirs name to lower case
DEST=$2
function rename()
{
name="$1"
lowerCaseName="$(echo "$name"|tr '[A-Z]' '[a-z]')"
if [ -d "$name" ]; then
if [ ! -d "$DEST/$lowerCaseName" ]; then
echo "mkdir -p $DEST/$lowerCaseName"
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Long 2.24 qw( :config bundling no_ignore_case no_auto_abbrev );
my ( $N, $EXT, @EXT, @USE, $DECODE, $ENCODE );
sub compile { eval shift } # defined early to control the lexical environment
my $msglevel = 0;
@Firxiao
Firxiao / speed_test.sh
Created July 19, 2019 08:05
Test network speed via scp
#!/bin/bash
# author: Firxiao
TEST_FILE=/root/test_file
LOG_FILE=/opt/speed_test.log
DEST_SERVER=xxxx
DEST_LOCATION='/tmp'
LOCAL_LOCATION='/tmp'
# Function: Setup LOG_FILE and redirect stdout/stderr.
2016/12/07 15:12:55 [INFO] Packer version: 0.12.0
2016/12/07 15:12:55 Packer Target OS/Arch: linux amd64
2016/12/07 15:12:55 Built with Go Version: go1.7.3
2016/12/07 15:12:55 Detected home directory from env var: /root
2016/12/07 15:12:55 Using internal plugin for amazon-instance
2016/12/07 15:12:55 Using internal plugin for digitalocean
2016/12/07 15:12:55 Using internal plugin for docker
2016/12/07 15:12:55 Using internal plugin for parallels-iso
2016/12/07 15:12:55 Using internal plugin for profitbricks
2016/12/07 15:12:55 Using internal plugin for qemu