工作,学习,生活,这里将会有一些记录. 备用域名:http://meisw.wdlinux.cn 注册 | 登陆
浏览模式: 标准 | 列表全部文章

复杂密码正则,必须且只含有数字和字母

 密码:必须含有数字和字母,可以拥有英文符号,6-17位。正则表达式怎么写?
if(!preg_match('/(?=^.*?[a-z])(?=^.*?[A-Z])(?=^.*?\d)^(.{6,17})$/','151523152f4545242')){
echo '密码不符合规定!';
}


/(?=^.*?[a-z])(?=^.*?[A-Z])(?=^.*?\d)^(.{6,17})$/
要求至少有一个大写字母
而 151523152f4545242 中并没有!


必须且只含有数字和字母,可以拥有英文符号,6-17位。
/(?=.{6,17})(?=.*\d)(?=.*[a-z])[\x20-\x7f]*/i

 
if(!preg_match('/(?=^.*?[a-z])(?=^.*?[A-Z])(?=^.*?\d)^(.{6,17})$/','15A15545242')){
echo '密码不符合规定!';
}
 

golang 字符串转换为 json数据

package main
 
import (
    "encoding/json"
    "fmt"
    "os"
)
 
type ConfigStruct struct {
    Host              string   `json:"host"`
    Port              int      `json:"port"`
    AnalyticsFile     string   `json:"analytics_file"`
    StaticFileVersion int      `json:"static_file_version"`
    StaticDir         string   `json:"static_dir"`
    TemplatesDir      string   `json:"templates_dir"`
    SerTcpSocketHost  string   `json:"serTcpSocketHost"`
    SerTcpSocketPort  int      `json:"serTcpSocketPort"`
    Fruits            []string `json:"fruits"`
}
 
type Other struct {
    SerTcpSocketHost string   `json:"serTcpSocketHost"`
    SerTcpSocketPort int      `json:"serTcpSocketPort"`
    Fruits           []string `json:"fruits"`
}
 
func main() { 
    jsonStr := `{"host": "http://localhost:9090","port": 9090,"analytics_file": "","static_file_version": 1,"static_dir": "E:/Project/goTest/src/","templates_dir": "E:/Project/goTest/src/templates/","serTcpSocketHost": ":12340","serTcpSocketPort": 12340,"fruits": ["apple", "peach"]}`
 
    //json str 转map
    var dat map[string]interface{}
    if err := json.Unmarshal([]byte(jsonStr), &dat); err == nil {
        fmt.Println("==============json str 转map=======================")
        fmt.Println(dat)
        fmt.Println(dat["host"])
    }
 
    //json str 转struct
    var config ConfigStruct
    if err := json.Unmarshal([]byte(jsonStr), &config); err == nil {
        fmt.Println("================json str 转struct==")
        fmt.Println(config)
        fmt.Println(config.Host)
    }
 
    //json str 转struct(部份字段)
    var part Other
    if err := json.Unmarshal([]byte(jsonStr), &part); err == nil {
        fmt.Println("================json str 转struct==")
        fmt.Println(part)
        fmt.Println(part.SerTcpSocketPort)
    }
 
    //struct 到json str
    if b, err := json.Marshal(config); err == nil {
        fmt.Println("================struct 到json str==")
        fmt.Println(string(b))
    }
 
    //map 到json str
    fmt.Println("================map 到json str=====================")
    enc := json.NewEncoder(os.Stdout)
    enc.Encode(dat)
 
    //array 到 json str
    arr := []string{"hello", "apple", "python", "golang", "base", "peach", "pear"}
    lang, err := json.Marshal(arr)
    if err == nil {
        fmt.Println("================array 到 json str==")
        fmt.Println(string(lang))
    }
 
    //json 到 []string
    var wo []string
    if err := json.Unmarshal(lang, &wo); err == nil {
        fmt.Println("================json 到 []string==")
        fmt.Println(wo)
    }
}

ubuntu常用操作

 设置root密码

sudo passwd
 

1、vi /etc/network/interfaces

添加内容:

auto eth0
iface eth0 inet static
address 192.168.8.100    
netmask 255.255.255.0
gateway 192.168.8.2
dns-nameserver 119.29.29.29


