Skip to content

Instantly share code, notes, and snippets.

// Single line comment
/* Multi-
line comment */
// A package clause starts every source file.
// Main is a special name declaring an executable rather than a library.
package main
// Import declaration declares library packages referenced in this file.
import (
@lixianyang
lixianyang / defer_and_return.go
Created November 10, 2020 06:59
defer 里修改返回值的几种情况
package main
import (
"fmt"
)
func main() {
fmt.Println(f())
fmt.Println(f1())
fmt.Println(f2())
@lixianyang
lixianyang / ohmyzsh-config.txt
Created May 23, 2020 08:52
ohmyzsh 粘贴卡顿
https://github.com/zsh-users/zsh-autosuggestions/issues/238#issuecomment-389324292
```shell
# This speeds up pasting w/ autosuggest
# https://github.com/zsh-users/zsh-autosuggestions/issues/238
pasteinit() {
OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]}
zle -N self-insert url-quote-magic # I wonder if you'd need `.url-quote-magic`?
}
@lixianyang
lixianyang / prometheus-metrics-to-md.py
Created January 16, 2019 06:01
prometheus metrics to markdown help
# coding: utf-8
import sys
import requests
def get_metrics_string(url):
""" get metrics content """
r = requests.get(url)
29585: /usr/bin/ruby2.3 -Eascii-8bit:ascii-8bit /usr/local/bin/fluentd -c /fluentd/etc/fluent.conf -p /fluentd/plugins --under-supervisor
Address Kbytes Mode Offset Device Mapping
00007f3e4e000000 6144 rw--- 0000000000000000 000:00000 [ anon ]
00007f3e4e600000 4096 rw--- 0000000000000000 000:00000 [ anon ]
00007f3e4ea00000 14336 rw--- 0000000000000000 000:00000 [ anon ]
00007f3e4f800000 16384 rw--- 0000000000000000 000:00000 [ anon ]
00007f3e50800000 2048 rw--- 0000000000000000 000:00000 [ anon ]
00007f3e50a00000 2048 rw--- 0000000000000000 000:00000 [ anon ]
00007f3e50c00000 4096 rw--- 0000000000000000 000:00000 [ anon ]
00007f3e51000000 2048 rw--- 0000000000000000 000:00000 [ anon ]
@lixianyang
lixianyang / README-Template.md
Created August 28, 2017 08:00 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@lixianyang
lixianyang / qsort.c
Created July 16, 2017 06:04
快速排序,c语言实现(基础版)
# include <stdio.h>
void swap(int v[], int i, int j){
int temp = v[i];
v[i] = v[j];
v[j] = temp;
}
void qsort(int v[], int left, int right){
int i, last;