🇭🇮, I'm huid
- 🤩 keep it simple, stupid
- 😍 love php, python, js, go
write some thing
<?php
function httGet($url) {
$opts = array(
'http' => array(
'method' => 'GET',
"header" => "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"
),
'ssl' => array(
'verify_peer' => false,
'verify_peername' => false
// Ideally use instead
// 'cafile' => 'path Certificate Authority file on local filesystem'
),
);
$context = stream_context_create($opts);
$result = file_get_contents($url, false, $context);
if ($result === false) {
return [];
}
return json_decode($result, true);
}
$url = 'https://api.github.com/repos/zhanghuid/blog/issues?page=1&per_page=300';
$data = httGet($url);
$ret = [];
foreach($data as $d1) {
$createdAt = date_create($d1['created_at'])->format('Y-m');
$ret[$createdAt][] = [
'title' => $d1['title'],
'url' => $d1['html_url']
];
}
$html = "";
$total = count($ret);
foreach ($ret as $date => $r1) {
$html .= "# {$date}" . PHP_EOL;
$html .= PHP_EOL;
$html .= PHP_EOL;
$secTotal = count($r1);
foreach ($r1 as $step => $r11) {
$html .= "- [{$r11['title']}]({$r11['url']})" . PHP_EOL;
echo "{$total}_{$secTotal}_{$step}" . PHP_EOL;
}
$html .= PHP_EOL;
}
file_put_contents('./readme.md', $html);
echo 'done';
本教程将介绍如何在SSH连接时解决有关ECDSA主机密钥的警告
建立新的SSH连接时,指纹会被缓存。因此,如果您为多台机器使用相同的IP地址,则可能会出现警告消息。
$ ssh [email protected]
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:Z90qjsBvFhvvCUFACZ53npyey4uXvjDuJl67qaTiI/A.
Please contact your system administrator.
Add correct host key in /c/Users/mixmedia/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /c/Users/mixmedia/.ssh/known_hosts:4
ECDSA host key for 192.168.33.149 has changed and you have requested strict checking.
Host key verification failed.
解决方案:
$ ssh-keygen -R 192.168.33.149
ssh [email protected]
插件id指:
1. 谷歌地址栏输入:chrome://extensions/
2. 勾选开发者模式
3. 每个插件都会出现ID
eg: ID:eimadpbcbfnmbkopoojfekhnkhdbieeh
file="/etc/apt/sources.list.bak"
if [ ! -f "$file" ]; then
echo '修改中。。。\n'
sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
block="
deb http://mirrors.cloud.tencent.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.cloud.tencent.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.cloud.tencent.com/ubuntu/ xenial-updates main restricted universe multiverse
#deb http://mirrors.cloud.tencent.com/ubuntu/ xenial-proposed main restricted universe multiverse
#deb http://mirrors.cloud.tencent.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.cloud.tencent.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.cloud.tencent.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.cloud.tencent.com/ubuntu/ xenial-updates main restricted universe multiverse
#deb-src http://mirrors.cloud.tencent.com/ubuntu/ xenial-proposed main restricted universe multiverse
#deb-src http://mirrors.cloud.tencent.com/ubuntu/ xenial-backports main restricted universe multiverse
"
sudo echo "$block" > "/tmp/sources.list"
sudo mv /tmp/sources.list /etc/apt/sources.list ##修改成功了
else
echo '已经是腾讯的了\n'
fi
apt-get clean all
apt-get update
// 先进先出
$obj = new \SplQueue();
$obj->enqueue('aaa');
$obj->enqueue('bbb');
$expected = 'aaa';
$this->assertEquals($expected, $obj->dequeue()); // 绿灯
// 后进先出
$obj = new \SplStack();
$obj->push('aaa');
$obj->push('bbb');
$obj->rewind();
$expected2 = 'bbb';
$this->assertEquals($expected2, $obj->current()); // 绿灯
CPU利用率(utilization)是指CPU在一段时间内用于做“有用功”的时间和整个这段时间的百分比值。所谓的“有用功”即CPU没有运行内核(kernel)IDLE线程,而是运行用户级(user-level)应用程序线程,或是其它的内核(kernel)线程,或是处理中断。
CPU用来执行用户级(user-level)应用程序的时间称之为user-time,而运行内核级(kernel-level)程序的时间称之为kernel-time。
计算密集型(computation-intensive)程序也许会把几乎所有的时间用来执行用户级(user-level)程序代码。而I/O密集型(I/O-intensive)程序有相当多的时间用来执行系统调用(system call),这些系统调用将会执行内核代码产生I/O。
当一个CPU利用率达到100%时,称之为饱和(saturated)。在这种情况下,线程在等待获得CPU时,将会面临调度延迟(scheduler latency)的问题。
REPOSITORY TAG IMAGE ID CREATED SIZE
dalan/php7.1 latest 1cfa4075bd78 20 minutes ago 855MB
laradock/php-fpm 2.2-7.0 71c07385bc62 3 days ago 414MB
mysql 5.7 5195076672a7 3 weeks ago 371MB
shincoder/homestead php7.1 47c8ee96a406 5 months ago 855MB
docker4w/nsenter-dockerd latest cae870735e91 5 months ago 187kB
shincoder/homestead php7.0 9d1ea3920d06 15 months ago 830MB
laraedit/laraedit latest 42d78c084a84 20 months ago 1.18GB
tutum/mariadb latest df9904aa3e74 2 years ago 366MB
Error response from daemon: conflict: unable to delete 1cfa4075bd78 (must be forced) - image is being used by stopped container f8f2d1d0a71e
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES SIZE
f8f2d1d0a71e dalan/php7.1 "/usr/bin/supervisord" 24 minutes ago Exited (0) 6 minutes ago homesteaddocker_web_1 7.62kB (virtual 855MB)
b205e0449a9d mysql:5.7 "docker-entrypoint.s…" 15 hours ago Exited (0) 6 minutes ago homesteaddocker_mysql_1 0B ( virtual 371MB)
0f36d22d4a20 shincoder/homestead:php7.1 "bash" 15 hours ago Exited (0) 15 hours ago zen_feynman 83B (virtual 855MB)
f399e73edf27 shincoder/homestead:php7.1 "bash" 16 hours ago Exited (127) 15 hours ago heuristic_leavitt 129B (virtual 855MB)
c9dcb1b14a34 laraedit/laraedit:latest "/bin/bash -c /usr/b…" 17 hours ago Exited (0) 16 hours ago laraedit 2.65 MB (virtual 1.18GB)
docker rm homesteaddocker_web_1
docker rmi dalan/php7.1
REPOSITORY TAG IMAGE ID CREATED SIZE
laradock/php-fpm 2.2-7.0 71c07385bc62 3 days ago 414MB
mysql 5.7 5195076672a7 3 weeks ago 371MB
shincoder/homestead php7.1 47c8ee96a406 5 months ago 855MB
docker4w/nsenter-dockerd latest cae870735e91 5 months ago 187kB
shincoder/homestead php7.0 9d1ea3920d06 15 months ago 830MB
laraedit/laraedit latest 42d78c084a84 20 months ago 1.18GB
tutum/mariadb latest df9904aa3e74 2 years ago 366MB
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
huid/homestead 7.0 69cd01741a9d About an hour ago 961MB
情况1:若前面在 Docker Hub 上创建了仓库,推送镜像名称必须要和 Docker Hub上的仓库名称一致
## 打标签
docker tag huid/homestead:7.0 zhanghuidee/homestead
## docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
huid/homestead 7.0 69cd01741a9d About an hour ago 961MB
zhanghuidee/homestead latest 69cd01741a9d About an hour ago 961MB
## 推送
docker push zhanghuidee/homestead
情况2:没有情况1的前提【报错:denied: requested access to the resource is denied】
docker push huid/homestead
# 1. mkdir php-composer
# 2. cd php-composer
# 3. composer init
{
"name": "huid/php-composer",
"authors": [
{
"name": "zhanghuide",
"email": "[email protected]"
}
],
"require": {}
}
# 1. create flarum project
composer create-project flarum/flarum your-path --stability=beta= -vvv
# 2. in current project root path, make dir && name called packages
cd your-path
mkdir packages && cd packages
# mkdir dir like tree
#|__vendor
#|____projectName
#|______composer.json # like first step
# example
packages
│ └── dl
│ └── login
│ ├── composer.json
│ ├── extend.php
│ ├── js
│ │ ├── admin.js
│ │ ├── forum.js
│ │ ├── package.json
│ │ ├── src
│ │ │ ├── admin
│ │ │ │ └── index.js
│ │ │ └── forum
│ │ │ └── index.js
│ │ └── webpack.config.js
│ ├── LICENSE.md
│ ├── README.md
│ ├── resources
│ │ ├── less
│ │ │ ├── admin.less
│ │ │ └── forum.less
│ │ └── locale
│ │ └── en.yml
│ └── src
│ └── Api
│ └── HelloWorldController.php
"repositories": [{
"type": "path",
"url": "packages/dl/login"
}]
composer require "dl/login @dev" -vvv
mkdir your-lib-project && cd your-lib-project
npm init
#{
# "name": "demo",
# "version": "1.0.0",
# "description": "",
# "main": "index.js",
# "scripts": {
# "test": "echo \"Error: no test specified\" && exit 1"
# },
# "author": "",
# "license": "ISC"
#}
#
npm install your-lib-project-path
# in macos
cd ~/Library/Application\ Support/picgo/
npm install /usr/home/picgo-plugin-<your-plugin-name>
1. sudo cat /var/log/syslog | grep -i rc.local
2. journalctl -e -u rc-local.service
3. systemctl status rc-local.service
sudo systemctl edit --foce frpc.service
[Unit]
Description=frpc service
After=network.target
Wants=network.target
[Service]
Type=simple
ExecStart=/usr/local/frp/frpc -c /etc/frpc.ini
Restart=on-failure
[Install]
WantedBy=multi-user.target
sudo systemctl enable frpc
file="/etc/apt/sources.list.bak"
if [ ! -f "$file" ]; then
echo '修改中。。。\n'
sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
block="
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
"
sudo echo "$block" > "/tmp/sources.list"
sudo mv /tmp/sources.list /etc/apt/sources.list ##修改成功了
else
echo '已经是阿里的了\n' ##已经是阿里的了
fi
apt-get clean all
apt-get update
大多数情况下,第一次新增的记录,在第二次会修改【体现在 修改值 跟 删除记录】,维护最新数据大体有两种方法
updated_at
字段,更新的记录的updated_at
字段的数据是当前时间,所以,只要删除旧的【time
<updated_at
】就可以了。version
字段,每次update
的时候,递增version
的值,所以,只要删除version
不是最新的就可以了window 10下的命令行界面,执行.cmd
文件的方法
F:\webpack-learning> ./node_modules/.bin/webpack.cmd
F:\webpack-learning> node_modules\.bin\webpack.cmd
第二种路径表示的话,按
tab
键是会自动补全的
"require": {
"tymon/jwt-auth": "1.0.0-rc.2"
},
// 在guards数组里配置
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'jwt',
'provider' => 'users',
],
'customer_api' => [
'driver' => 'jwt',
'provider' => 'customers',
],
],
// 在providers数组里配置
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'customers' => [
'driver' => 'eloquent',
'model' => App\Customer::class,
],
],
// jwt 中介件
class RefreshToken extends BaseMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$guard = auth()->guard('api');
$token = $request->input('token');
try {
$this->checkForToken($request); // Check presence of a token.
// 检测用户的登录状态,如果正常则通过
$id = $guard->setToken($token)->getPayload()->get('sub');
if (! $guard->byId($id)) {
throw new UnauthorizedHttpException('jwt-auth', '用户不存在');
}
return $next($request); // Token is valid. User logged. Response without any token.
} catch (TokenExpiredException $t) { // Token expired. User not logged.
// 此处捕获到了 token 过期所抛出的 TokenExpiredException 异常,我们在这里需要做的是刷新该用户的 token 并将它添加到响应头中
try {
// 刷新用户的 token
$token = $guard->refresh();
// 使用一次性登录以保证此次请求的成功
$guard->onceUsingId($guard->manager()->getPayloadFactory()->buildClaimsCollection()->toPlainArray()['sub']);
} catch (JWTException $exception) {
// 如果捕获到此异常,即代表 refresh 也过期了,用户无法刷新令牌,需要重新登录。
throw new UnauthorizedHttpException('jwt-auth', $exception->getMessage());
}
}
return $this->setAuthenticationHeader($next($request), $token); // Response with new token on header Authorization.
}
}
// customer.jwt中介件
class CustomerRefreshToken extends BaseMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$guard = auth()->guard('customer_api');
$token = $request->input('token');
try {
$this->checkForToken($request); // Check presence of a token.
// 检测用户的登录状态,如果正常则通过
$id = $guard->setToken($token)->getPayload()->get('sub');
if (! $guard->byId($id)) {
throw new UnauthorizedHttpException('jwt-auth', '用户不存在');
}
return $next($request); // Token is valid. User logged. Response without any token.
} catch (TokenExpiredException $t) { // Token expired. User not logged.
// 此处捕获到了 token 过期所抛出的 TokenExpiredException 异常,我们在这里需要做的是刷新该用户的 token 并将它添加到响应头中
try {
// 刷新用户的 token
$token = $guard->refresh();
// 使用一次性登录以保证此次请求的成功
$guard->onceUsingId($guard->manager()->getPayloadFactory()->buildClaimsCollection()->toPlainArray()['sub']);
} catch (JWTException $exception) {
// 如果捕获到此异常,即代表 refresh 也过期了,用户无法刷新令牌,需要重新登录。
throw new UnauthorizedHttpException('jwt-auth', $exception->getMessage());
}
}
return $this->setAuthenticationHeader($next($request), $token); // Response with new token on header Authorization.
}
}
// app\Http\Kernel.php
protected $routeMiddleware = [
'refresh.token' => \App\Http\Middleware\RefreshToken::class,
'refresh.customer.token' => \App\Http\Middleware\CustomerRefreshToken::class,
];
authenticate
方法public function authenticate(\Illuminate\Http\Request $request)
{
$credentials = $request->only('email', 'password'); // grab credentials from the request
try {
if (!$token = \Auth::guard('api')->attempt($credentials)) { // attempt to verify the credentials and create a token for the user
return response()->json(['error' => 'invalid_credentials'], 401);
}
} catch (JWTException $e) {
return response()->json(['error' => 'could_not_create_token'], 500); // something went wrong whilst attempting to encode the token
}
return response()->json(['token' => "Bearer $token"]);
}
authenticate
方法public function authenticate(\Illuminate\Http\Request $request)
{
$credentials = $request->only('email', 'password'); // grab credentials from the request
try {
if (!$token = \Auth::guard('customer_api')->attempt($credentials)) { // attempt to verify the credentials and create a token for the user
return response()->json(['error' => 'invalid_credentials'], 401);
}
} catch (JWTException $e) {
return response()->json(['error' => 'could_not_create_token'], 500); // something went wrong whilst attempting to encode the token
}
return response()->json(['token' => "Bearer $token"]);
}
// 第一个用户
Route::post('auth/signin', 'AuthController@authenticate');
Route::group(['middleware' => [['auth:api'], 'jwt']], function () {
// Protected routes
Route::get('user', 'IndexController@user');
});
// 第二个用户
Route::post('auth/customer/signin', 'CustomerAuthController@authenticate');
Route::group(['middleware' => ['auth:customer_api', 'customer.jwt']], function () {
// Protected routes
Route::get('customer', 'IndexController@customer');
});
这里需要注意的是:
auth:api
中间件在jwt中介件前auth:customer_api
中间件在customer.jwt
中介件前/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
if ($e instanceof UnauthorizedHttpException) { // 这里是 refresh 过期了,用户无法刷新令牌,需要重新登录。
return response()->json([
'message' => '登录已过期,请重新登录',
], 401);
}
return parent::render($request, $e);
}
[1]. 新建IndexController,并添加两个方法
public function user()
{
$user = auth()->guard('api')->user();
return $user;
}
public function customer()
{
$customer = auth()->guard('customer_api')->user();
return $customer;
}
[1]. 测试路由:http://localhost:8000/auth/signin
,得到token
[2]. 测试路由:http://localhost:8000/user
,得到user的信息。
情景:当你ssh进去容器时,你可以安装zsh,但....你stop了容器。然后你再up容器,此时你会发现,你的zsh不见了。
解决方案:
使用docker commit
# 命令
docker ps -as
# 结果
CONTAINER ID IMAGE
1811a435152a ubuntu:16.04
# 命令
docker commit (contaner-id) -m "xxx" --author "xxx" new-image-name
example: docker commit -m "add aa.txt" --author "zhanghuid" 1811a435152a demo
# 结果
CONTAINER ID IMAGE
22b8d1e20877 demo
一,情景重现
docker-compose up -d
,此时的配置文件如下web:
image: shincoder/homestead:php7.0
ssh homestead@localhost // success
3. 执行docker-compose up -d
,此时的配置文件如下
web:
image: shincoder/homestead:php7.1
ssh homestead@localhost //fail
二,解决方案:
ssh-keygen -R localhost // 这里localhost指的是远程的主机的ip
三,原因猜想:
ssh homestead@localhost
时,会在客户端跟服务端同时记录一点东西,在客户端记录为 /c/Users/huid/.ssh/known_hosts
文件下的: localhost ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBL6GQ+kHZsnKdxqKKNYyJFts0fmdsYb3AGWyBL4kkLqerFnonQVG6FuUncYpKlcBwNjQK9
wyDamugIvFhknqg7Q=
ssh homestead@localhost
时,由于之前know_hosts
文件记录的签名跟现在的不一样了。CREATE DATABASE
IF
NOT EXISTS RUNOOB DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
sudo yum install fish
You can also install Oh My Fish with Git or with an offline source tarball downloaded from the releases page:
$ git clone https://github.com/oh-my-fish/oh-my-fish
$ cd oh-my-fish
$ bin/install --offline
# with a tarball
$ curl -L https://get.oh-my.fish > install
$ fish install --offline=omf.tar.gz
if show message like : Install aborted: Git version 1.9.5 or greater required;
link
Links
解决方法:
网络和共享中心
│
└───vEthernet(DockerNAT)
│ │
│ └───Internet协议版本4(TCP/IPv4)
│ │
│ └─── 使用下面的DNS服务器地址
│ │
│ └───8.8.8.8/1.1.1.1
│
location /images/ {
alias /data/images/;
valid_referers none blocked *.xx.com xx.com;
if ($invalid_referer) {
return 403;
}
}
// 加密
$url = url(env('APP_URL') . 'api/image?hash=' . encrypt($this->image));
// 解密
$hash = \request()->input('hash');
$path = decrypt($hash);
// 渲染图片
$ext = pathinfo(storage_path($path), PATHINFO_EXTENSION);
$file = Storage::get($path);
response($file, 200)->header('Content-Type', 'image/'. $ext);
window设置
│
└───安全设置
│ │
│ └───本地策略
│ │
│ └───安全选项
│ │
│ └───网络访问:本地账户的共享跟安全模型
│ │
│ └───经典 - 对本地用户进行身份验证,不改变其本来身份
│
│
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.