vim /etc/ssh/sshd_config
  1. #PermitRootLogin without-password  
  2. PermitRootLogin yes 

killall命令
apt-get install psmisc



文件上传,断点续传

 文件下载之断点续传(客户端与服务端的实现)

https://www.cnblogs.com/zhaopei/p/download.html
 
文件各种上传,离不开的表单
http://www.cnblogs.com/zhaopei/p/upload.html
 
Golang实现断点续传
https://www.cnblogs.com/7explore-share/p/8111720.html
 
阿里云上传文件
https://helpcdn.aliyun.com/document_detail/32147.html
 

Go语言实现文件断点续传功能—resumable file uploads

 

HTTP 断点续传(分块传输)

https://blog.csdn.net/liang19890820/article/details/53215087
 
 
HTTP Range 请求
HTTP Range请求允许服务器向客户端发送HTTP消息体的一部分数据。Partial Requests在使用比较大的网络媒体文件或者在下载文件时提供暂停和恢复功能时很有用。
这也是下载时实现HTTP断点续传的一个关键。
 
HTTP 206 (Partial Content)
如果服务器能返回HTTP 206请求,我们就知道它能够支持Range request.
# curl -I https://www.baidu.com/ -H "Range: bytes=0-"
 
 
下载续传,一般WEB服务器,如nginx,apache,iis已支付,只在客户端实现即可
上传续传,也叫分片上传,需要分别在服务端,客户端实现
服务端针对分片的处理,获取当前的分片,每个分片上传保存,然后将分片合并
 
 
---
一些思路
提供一个思路,上传前先往数据库插入一条数据。数据包含文件要存的路径、文件名(用GUID命名,防止同名文件冲突)、文件MD5(用来识别下次续传和秒传)、临时文件块存放路径、文件是否完整上传成功等信息。
然后如果我们断网后再传,首先获取文件MD5值,看数据库里面有没上传完成的文件,如果有就实现秒传。如果没有,看是不是有上传了部分的。如果有接着传,如果没有则重新传一个新的文件。
 

webstorm 2017 激活破解方法大全

 webstorm 作为最近最火的前端开发工具,也确实对得起那个价格,但是秉着勤俭节约的传统美德,我们肯定是能省则省啊。

方法一:(更新时间:2018/4/8)v3.3


注册时,在打开的License Activation窗口中选择“License server”,在输入框输入下面的网址:

http://im.js.cn:8888 (新,感谢 [ qq_34394012 ])

点击:Activate即可。

方法二:获取注册码


打开网址(IntelliJ IDEA 注册码),我们能看到下面的界面,直接点击获取激活码,将生成的激活码粘贴到WebStorm激活对话框中的Lisence Code输入框,点击OK即可破解。

 

http://xiazai.xiazaiba.com/Soft/W/WebStorm_2017.3_XiaZaiBa.zip?pcid=30429&filename=WebStorm_2017.3_XiaZaiBa.zip&downloadtype=xiazaiba_seo

centos 远程安装

 yum install -y wget

cd /boot
wget http://mirrors.163.com/centos/6.9/os/x86_64/images/pxeboot/initrd.img
wget http://mirrors.163.com/centos/6.9/os/x86_64/images/pxeboot/vmlinuz
 
vi /boot/grup/grup.conf
add
 
title CentOS reinstall
       root (hd0,0)
        kernel /vmlinuz headless hostname=localhost ip=192.168.0.104 noipv6 netmask=255.255.255.0 gateway=192.168.0.1 dns=114.114.114.114 ksdevice=eth0 method=http://mirrors.163.com/centos/6.9/os/x86_64/ lang=en_US keymap=us
        #kernel /vmlinuz vnc vncpassword=123456 headless hostname=localhost ip=192.168.0.104 noipv6 netmask=255.255.255.0 gateway=192.168.0.1 dns=114.114.114.114 ksdevice=eth0 method=http://mirrors.163.com/centos/6.9/os/x86_64/ lang=en_US keymap=us
       initrd /initrd.img

golang 编译

 go编译的时候默认会将代码和行号包含到gdb调试信息里,使用gdb还是可以看见源码,编译的时候加-ldflags "-s -w"可以去掉调试信息。

ubuntu shell兼容问题

 dpkg-reconfigure dash