Yvan Zhu's blog

  • 首页

  • 关于

  • 分类

  • 归档

  • 日程表

  • 搜索

js 面试之类型检测

发表于 2021-01-11 更新于 2021-01-12 分类于 technology

js 8 种数据类型

image-20210111181230568

typeof

image-20210111180636320

instanceof

image-20210111180709997

myInstanceof

image-20210111180815057

Object.prototype.toString.call()

image-20210111181005227

通用的数据类型判断方法

image-20210111181129536

茅屋为秋风所破歌

发表于 2020-11-24 分类于 literature

杜甫

八月秋高风怒号⑴,卷我屋上三重茅⑵。茅飞渡江洒江郊,高者挂罥长林梢⑶,下者飘转沉塘坳⑷。

南村群童欺我老无力,忍能对面为盗贼⑸。公然抱茅入竹去⑹,唇焦口燥呼不得⑺,归来倚杖自叹息。

俄顷风定云墨色⑻,秋天漠漠向昏黑⑼。布衾多年冷似铁⑽,娇儿恶卧踏里裂⑾。床头屋漏无干处⑿,雨脚如麻未断绝⒀。自经丧乱少睡眠⒁,长夜沾湿何由彻⒂!

安得广厦千万间⒃,大庇天下寒士俱欢颜⒄,风雨不动安如山。呜呼⒅!何时眼前突兀见此屋⒆,吾庐独破受冻死亦足⒇!

将进酒

发表于 2020-11-24 分类于 literature

李白

君不见黄河之水天上来,奔流到海不复回。
君不见高堂明镜悲白发,朝如青丝暮成雪。
人生得意须尽欢,莫使金樽空对月。
天生我材必有用,千金散尽还复来。
烹羊宰牛且为乐,会须一饮三百杯。
岑夫子,丹丘生,将进酒,君莫停。
与君歌一曲,请君为我侧耳听。
钟鼓馔玉不足贵,但愿长醉不愿醒。
古来圣贤皆寂寞,惟有饮者留其名。
陈王昔时宴平乐,斗酒十千恣欢谑。
主人何为言少钱,径须沽取对君酌。
五花马,千金裘,呼儿将出换美酒,与尔同销万古愁。

念奴娇赤壁怀古

发表于 2020-11-24 分类于 literature

苏轼

大江东去,浪淘尽,千古风流人物。
故垒西边,人道是,三国周郎赤壁。
乱石穿空,惊涛拍岸,卷起千堆雪。(穿空 一作:崩云)
江山如画,一时多少豪杰。

遥想公瑾当年,小乔初嫁了,雄姿英发。
羽扇纶巾,谈笑间,樯橹灰飞烟灭。(樯橹 一作:强虏)
故国神游,多情应笑我,早生华发。
人生如梦,一尊还酹江月。(人生 一作:人间;尊 同:樽)

译文

大江之水滚滚不断向东流去,滔滔巨浪淘尽千古英雄人物。
那旧营垒的西边,人们说那就是三国时周郎大破曹兵的赤壁。
岸边乱石林立,像要刺破天空,惊人的巨浪拍击着江岸,激起的浪花好似千万堆白雪。
雄壮的江山奇丽如图画,一时间涌现出多少英雄豪杰。

遥想当年的周瑜春风得意,小乔刚刚嫁给了他做妻子,英姿雄健风度翩翩神采照人。
手摇羽扇头戴纶巾,谈笑之间,就把强敌的战船烧得灰飞烟灭。
如今我身临古战场神游往昔,可笑我有如此多的怀古柔情,竟如同未老先衰般鬓发斑白。
人生犹如一场梦,且洒一杯酒祭奠江上的明月。

转自:https://so.gushiwen.org/mingju/juv_2f2012ed6c86.aspx

分布式散列表

发表于 2020-09-22 分类于 未分类
  1. hashtable
  2. distributed hash table
  3. 一致性哈希
  4. kademila算法

https://www.8btc.com/article/399577
https://www.8btc.com/article/404686
https://colobu.com/2018/03/26/distributed-hash-table/

php处理postgresql图片

发表于 2020-09-10 分类于 未分类

连接pgsql数据库

1
2
3
4
5
6
7
8
9
10
11
$host        = "host=xxx";
$port = "port=5432";
$dbname = "dbname=xxx";
$credentials = "user=postgres password=xxx";

$db = pg_connect( "$host $port $dbname $credentials" );
if(!$db){
echo "Error : Unable to open database\n";
} else {
echo "Opened database successfully\n";
}

查询数据库输出图片

