HuaChao's Blog

This is Dairy&Study Recorder


  • Home

  • About

  • Archives

  • Tags

hexo-renderer-markdown-it-plus plugin demo

Posted on 2017-07-27 | Visitors

I use hexo-theme-next for my blog, and I met a problem same with #826.

I wrote a plugin hexo-renderer-markdown-it-plus for fix it,and this article is a demo for hexo-renderer-markdown-it-plus

The hexo default hexo-renderer-marked do not support LaTex parser, you must referer external link to parse Latex grammar to html(That’s whathexo-theme-next did, hexo-theme-next use mathjax), and the mathjax and hexo-renderer-marked will cause some problem:

  1. _ parse error, you must change x_i to x\_i(This problem had been fixed when i test.)
  2. do not support lines grammar, expample below:
$$
H=-\sum_{i=1}^N (\sigma_{i}^x \sigma_{i+1}^x+g \sigma_{i}^z)
$$

$$
f(n) = \begin{cases}
 \frac{n}{2},
 & \text{if } n\text{ is even}
 \\ 3n+1, & \text{if } n\text{ is odd}
 \end{cases}
$$

$$
\begin{aligned}
\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\   
\nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
\nabla \cdot \vec{\mathbf{B}} & = 0 \end{aligned}
$$
Read more »

CF Educational Codeforces Round 15

Posted on 2016-07-30 | Visitors

A. Maximum Increase

You are given array consisting of n integers. Your task is to find the maximum length of an increasing subarray of the given array.

A subarray is the sequence of consecutive elements of the array. Subarray is called increasing if each element of this subarray strictly greater than previous.

Input

The first line contains single positive integer n (1≤n≤1051 \leq n \leq 10^51≤n≤10​5​​) — the number of integers.

The second line contains n positive integers a1a_1a​1​​, a2a_2a​2​​, …, ana_na​n​​ (1≤ai≤1091 \leq a_i \leq 10^91≤a​i​​≤10​9​​).

OutPut

Print the maximum length of an increasing subarray of the given array.

Examples

input
5
1 7 2 11 15
output
3

input
6
100 100 100 100 100 100
output
1

input
3
1 2 3
output
3

题解

题意大致是最大的连续上升连续子序列长度
简单判断一下连续的子序列长度,然后求一个max就可以了

//author: CHC
//First Edit Time:	2016-07-29 23:04
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <limits>
using namespace std;
typedef long long LL;
const int MAXN=1e+5 + 1000;
const int INF = numeric_limits<int>::max();
const LL LL_INF= numeric_limits<LL>::max();
int A[MAXN],n;
int main()
{
    while(~scanf("%d",&n))
    {
        for(int i=1;i<=n;i++)
            scanf("%d",&A[i]);
        int cnt = 1;
        int mcnt = 1;
        for(int i=1;i<n;i++)
        {
            if(A[i]<A[i+1])
            {
                ++cnt;
            }
            else
            {
                cnt = 1;
            }
            mcnt = max(mcnt,cnt);
        }
        printf("%d\n",mcnt);
    }
    return 0;
}

B. Powers of Two

You are given n integers a1a_1a​1​​, a2a_2a​2​​, …, ana_na​n​​. Find the number of pairs of indexes i, j (i < j) that a_i + a_j is a power of 2 (i. e. some integer x exists so that a_i + a_j = 2^x).

Read more »

[HTTPS]使用letsencrypt搭建SSL证书

Posted on 2016-07-29 | Visitors

官网:https://letsencrypt.org/getting-started/

使用certbot

certbot:https://certbot.eff.org/

可以按照官网上的来(一直没有成功过。。。)
也可以按照我的方法来执行

git clone https://github.com/certbot/certbot.git
cd certbot
./certbot-auto

然后等待,自动安装完成之后会弹出一个蓝色的框,然后选择NO退出
如果nginx正在运行要把nginx关掉pkill nginx
再执行以下命令(如果想要知道更详细的信息,请自行查看官方文档或者./certbot-auto --help all)

./certbot-auto certonly --standalone --agree-tos -v -t --email chen93104@163.com -d www.chenhuachao.com -d chenhuachao.com -d chchc.me -d www.chchc.me

成功之后,会告诉我证书放在了/etc/letsencrypt/live/www.chenhuachao.com/这个位置
然后,到此证书就生成完毕了
nginx的配置中 加上两行:

server {
    listen 443;
    // ...
    ssl on;
    ssl_certificate /etc/letsencrypt/live/www.chenhuachao.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/www.chenhuachao.com/privkey.pem;
    // ...
}

HTTP跳转HTTPS

一般用户输入网址是不会输入https的,但是输入http访问的话确不是访问的HTTPS,这里有一个解决方案,就是在80那里跳转到https

server {
    listen       80; 
    server_name  ~chenhuachao|chenxchen|chchc;
    rewrite ^(.*)$  https://$host$1 permanent;
    # 避免嵌入iframe,避免点击劫持
    add_header X-Frame-Options "DENY";
    root   /usr/local/nginx/blog/chc-blog;
    index index.html index.htm;

    location ~ /\. {
        deny all;
    }   
}

