鱼喃

听!布鲁布鲁,大鱼又在那叨叨了

一键安装脚本:pi-setup-wifi.sh

背景

3月初发布的树莓派3自带了WiFi和蓝牙,再加上它本来就有一个网口,因此俨然就是一台无线路由器了。我也忍不住入手了一个,打算用来做路由器和NAS。树莓派做路由器的教程已经有很多了,当然,基本都是基于树莓派2的,3之前的版本都没有自带WiFi,因此需要自己配无线网卡,而3自带了无线网卡,配置就方便多了。参考了两篇外文教程,成功配置,在这里记录一下。

Read more »

在导入 twitter 内容的时候,发现有部分内容会出错。开始以为是编码问题,但文本全部为 utf8 也会出现这个问题,后来定位到 emoji 字符。其原因是 utf8 是不定长的,根据左侧位来决定占用了几个字节。emoji 表情是 4 个字节,而 MySQL 的 utf8 编码最多支持 3 个字节,所以插入会出错。

Read more »

redis简介

Redis是一个开源、支持网络、基于内存、键值对存储数据库,使用ANSI C编写。从 2015 年 6 月开始,Redis 的开发由RedisLabs赞助,在2013年5月至2015年6月期间,其开发由Pivotal赞助。在2013年5月之前,其开发由VMware赞助。根据月度排行网站DB-Engines.com的数据显示,Redis是最流行的键值对存储数据库。
维基百科)

Read more »

transaction

  • MULTI … EXEC (Notice: 2 methods to handle exceptions) (1. wrong command: return wrong directly after exec) (2. wrong syntax: execute each command)
  • WATCH key [key…] (watch key(s), if these keys has been modified before transaction, abort this transaction. watch will be canceled after EXEC) (Notice: if a key is removed because of EXPIRE, watch wouldn’t regard it changed)

expires

  • EXPIRE key time (remove this key after time second(s))
  • TTL key (see how long will key be alive)
  • PERSIST key (cancel EXPIRE, GET or GETSET can also do this)

sort (result is list, n+m*log(m))

  • SORT key [ALPHA] [DESC] [LIMIT offset count] (sort set, sorted set, list by asc, if ALPHA is set, sort by directory in asc order)
  • SORT key1 BY key2:*->field (sort key by fields in key2)
  • SORT key1 BY key2:*->field GET key2:*->field [GET key3:*->field …] (sort and get field)
  • SORT key1 BY key2:*->field GET # (sort and get * itself)
  • SORT key STORE key2 (sort and store to key2)

message queue

  • BRPOP key timeout (block and RPOP, timeout is timeout, 0 for nil)
  • BRPOP queue1 [queue …] (RPOP from queue1 to nil, and then RPOP queue2, …)

pub/sub

  • PUBLISH channel message
  • SUBCRIBE channel [channel…]
  • PSUBCRIBE pattern (SUBCRIBE channel1.*) (Notice: as patterns can be various for one channel, a channel can be subscribed more than once)
  • UNSUBSCRIBE [channel …] (default is all)
  • PUNSUBSCRBE pattern1 [pattern2…] (can only cancel PSUBCRIBE pattern1) (Notice: SUBSCRIBE and PSUBCRIBE is handled differently, thus the subscribed channels has no relationship)