swift4 自定义UITableCell

2018-06-09 10:27:00   朋也   swift学习笔记(纯代码)   swift4 uitableview uitablecell  

直接上图

spring-security 实现用户名密码/图片验证码验证和记住我以及登录次数判断功能

2018-05-21 16:40:44   朋也   spring-boot学习笔记   spring-security  

自定用户名密码验证

不用spring-security自带的,自己实现一个provider,只做用户名密码校验,代码如下

public class MyAuthenticationProvider extends DaoAuthenticationProvider {

  @Override
  public Authentication authenticate(Authentication authentication) throws AuthenticationException {
    UsernamePasswordAuthenticationToken token = (UsernamePasswordAuthenticationToken) authentication;
    String username = token.getName();
    UserDetails userDetails = this.getUserDetailsService().loadUserByUsername(username);
    // 验证密码是否正确
    if (!new BCryptPasswordEncoder().matches((CharSequence) token.getCredentials(), userDetails.getPassword())) {
      throw new AuthenticationServiceException("用户名或密码错误");
    }
    return new UsernamePasswordAuthenticationToken(userDetails, userDetails.getPassword(), userDetails.getAuthorities());
  }

  @Override
  public boolean supports(Class<?> authentication) {
    return UsernamePasswordAuthenticationToken.class.equals(authentication);
  }
}

SecurityConfig配置如下

ngrok

2018-05-18 00:00:00   ngrok 内网穿透   内网 ngrok  

内网穿透

ngrok by @inconshreveable  
Session Status                online
Account                       yongze (Plan: Free)
Version                       2.2.8
Region                        United States (us)
Web Interface                 http://127.0.0.1:4040
Forwarding                    http://b0cecd04.ngrok.io -> localhost:80
Forwarding                    https://b0cecd04.ngrok.io -> localhost:80

Connections                   ttl     opn     rt1     rt5     p50     p90
                              3       0       0.00    0.01    0.65    98.26

HTTP Requests
-------------

GET /                          200 OK
GET /                          200 OK
GET /                          200 OK
GET /favicon.ico               404 Not Found
GET /                          200 OK


Java使用HttpUrlConnection下载网络文件

2018-05-11 09:47:00   朋也   java学习笔记   下载 http  

单线程下载

读取文件长度

防止文件过大,建议用long接收

HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
long contentLength = connection.getContentLength();

egg.js开发博客

2018-04-20 16:34:44   朋也   egg.js学习笔记   egg.js  

业余时间学了一下egg.js,并开发了个非常简单的博客,实现了 CRUD 功能,总结一下

安装

$ npm i egg-init -g
$ egg-init eblog --type=simple
$ cd eblog
$ yarn install

       4 / 15