给sunpinyin加速
因为sunpinyin词库一大就会卡,因此需要自己添加一个脚本给sunpinyin加速。
加速的原理就是把词库添加到内存,现在内存都这么大,根本不在乎这么几兆,当然输入体验更重要啦~
首先先建一个脚本实现把词库放到内存中的功能,脚本就取名为sunpinyin_speed_up吧。
#!/bin/sh # Capture the exit signal, make sure it is the FIRST uncommented line.
trap "do_exit" SIGHUP SIGINT SIGQUIT SIGTERM SUN_DIR="/home/xuzhenan/.sunpinyin"
SHM_USERDICT="/dev/shm/sunpinyin_userdict.sh0" # Backup the userdict and restore all changes made by this script on exit.
do_exit() {
cp -f "${SHM_USERDICT}" "${SUN_DIR}/userdict.real"
rm -f "${SHM_USERDICT}"
mv -f "${SUN_DIR}/userdict.real" "${SUN_DIR}/userdict"
#notify-send 'Pinyin dict' 'done'
exit
} # Work around for abnormal quit.
if [ -e "${SUN_DIR}/userdict.real" ]
then
rm -f "${SHM_USERDICT}"
mv -f "${SUN_DIR}/userdict.real" "${SUN_DIR}/userdict"
fi # Rename the real userdict, copy it to RAM and make a symblic link back.
# From now on the modification and query on userdict takes place in RAM.
mv -f "${SUN_DIR}/userdict" "${SUN_DIR}/userdict.real"
cp -f "${SUN_DIR}/userdict.real" "${SHM_USERDICT}"
ln -sf "${SHM_USERDICT}" "${SUN_DIR}/userdict" # Automatically backup the userdict, make sure not losing the modification.
p_count=
while [ true ]
do
p_count=$(($p_count+))
sleep if [ $p_count == ]
then
p_count=
cp -f "${SHM_USERDICT}" "${SUN_DIR}/userdict.real"
fi p_size_shm=$(ls -l "${SHM_USERDICT}" | awk '{print $5}')
p_size_real_t=$(ls -l "${SUN_DIR}/userdict.real" | awk '{print $5}')
p_size_real=$(($p_size_real_t+)) if [ $p_size_shm -ge $p_size_real ]
then
cp -f "${SHM_USERDICT}" "${SUN_DIR}/userdict.real"
fi
done
sunpinyin_speed_up
之后将其设置为开机启动就好了。
因为我们用systemd的方式,所以需要再写一个开机启动的服务放到/etc/systemd/system/中。
[Unit]
Description=Sunpinyin dict cache [Service]
ExecStart=/home/xuzhenan/mysh/sunpinyin_speed_up [Install]
WantedBy=multi-user.target
sunpinyin_speed_up.service
之后运行
sudo systemctl enable sunpinyin_speed_up.service
将其设置为开机自启动就好了。
给sunpinyin加速的更多相关文章
- 百度MIP移动页面加速——不只是CDN
MIP是用CDN做加速的么?准确答案是:是,但不只是. MIP全称Mobile Instant Pages,移动网页加速器,是百度提出的页面加速解决方案.MIP从前端渲染和页面网络传输两方面进行优化, ...
- 【初码干货】使用阿里云对Web开发中的资源文件进行CDN加速的深入研究和实践
提示:阅读本文需提前了解的相关知识 1.阿里云(https://www.aliyun.com) 2.阿里云CDN(https://www.aliyun.com/product/cdn) 3.阿里云OS ...
- 阿里云系列——6.给你的域名使用CDN加速(详细步骤+简单配置)
网站部署之~阿里云系列汇总 http://www.cnblogs.com/dunitian/p/4958462.html 进入管理页面:https://home.console.aliyun.com/ ...
- Signalr系列之虚拟目录详解与应用中的CDN加速实战
目录 对SignalR不了解的人可以直接移步下面的目录 SignalR系列目录 前言 前段时间一直有人问我 在用SignalR 2.0开发客服系统[系列1:实现群发通讯]这篇文章中的"/Si ...
- docker学习(2) mac中docker-machine使用vmware fusion以及配置国内镜像加速
一.前言 先回顾下上一节创建docker-machine的过程,默认情况下docker toolbox中的docker-machine使用virtual box创建虚拟机,KI首次启动时创建虚拟机的过 ...
- [转]加速Android Studio/Gradle构建
加速Android Studio/Gradle构建 android android studio gradle 已经使用Android Studio进行开发超过一年,随着项目的增大,依赖库的增多, ...
- 利用免费cdn加速webpack单页应用
回顾现状 在之前的学习过程中,react单页应用经过webpack打包之后会输出大概如下的目录结构,它就是站点的所有前端组成了: 1 2 3 4 5 6 MacBook-Pro:output ba ...
- ffmpeg实现dxva2硬件加速
这几天在做dxva2硬件加速,找不到什么资料,翻译了一下微软的两篇相关文档.这是第二篇,记录用ffmpeg实现dxva2. 第一篇翻译的Direct3D device manager,链接:http: ...
- 用CSS开启硬件加速来提高网站性能
国外一篇文章,有点意思,转载过来,准备尝试下~ 中文地址:http://www.cnblogs.com/rubylouvre/p/3471490.html 原文地址:http://blog.teamt ...
随机推荐
- html5中不再支持的元素
html5中不再支持的元素:1.acronym(建议abbr) : 定义首字母缩写2.applet(建议object): 定义 applet3.basefont(使用css控制)4.big(使用css ...
- codevs1993 草地排水(最大流)
1993 草地排水 USACO 时间限制: 2 s 空间限制: 256000 KB 题目等级 : 钻石 Diamond 题目描述 Description 在农夫约翰的农场上,每逢下雨,Bes ...
- 洛谷P1182数列分段
题目描述 对于给定的一个长度为N的正整数数列A[i],现要将其分成M(M≤N)段,并要求每段连续,且每段和的最大值最小. 关于最大值最小: 例如一数列4 2 4 5 1要分成3段 将其如下分段: [4 ...
- Akka源码分析-FSM
akka还有一个不常使用.但我觉得比较方便的一个模块,那就是FSM(有限状态机).我们知道了akka中Actor模型的具体实现之后,就会发现,Akka的actor可以非常方便的实现FSM.其实在akk ...
- phpStorm更新后配置svn无法使用
phpStorm迎来新的更新,结果之前配置的svn竟然无法使用啦,快捷键一类也没有作用.各种查找解决方案,最后找到解决方案.点击File找到Settings,找到Plugins这个部分,这个部分是管理 ...
- 知识记忆1:标志寄存器PSW
8086CPU的flag寄存器结构如下: [ ] [ ] [ ] [ ] [OF][DF][IF][TF][SF][ZF][ ][AF][ ][PF][ ][CF] 其中debug中的显示为: 标志 ...
- 51nod1446 Kirchhoff矩阵+Gauss消元+容斥+折半DFS
思路: //By SiriusRen #include <cstdio> #include <cstring> #include <algorithm> using ...
- 【CodeForces727E/CF727E】Games on a CD (字符串哈希)
题目: CodeForces727E 分析: 看到字符串比较,肯定想到哈希啊--现学的哈希,先丢两个重要的公式 (\(seed\)是大于字符集大小的质数,\(p\)是大质数) \[hash[i]=(h ...
- form表单中图片也可以当作提交按钮
点击图片按钮时,不光提交其他输入框信息,还把鼠标点击图片上的x,y坐标也传输过去了
- Emoji过滤
private static boolean isNotEmojiCharacter(char codePoint) { return (codePoint == 0x0) || (codePoint ...