方法一 base64格式
1
2
3
4
5
6
7
8
9
10
11
$sql =  "SELECT id,encode(picture, 'BASE64') as picture FROM water_flow_pictures_data WHERE id=".$_GET['imgid'];

$ret = pg_query($db, $sql);
if(!$ret){
echo pg_last_error($db);
exit;
}
while($row = pg_fetch_row($ret)){
// 方法一
echo '<img src="data:image/jpg;base64,' . $row[1] .'"/>';
}
方法二
1
2
3
4
5
6
7
8
9
10
11
12
$sql =  "SELECT id,picture FROM water_flow_pictures_data WHERE id=".$_GET['imgid'];

$ret = pg_query($db, $sql);
if(!$ret){
echo pg_last_error($db);
exit;
}
while($row = pg_fetch_row($ret)){
// 方法二
header("Content-Type: image/jpeg");
echo pg_unescape_bytea($row[1]);
}

缩放后输出(也可压缩质量)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// 获取原图属性
list($width, $height, $type, $attr) = getimagesizefromstring(pg_unescape_bytea($row[1]));
$newWidth = $_GET['width']?$_GET['width']: $width;
$newHeight = $height/$width * $newWidth;

$image =imagecreatefromstring(pg_unescape_bytea($row[1]));
$quality = 0; // 图片输出质量,0 为最低


// Create a blank image and add some text
$im = imagecreatetruecolor($newWidth, $newHeight);
imagecopyresized($im,$image,0,0,0,0,$newWidth,$newHeight,$width,$height);
// $text_color = imagecolorallocate($im, 233, 14, 91);
// imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);

// Set the content type header - in this case image/jpeg
header('Content-Type: image/jpeg');

// Output the image
imagejpeg($im, null, $quality);

// Free up memory
imagedestroy($im);

关闭数据库

1
pg_close($db);

参考

https://www.php.net/manual/en/ref.image.php
https://www.runoob.com/php/php-image-gd.html

laravel学习笔记

发表于 2020-08-23 更新于 2020-09-07 分类于 未分类

migration

php artisan make:migration create_tasks_table
php artisan migrate

model

php artisan make:model User

contorller

php artisan make:controller UsersContorller –resource

windows terminal

发表于 2020-08-19 更新于 2020-08-27 分类于 未分类

安装 windows Terminal

  1. windows 应用商店安装
  2. github 下载安装

安装 powershell 7

github 下载安装

安装字体

安装字体,否则乱码
这里仅推荐一款字体:Fira Code。该字体支持 ligature 连字功能,而且是一款专门为代码显示准备的字体。该字体开源,广受海内外程序员好评!
下载地址:
https://link.zhihu.com/?target=https%3A//github.com/tonsky/FiraCode/releases/download/3.1/FiraCode_3.1.zip

配置 windows Terminal

guid 需要生成,文章末尾有生成 guid 的网站

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// 默认的配置就是我们的新 powershell(重要!!!)
"defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",

{
// Powershell 7.1.0-preview.6 配置
"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"hidden": false,
"name": "pwsh",
// -nologo 去掉启动时的logo等信息输出
"commandline": "D:/Program Files/PowerShell/7-preview/pwsh.exe -nologo",
"icon": "D:/Program Files/PowerShell/7-preview/assets/Powershell_avatar.ico",
//"source": "Windows.Terminal.PowershellCore",
// 启动菜单一定要设置为 <.>,否则后面重要的一步将会无效!
"startingDirectory": ".",
// 字体
"fontFace": "Fira Code",
"fontSize": 11,
"historySize": 9001,
"padding": "5, 5, 20, 25",
"snapOnInput": true,
"useAcrylic": false,
// 颜色方案
// "colorScheme": "Homebrew"
},

安装 powershell 插件

1
2
3
4
5
6
7
8
# 1. 安装 PSReadline 包,该插件可以让命令行很好用,类似 zsh
Install-Module -Name PSReadLine -AllowPrerelease -Force

# 2. 安装 posh-git 包,让你的 git 更好用
Install-Module posh-git -Scope CurrentUser

# 3. 安装 oh-my-posh 包,让你的命令行更酷炫、优雅
Install-Module oh-my-posh -Scope CurrentUser

添加 Powershell 启动参数

1
notepad $PROFILE
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

#------------------------------- Import Modules BEGIN -------------------------------
# 引入 posh-git
Import-Module posh-git

# 引入 oh-my-posh
Import-Module oh-my-posh

# 设置 PowerShell 主题
Set-Theme Paradox
#------------------------------- Import Modules END -------------------------------





