杜郎俊赏 - dujun.io

要熟悉一下 MongoDB 了,遇到不少坑。

2017-05-26

给文章增加了自动获取天气的功能,数据采集自中国天气网。 同时想把淘淘日记之前的天气补全,第一个念头是谁会这么无聊保存历史天气数据,结果一搜真有。互联网真有趣。

2017-05-24

建站之图标

为丰富页面,使用 webfont。 找图标(SVG)推荐网站:iconfont.cn 生成 webfont 推荐网站:icomoon.io

2017-05-21

上线挺长一段时间了,一直在重构代码,懒得写文章,作为博客来说有点本末倒置了。 看来我更喜欢写代码,而不是写文字了。 网站系统变更路线: wordpress 和 typecho 之间选择了后者来搭建 设置了 maupassant 皮肤 修改代码和样式,去除了 rss 等我不想要的功能 文章、评论等做了全站缓存 加入了图片、视频处理 推倒一切,用 yaf 重写了整站

2017-05-19

建站之 redis 纯内存运行

mysql 做永久存储,redis 做缓存。所以将 redis 设置为纯内存运行,减少开销。 编辑 /etc/redis/redis.conf,修改下列几项 #注释掉 save 项 #save 900 1 #save 300 10 #save 60 10000 #设置最多 1G 内存 maxmemory 1GB maxmemory-policy volatile-lru appendfsync no

2017-05-19

建站之视频处理

借助 ffmpeg 扩展处理视频。包括自动旋转、截图、转换格式等。 ubuntu 下安装扩展 sudo apt-get install ffmpeg 获取视频尺寸、旋转角度 /** * /usr/bin/ffprobe video.mp4 -show_streams -print_format json */ public static function info($video) { $raw = shell_exec(sprintf('%s %s -show_streams -print_format json', self::ffprobe(), $video))...

2017-05-18

建站之友好时间显示

public function format($time) { if (invalid_integer($time)) { return ''; } $now = time(); $today = strtotime(date('Y-m-d', $now)); $tmp = $now - $time; if (60 > $tmp) { return '刚刚'; } elseif (3600 > $tmp) { return floor($tmp / 60) . ' 分钟前'; }...

2017-05-18

建站之阿里云邮件推送

评论被回复时,如果评论者填了邮箱,则向其发送通知邮件。使用阿里云的邮件推送。每日免费额度 200 封。 /** * 发送阿里云邮件 */ class Util_Mail { private static $url, $accessId, $accessSecret, $account, $name; public static function send($title, $content, $receiver = null) { if (empty($title) || empty($content)) { return...

2017-05-18

建站之图片缩略图

难点在于,gif 图片直接截缩略图可能有巨大噪音,所以改为截取第一帧。 //生成缩略图 public static function createThumb($imagePath) { try { if (!($imagePath = File::exist($imagePath))) { return false; } if (is_mobile()) { //移动端生成更小的图 $path = $imagePath . '_s.jpg'...

2017-05-18

建站之图片大小调整

借助 imagemagick 扩展调整图片大小。 $maxSize = 2097152; //图片限制 2M $maxWidth = 1024; $maxHeight = 768; try { do { $imagick = new Imagick($imagePath); if ($maxSize >= $imagick->getImageLength()) { break; } if ($maxWidth < $imagick->getImageWidth()) {...

2017-05-18

分页: 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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176