给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 ...
随机推荐
- PKUACM2018 A Wife——DP
题目:http://poj.openjudge.cn/practice/C18A/ 据说正解是差分约束,转化的过程还要用到标准型.对偶型什么的知识,暂时还不太懂... 但也有贪心DP做法,有个结论:一 ...
- codeforces round #427 div2
A:读懂题,乘一下判断大小就行了 #include<bits/stdc++.h> using namespace std; int main() { int s, v1, v2, t1, ...
- nova service-list for juno kilo,liberty openstack
- Spark 操作Hive 流程
1.ubuntu 装mysql 2.进入mysql: 3.mysql>create database hive (这个将来是存 你在Hive中建的数据库以及表的信息的(也就是元数据))mysql ...
- IE版本的判断
var Sys = {};var ua = navigator.userAgent.toLowerCase(); var s;(s = ua.match(/msie ([\d.]+)/)) ? Sys ...
- 在3D中两条射线的相交性检测
摘自[3D数学基础: 图形与游戏开发] 考虑在3D中两条以参数形式定义的射线: \(\vec{r_1}(t_1)=\vec{p_1}+t_1\vec{d_1}\) \(\vec{r_2}(t_2)=\ ...
- 【转】基于linux下的变量声明declare的用法
转自:http://techcurtman.iteye.com/blog/1249512 declare 功能介绍:声明变量的属性,如果使用declare,后面没有任何参数,那么bash就会主动将所有 ...
- jsp之servlet模板问题
如果你在web项目下创建一个Servlet类,那么它会自带很多东西,比如有很多的注释,还有很多out.println()语句等.可能这些东西都不是你需要,这样看起来就会比较的令人不爽.下面的话就教大家 ...
- Java系列学习(四)-运算计算
1.运算符 (1)算术运算符 A:+,-,*,/,%,++,-- B:+的用法 [a.加法] [b.正号] [c.字符串连接付] C:/和%的区别 [数据做除法的时候,/取的是商,%取的是余数] D: ...
- 表格对象的获取和更改(原生js)
表格对象的获取 var oT = document.getElementById("tb"); //获取head console.log(oT.tHead); console.lo ...