#------------------------------- Set Hot-keys BEGIN -------------------------------
# 设置 Tab 键补全
# Set-PSReadlineKeyHandler -Key Tab -Function Complete

# 设置 Ctrl+d 为菜单补全和 Intellisense
Set-PSReadLineKeyHandler -Key "Tab" -Function MenuComplete

# 设置 Ctrl+d 为退出 PowerShell
Set-PSReadlineKeyHandler -Key "Ctrl+d" -Function ViExit

# 设置 Ctrl+z 为撤销
Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo

# 设置向上键为后向搜索历史记录
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward

# 设置向下键为前向搜索历史纪录
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
#------------------------------- Set Hot-keys END -------------------------------

参考:
https://www.cnblogs.com/Rohn/p/12940312.html
https://zhuanlan.zhihu.com/p/137595941
https://blog.csdn.net/WPwalter/article/details/100159481
字体:
https://sspai.com/post/52907
powershell 乱码,vscode 乱码 :
https://zhuanlan.zhihu.com/p/51901035
其他:
guid 生成工具
https://www.qvdv.com/tools/qvdv-guid.html

windows服务器添加远程控制用户

发表于 2020-08-18 更新于 2020-08-26 分类于 未分类

添加用户

两种方式

  1. 控制面板-用户帐户-用户帐户-管理其他帐户-添加用户账户
  2. 服务器管理器-工具-计算机管理-系统工具-本地用户和组-用户-右键新用户-记得右键设置密码

    赋予远程控制组

    两种方式
  3. 上一步第二种方法直接右键用户选属性-隶属于选项卡-添加 Remote Desktop Users 组
  4. 右键这台电脑-属性-更改设置-远程选项卡-选择用户-添加相应用户

参考:
https://blog.csdn.net/zhuge_Spring/article/details/107005114
补充:
ie增强的安全配置如何关闭
https://jingyan.baidu.com/article/ce09321b63a43c2bfe858f5f.html

状态码

发表于 2020-08-18 更新于 2020-12-01 分类于 未分类

200

200 OK 请求成功
201 Created 已创建新资源
202 Accepted 已接受但未完成(异步处理)

300

301 Moved Permanently 资源(网页等)被永久转移到其它URL
302 Temporarily Moved / Found
303 See Other

400

400 Bad Request
401 Unauthorized 请求要求用户的身份认证
403 Forbidden 服务器理解请求客户端的请求,但是拒绝执行此请求
404 Not Found 请求的资源(网页等)不存在
406 Not Acceptable
409 Conflict
412 Precondition Failed
415 Unsupported Media Type

500

500 Internal Server Error 内部服务器错误
503 Service Unavailable

参考:
https://www.runoob.com/http/http-status-codes.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
100 "continue"
101 "switching protocols"
102 "processing"
200 "ok"
201 "created"
202 "accepted"
203 "non-authoritative information"
204 "no content"
205 "reset content"
206 "partial content"
207 "multi-status"
208 "already reported"
226 "im used"
300 "multiple choices"
301 "moved permanently"
302 "found"
303 "see other"
304 "not modified"
305 "use proxy"
307 "temporary redirect"
308 "permanent redirect"
400 "bad request"
401 "unauthorized"
402 "payment required"
403 "forbidden"
404 "not found"
405 "method not allowed"
406 "not acceptable"
407 "proxy authentication required"
408 "request timeout"
409 "conflict"
410 "gone"
411 "length required"
412 "precondition failed"
413 "payload too large"
414 "uri too long"
415 "unsupported media type"
416 "range not satisfiable"
417 "expectation failed"
418 "I'm a teapot"
422 "unprocessable entity"
423 "locked"
424 "failed dependency"
426 "upgrade required"
428 "precondition required"
429 "too many requests"
431 "request header fields too large"
500 "internal server error"
501 "not implemented"
502 "bad gateway"
503 "service unavailable"
504 "gateway timeout"
505 "http version not supported"
506 "variant also negotiates"
507 "insufficient storage"
508 "loop detected"
510 "not extended"
511 "network authentication required"

参考:https://koa.bootcss.com/#response

12…14

Yvan Zhu

131 日志
18 分类
33 标签
GitHub E-Mail Weibo oschina
友情链接
  • 卡拉搜索
标签云
AD Mac PostgreSQL apache arcgis centos composer config docker dog english git idea java javascript js life list map mariaDB mysql npm php pm2 project question redis shell video vue yarn 低自我价值 跨域
京ICP备17034022号-3 © 2017 – 2021 Yvan Zhu
|
0%