function format(date, format = "yyyy-MM-dd hh:mm:ss") {
//new Date 在 ios safari浏览器有兼容性问题处理如下:
// ? 兼容safari : 兼容其他浏览器
let $this = new Date(date) == 'Invalid D...
table, td{
border: 1px solid #000000;
border-collapse: collapse;
line-height:40px;
}
魔法方法
含义
基本的魔法方法
__new__(cls[, ...])
1. __new__ ...
#!/usr/bin/python3
import os
import paramiko
class DownFile(object):
ssh = paramiko.SSHClient()
def __exit__(self, exc_type, exc_val, exc_tb):
self.ssh.close()
...
安装依赖:
go get github.com/oschwald/geoip2-golang
数据库文件下载地址(需注册用户):
https://www.maxmind.com/en/accounts/current/geoip/downloads
示例代码:
type Result struct {
...
基于:github.com/gorilla/websocket 实现
func main() {
interrupt := make(chan os.Signal, 1)
signal.Notify(interrupt, os.Interrupt)
ws := "ws://127.0.0.1:8080/ws"
c, _, err := ...
etcdctl基本使用
增加一条数据
etcdctl put "/school/class/name" "helios"
获取一条数据
etcdctl get "/school/class/name"
得到一组数据
etcdctl get "/school/class/" --prefix
得到所有的ke...
限量核心代码:limit.go
type Limit struct {
Name string
Key string
Rate int64
Max int64
Default int64
}
func (l *Limit) Add(a, b float64) float64 {
r...
获取请求报文
请求报文格式说明
HTTP请求报文由请求行、请求头、空行、请求体四个部分组成,如下图:
请求行
请求行由方法字段和HTTP协议版本字段3个部分组成,他们呢之间使用空格隔开。...
完整报错信息:
logstash.outputs.elasticsearch] retrying failed action with response code: 403 ({"type"=>"cluster_block_exception", "reason"=>"blocked by: [FORBIDDEN/12/index read-only / allo...
js文件调用方式:
<script src="./xx.js?a=b"></script>
获取参数的方法:
function getQueryVariable(variable)
{
var src = document.currentScript.src;
var getParam = src.su...
网络分层架构
典型协议
传输层:常见协议有TCP/UDP协议
应用层:常见的协议有HTTP协议,FTP协议
网络层:常见协议有IP协议,ICMP协议,IGMP协议
网络接口层:常见协议有ARP协议,RARP协议
TCP传...
条件变量的作用并不保证同一时刻仅有一个协程(线程)访问某个共享的数据资源,而是在对应的共享数据的状态发生变化时,通知阻塞在某个条件上的协程(线程)。条件变量不是锁,在兵法中不能达到同步的目的,因此...
注意:仅作为学习参考,并没有完整实现所有类型
type User struct {
Name string
Age int
Sex byte `json:"sex"`
}
type Book struct {
ISBN string `json:"isbn"`
Name ...
time.Timer
Timer 是一个定时器。代表未来的一个单一事件,你可以告诉timer你要等待多长时间。
type Timer struct {
C <-chan Time
r runtimeTimer
}
它提供一个channel,在定时时间到达之前,...