Skip to content

Instantly share code, notes, and snippets.

@hmldd
hmldd / urlpoll.go
Created November 20, 2019 13:08
Go 代码漫读 - 通过通信共享内存
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
/*
Go Codewalk: Share Memory By Communicating
Go 代码漫读 - 通过通信共享内存
https://golang.org/doc/codewalk/sharemem/
*/
@hmldd
hmldd / crawler.go
Created November 20, 2019 13:07
Go语言之旅 - 网络爬虫
/*
A Tour of Go Exercise: Web Crawler
Go语言之旅 - 网络爬虫
https://tour.golang.org/concurrency/10
*/
package main
import (
"fmt"
"sync"
@hmldd
hmldd / tree.go
Last active November 20, 2019 13:06
Go语言之旅 - 判断两个二叉树是否相等
/*
A Tour of Go Exercise: Equivalent Binary Trees
Go语言之旅 - 判断两个二叉树是否相等
https://tour.golang.org/concurrency/8
*/
package main
import "golang.org/x/tour/tree"
// Walk walks the tree t sending all values
@hmldd
hmldd / docker-compose.yml
Created November 1, 2019 09:15
Traefik docker 配置,包含traefik.toml文件、basic auth和grafana配置
version: '3'
services:
gateway:
# 官方最新的 traefik docker 镜像
# 生产环境建议指定镜像版本号
image: traefik:latest
# 停止后重新启动
restart: unless-stopped
# 静态配置可以通过 traefik.toml 文件设置,command 命令参数移至配置文件
@hmldd
hmldd / README.md
Last active October 30, 2019 06:49
简单的 traefik docker compose 配置文件,整理自 traefik 官方 Quick start。详情:https://docs.traefik.io/getting-started/quick-start/
1. Schedule a cron to execute at 2am daily.
This will be useful for scheduling database backup on daily basis.
0 2 * * * /bin/sh backup.sh
are used for matching all the records.
2. Schedule a cron to execute twice a day.
Below example command will execute at 5AM and 5PM daily. You can specify multiple time stamp by comma separated.
0 5,17 * * * /scripts/script.sh
3. Schedule a cron to execute on every minutes.
@hmldd
hmldd / cli-params.py
Created August 5, 2017 04:06
Python cli (command line) arguments
#!/usr/bin/env python
# coding:utf-8
import getopt
import sys
def main(argv):
# Default arguments value
@hmldd
hmldd / scroll.py
Last active October 6, 2023 14:59
Example of Elasticsearch scrolling using Python client
# coding:utf-8
from elasticsearch import Elasticsearch
import json
# Define config
host = "127.0.0.1"
port = 9200
timeout = 1000
index = "index"