Skip to content

Instantly share code, notes, and snippets.

@tigercallme
tigercallme / aws.md
Created February 15, 2019 09:58 — forked from colinvh/aws.md
AWS Region Names

Alternative naming schemes for AWS regions

Purpose

The intent is to define terse, standards-supported names for AWS regions.

Schemes

@tigercallme
tigercallme / main.go
Last active October 20, 2017 13:26
Go小技巧-使用for range time.Tick()固定间隔时间执行
for range time.Tick(30 * time.Millisecond) {
doSomthing()
}
//time.Tick()返回的是一个channel,每隔指定的时间会有数据从channel中出来,
//for range不仅能遍历map,slice,array还能取出channel中数据,range前面可以不用变量接收,
//所以可以简写成上面的形式。
@tigercallme
tigercallme / main.go
Last active October 20, 2017 13:27
Go小技巧-使用select{}阻塞main函数
// 很多时候我们需要让main函数不退出,让它在后台一直执行,例如:
func main() {
for i := 0; i < 20; i++ { //启动20个协程处理消息队列中的消息
c := consumer.New()
go c.Start()
}
select {} // 阻塞
}
@tigercallme
tigercallme / time.py
Created February 24, 2017 09:02 — forked from DeronW/time.py
python 拿当前的时间戳 秒数和毫秒数,time的经度跟系统相关,windows小数点后3位,linux后面6位
import time
from datetime import datetime, date
# 今天
datetime.datetime.today().date().isoformat()
# 通过日期对象生成时间戳
int(time.mktime(datetime.now().timetuple()))
# 通过时间戳生成日期对象,timestamp 的时间戳以秒为单位
@tigercallme
tigercallme / Vagrantfile
Created February 16, 2017 03:19 — forked from mikesorae/Vagrantfile
ansible file for dynamodb server
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
@tigercallme
tigercallme / install-dynamodb-local
Created February 15, 2017 17:26 — forked from bcavagnolo/install-dynamodb-local
A script to install dynamodb local
#!/usr/bin/env bash
set -e
set -x
[ "${DYNAMODB_HOME}" = "" ] && DYNAMODB_HOME=/opt/dynamodb
DYNAMODB_FILE=dynamodb_local_latest.tar.gz
DYNAMODB_URL=http://dynamodb-local.s3-website-us-west-2.amazonaws.com/${DYNAMODB_FILE}
DYNAMODB_JAR=DynamoDBLocal.jar
DYNAMODB_LOG=/var/log/dynamodb.log
man() {
env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
man "$@"
package main
//round n up to a multiple of a. a must be a power of 2.
func round(n, a int) int {
return (n + a - 1) &^ (a - 1)
}
func main() {
println(round(3, 4))
println(round(5, 4))
package main
func rangeCopy() {
x := [2]int{0x11, 0x22}
for i, n := range x {
x[0], x[1] = 0x100, 0x200
println(i, n)
}