然而,因为302的这个过程中,有可能被拦截篡改(中间人攻击),因此,需要配置HSTS了,如果你之前访问过这个网站,浏览器就知道只使用HTTPS,HSTS的意思是告诉浏览器只使用HTTPS,它需要在HTTPS server中配置
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";即可

HTTPS安全性及其性能优化

涉及到的相关知识点
OCSP
HSTS
SPDY(1.9.5版本过后被http2取代)

Read more »

CentOS7 搭建OpenVPN

Posted on 2016-06-23 | Visitors

添加epel源

yum install epel-release
yum cleanall # 可选
yum update # 可选
yum makecache # 可选

安装openvpn easy-rsa iptables

yum -y install openvpn easy-rsa iptables-services

配置easy-rsa

在这一步生成一些证书

  • CA证书
  • 服务器证书和密钥
  • Diffie-Hellman密钥
  • 客户端证书和密钥
cp -r /usr/share/easy-rsa/ /etc/openvpn/
cd /etc/openvpn/easy-rsa/2.*/
vim vars

确保vars中以下参数正确

Read more »

编译USB无线驱动8192cu

Posted on 2016-06-09 | Visitors

之前买的那个USB无线驱动不好用。。然后在某东上买了一个EDUP EP-DB1608 11AC双频,买之前很惊讶的发现其官网上有Linux驱动下。果断买买买

在这里下载对应版本的linux版EP-DB1608驱动
http://www.edup.cn/support/driver-download/

我的系统:

uname -a
Linux xxx 4.4.0-22-generic #40-Ubuntu SMP Thu May 12 22:03:46 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

解压缩之后进入文件夹

chmod +x install.sh
sudo ./install.sh

执行完之后一阵报错,于是去源代码里找看是怎么回事。。

cd 8811linux/driver
tar xvf rtl8821AU_linux_v4.3.14_13455.20150212_BTCOEX20150128-51.tar.gz

找了半个小时不知道怎么解决,于是去github上找,没想到还真找到了

https://github.com/ulli-kroll/rtl8821au

把代码clone下来
然后执行

make
sudo insmod rtl8821au.ko

然后成功。。

Read more »

在network中的所有内容中查找

Posted on 2016-06-06 | Visitors

在chrome的dev-tools中,并没有提供在network的所有内容中查找。。这样在查找接口的时候很难。。然后在google上找了两个小时之后终于找到,有前人开发的插件
github地址:

https://github.com/roryc89/network-filter

Read more »

linux 编译安装USB网卡驱动 rtl8188eu(s)

Posted on 2016-05-28 | Visitors

在某东上买了一个USB无线网卡。因为我的笔记本的ubuntu下网卡驱动有问题,连接老是不稳定经常断开,研究了一阵子后弃疗,所以买了一个USB无线网卡。
第二天到货。
插上USB无线网卡,然后输入以下命令

xxx@xxx:~$ lsusb
Bus 002 Device 002: ID 0bda:8179 Realtek Semiconductor Corp. RTL8188EUS 802.11n Wireless Network Adapter

通过查看可以看到后面哪个版本号RTL8188EUS,但是在官网找了以下,发现全是win版本的,于是在github上搜了以下,发现有RTL8188EUS这个项目,clone下来之后发现无法编译。
于是网上又找了找,发现了有的人RLT8188EUS可以安装RLT8188EU的驱动成功。。于是github上又找了RLT8188EU,编译安装重启。。成功。。。
链接:

https://github.com/lwfinger/rtl8188eu
Read more »

ssh出错 sign_and_send_pubkey: signing failed: agent refused operation

Posted on 2016-05-26 | Visitors

在服务器添加完公钥之后,ssh服务器然后报了这个错误

sign_and_send_pubkey: signing failed: agent refused operation

然后执行了以下命令才好。。

eval "$(ssh-agent -s)"
ssh-add
Read more »

linux MySQL重置密码

Posted on 2016-03-16 | Visitors

关闭MYSQL服务

service mysqld stop

启动mysqld_safe ,跳过启动授权表。

mysqld_safe --skip-grant-tables &

登录mysql,并修改密码

mysql
use mysql
update user set password=PASSWORD('12345678') where user="root";    ---将root密码设置为12345678
flush privileges;
exit

关掉mysqld_safe进程

kill -9  11283  (11283为mysqld_safe进程)
service mysqld start
mysql -uroot -p     (输入密码12345678即可)
Read more »

mysql 创建 用户 授权

Posted on 2016-03-16 | Visitors

我的版本为5.7.11
下面这种方法已经不行。

insert into user(User,Host,Password) values('test','%',password('123123'));

所以只能使用另一种方法

create user 'test'@'%' identified by '123123';

查看用户

select host,user from mysql.user;

授权某数据操作给用户

grant all privileges on testDB.* to 'test'@'%';
flush privileges;

我遇到了一个问题:创建帐号之后,用密码无法登录,但不用密码可以登录(本地),远程可以登录,然后查了一下发现有两个帐号的user为空,把user为空的那两行给删掉就可以了。。

Read more »
12…22
CHC

CHC

『Everything is Possible. But Not Everything is Possible』

213 posts
164 tags
GitHub
Links
  • Changkun's Blog
  • Berlin's Website
  • Xuesong's Blog
© 2015 - 2018 CHC
Powered by Hexo
Theme - NexT.Pisces