The intent is to define terse, standards-supported names for AWS regions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for range time.Tick(30 * time.Millisecond) { | |
doSomthing() | |
} | |
//time.Tick()返回的是一个channel,每隔指定的时间会有数据从channel中出来, | |
//for range不仅能遍历map,slice,array还能取出channel中数据,range前面可以不用变量接收, | |
//所以可以简写成上面的形式。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 很多时候我们需要让main函数不退出,让它在后台一直执行,例如: | |
func main() { | |
for i := 0; i < 20; i++ { //启动20个协程处理消息队列中的消息 | |
c := consumer.New() | |
go c.Start() | |
} | |
select {} // 阻塞 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from datetime import datetime, date | |
# 今天 | |
datetime.datetime.today().date().isoformat() | |
# 通过日期对象生成时间戳 | |
int(time.mktime(datetime.now().timetuple())) | |
# 通过时间戳生成日期对象,timestamp 的时间戳以秒为单位 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
func rangeCopy() { | |
x := [2]int{0x11, 0x22} | |
for i, n := range x { | |
x[0], x[1] = 0x100, 0x200 | |
println(i, n) | |
} |
#参考资料
###下载单个文件,默认将输出打印到标准输出中(STDOUT)中
curl http://www.centos.org
NewerOlder