分类:技术
-
使用 Docker部署我的个人博客
1
-
使用 Docker 基于 Debian 安装 Java 环境失败的解决方法1
# 安装 default-jre 需要手动创建 /usr/share/man/man1 目录 RUN mkdir -p /usr/share/man/man1 \ && apt-get update \ && apt-get install -y \ default-jre \
-
升级 Catalina 后出现 Read-only file system 问题解决方案
由于项目的根目录在
/data1
目录,需要在根目录创建data1
目录,但是提示:mkdir: data1: Read-only file system
先关闭 sip,终端输入
sudo mount -uw /
然后再创建目录或者创建软链接,即可成功!
-
Yii2 使用 Codeception 进行单元测试
测试总入口脚本:
app/tests/_bootstrap.php
入口脚本:
app/tests/unit/_bootstrap.php
参考文档: https://codeception.com/for/yii
-
Yii China 是官方唯一认可的中文社区
今天是 Yii Framework 2.0.16 版本发布 的日子,经过我们坚持不懈的进行国际化翻译,以及在中国进行大量的宣传和推广,Yii China 已经成为全球最大的 Yii 中文社区。
希望更多的 Yiiers 加入我们社区! https://www.yiichina.com
官方提供的社区推荐地址: https://github.com/yiisoft/yii2/wiki/communities#chinese
-
GitLab 实现仓库完全迁移,包括所有提交记录、分支、标签
具体命令如下:
cd <项目目录> git fetch --all git fetch --tags git remote set-url origin <项目的新仓库地址> git push origin --all git push --tags
参考文章:
https://developer.atlassian.com/blog/2016/01/totw-copying-a-full-git-repo/
-
Mac OSX 目录操作遇到 Operation not permitted 问题
今天在安装 PHP 扩展的时候发现使用 sudo 还依然提示 “Operation not permitted”。
这是由于 10.13 版本加强了权限的限制,即 rootless 机制,可以进入恢复模式关闭 rootless 机制。
官方说明:https://developer.apple.com/videos/play/wwdc2015/706/
解决方案
重启 Mac,按 Command + R(Win 键盘:win + R)进入恢复模式
打开终端,输入命令:
csrutil disable
重启后让机器正常启动,可以在终端查看 rootless 状态:
csrutil status
显示
System Integrity Protection status: disabled.
正常情况下 rootless 已经关闭。
要想重新开启 rootless 机制,参考步骤 1,输入命令:
csrutil enable
-
使用 pdflatex 生成 Yii 2 中文权威指南 PDF
问题来源
https://github.com/yiisoft-contrib/yiiframework.com/issues/142 https://en.wikibooks.org/wiki/LaTeX/Internationalization#Chinese
解决方案
https://github.com/yiisoft-contrib/yiiframework.com/blob/master/commands/GuideController.php#L85
修改为:
// https://en.wikibooks.org/wiki/LaTeX/Internationalization#Chinese // TODO this does not work yet. See https://github.com/yiisoft-contrib/yiiframework.com/issues/142 file_put_contents("$pdfTarget/main.tex", str_replace(['\usepackage[british]{babel}', '\begin{document}', '\end{document}'], ['\usepackage{CJKutf8}', '\begin{document}' . PHP_EOL . '\begin{CJK}{UTF8}{gbsn}', '\end{CJK}' . PHP_EOL . '\end{document}'], file_get_contents("$pdfTarget/main.tex")));
{gbsn}
是“宋体”,所以前提是服务器已经安装中文的“宋体”字体。 -
Yii China 性能优化之路
使用 Tengine
MySQL 缓存和 Scheme 缓存
gZip 压缩
合并 css 和 js
使用 https
使用 http2
添加 swap 分区
-
Yii 2 将 Gravatar 头像图片做本地化缓存
Gravatar 是全球公认头像,但头像图片有时候访问奇慢无比,将整个页面的加载速度降了下来,如果能将头像图片缓存到本地,并设置过期时间,那性能会飞速提高,以下代码是 Yii2 的自定义 Helper 中的代码片断,用于实现 Gravatar 本地化访问。
public function gravatar($email, $s = 80, $atts = [], $d = 'mp', $r = 'g') { $key = md5(strtolower(trim($email))); $img_file = Yii::getAlias("@webroot/uploads/avatar/$key.jpg"); $img_url = Yii::getAlias("@web/uploads/avatar/$key.jpg"); $noavatar_file = Yii::getAlias('@webroot/images/noavatar.jpg'); $noavatar_url = Yii::getAlias('@web/images/noavatar.jpg'); // 缓存时间 30 天,超过 30 天会重新到 gravatar.com 去取 if (!file_exists($img_file) || filemtime($img_file) < time() - 3600 * 24 * 30) { file_put_contents($img_file, file_get_contents("https://www.gravatar.com/avatar/$key?s=$s&d=$d&r=$r")); } // 没有设置过头像的用户,显示自定义头像 if (md5_file($img_file) == md5_file($noavatar_file)) { $img_url = $noavatar_url; } return Html::img($img_url, $atts); }
文章归档
文章日历
2024 年 04 月 | ||||||
---|---|---|---|---|---|---|
日 | 一 | 二 | 三 | 四 | 五 | 六 |
29 | 01 | 02 | 03 | 04 | 05 | 06 |
07 | 08 | 09 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
29 | 30 | 01 | 02 | 03 | 04 | 05 |
文章标签
- Linux
- Go
- Yii
- 新浪
- CentOS
- PHP
- Git
- WSL
- Composer
- Mac
- 入职
- Bootstrap
- China
- UCenter
- 厦门
- 出差
- 长沙
- 湖南卫视
- 微博
- Tengine
- YUI
- 泰国
- pecl
- 优化
- GitLab
- 迁移
- rootless
- 年会
- 生日
- Tengin
- RedHat
- Sphinx
- cygwin
- Windows
- Tmux
- Zsh
- 升级
- MySQL
- sql_mode
- Shadowsockets
- 面向对象
- HTTP
- 状态码
- grep
- unoconv
- PPT
- Nginx
- htpasswd
- golang