1 "" Let's start VIM journey 2 set nocompatible 3 4 "" Include default settings 5 "source $VIMRUNTIME/vimrc_example.vim 6 "source $VIMRUNTIME/gvimrc_example.vim 7 8 "" shell settings 9 let $PATH="$HOME/bin;C:/msys64/usr/bin;C:/msys64/mingw64/bin;C:/Windows;C:/Windows/System32" 10 set shell=bash.exe 11 set shellslash 12 13 "" Don't need ugly files 14 set backupdir=c:/temp/vim/backup 15 set directory=c:/temp/vim/swap 16 set nobackup 17 set swapfile 18 set undodir=c:/temp/vim/undo 19 set undofile 20 set writebackup 21 22 "" UI settings 23 set cmdheight=2 24 "set guioptions-=t 25 set laststatus=2 26 set lazyredraw 27 set lines=35 columns=160 28 set number 29 set renderoptions=type:directx 30 set ruler 31 set showcmd 32 set wildmenu 33 34 "colorscheme torte 35 colorscheme koehler 36 37 "" Tab/Space related 38 set expandtab 39 set shiftwidth=4 40 set softtabstop=4 41 set tabstop=4 42 43 "" IME settings 44 if has("multi_byte") 45 set encoding=utf-8 46 "let &termencoding = &encoding 47 set termencoding=unicode 48 " Set default encoding as UTF-8 with BOM 49 setglobal fileencoding=utf-8 "bomb "bomb introduce problem for *nix 50 set fileencodings=ucs-bom,utf-8,gb18030,cp936,cp950,latin1 51 " Walkaround the encoding problem for fenc=utf-8 && enc=ucs-2 52 augroup i18n 53 autocmd! 54 autocmd BufReadPost * if &fileencoding == "utf-8" | let &encoding = &fileencoding | endif 55 augroup END 56 endif 57 58 "" Enable the Chinese characters 59 "set guifont=Fira_Code:h11:cANSI,NSimSun:h12:cGB2312 60 set guifont=Iosevka:h12:cANSI:qDRAFT ",SimHei:h12:cGB2312:qDRAFT 61 "set guifontwide=SimHei:h12:cGB2312 62 "set guifontwide=Microsoft_YaHei:h12:cGB2312 63 set guifontwide=Noto_Mono:h12:cGB2312 64 65 "" IME 66 if has('multi_byte_ime') 67 "未开启IME时光标背景色 68 hi Cursor guifg=bg guibg=Orange gui=NONE 69 "开启IME时光标背景色 70 hi CursorIM guifg=NONE guibg=Skyblue gui=NONE 71 " 关闭Vim的自动切换IME输入法(插入模式和检索模式) 72 set iminsert=0 imsearch=0 73 " 插入模式输入法状态未被记录时,默认关闭IME 74 inoremap <silent> <ESC> <ESC>:set iminsert=0<CR> 75 endif 76 77 "" Useful Plugins 78 packadd vim-fugitive 79 "" Plugin - airline 80 let g:airline_theme='solarized' 81 let g:airline_detect_iminsert=1 82 let g:airline_highlighting_cache = 1 83 let g:airline_powerline_fonts = 1 84 let g:airline#extensions#tabline#enabled = 1 85 packadd vim-airline 86 packadd vim-airline-themes 87 88 "" Plugins 89 packadd! emmet-vim 90 packadd! ctrlp.vim 91 packadd! nerdtree 92 93 "" Key Maps 94 "" display the syntax name under the cursor 95 map <F12> :echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "name")<CR> 96 "" We can navigate the list by using the <F3> and <S-F3> 97 map <F3> :cnext<CR> 98 map <S-F3> :cprevious<CR> 99 "" Let's help the tab navigation a little 100 map <F4> :try\|:next\|finish\|catch\|:tabnext\|endtry<CR> 101 map <S-F4> :bdelete<CR> 102 "" Tlist and NERDTree 103 map <F5> :NERDTreeToggle<CR> 104 map <S-F5> :Tlist<CR> 105 set tags=./tags,../tags,../../tags,../../../tags 106 "" open Terminal 107 tmap <F9> <C-W>:$tabnew +:term<CR><C-W>o 108 map <F9> :$tabnew +:term<CR><C-W>o 109 110
2018/09/03
vimrc 备份
2017/11/10
2017/09/10
LeEco Le Pro3 三方ROM不完全集合
= 国外大神团队制作的 Android N v7.1.x 的 ROM =
LineagoOS v13.0, v14.1 - http://www.lineagoos.org
三方ROM的鼻祖,历史最有旧,传承自CyanogenMod;各方面都挺完善。文档最完备。 但是WIFI EAP-TLS密钥模式无法工作download: https://download.lineageos.org/zl1
Paranoid Android - http://www.aospa.co
很优雅,WIFI EAP-TLS密钥模式可以工作。 但是对App的管控不严,而且没法手动调整,耗电比较快download: http://get.aospa.co/official/zl1
OmniRom v7.1.2 - https://omnirom.org/
总体来说是一个非常严谨的ROM, 所有功能都可用包括NFC卡模拟, 耗电控制很好, 可以通过 Security --> App Ops 来控制自启动; OmniSwitch 让人很有控制感,虽然界面有些粗糙download: http://dl.omnirom.org/zl1/
AICP v12.1 - http://www.aicp-rom.com/
定制内核, 这个还没来得及尝试!download: http://dwnld.aicp-rom.com/?device=zl1
AospExtended v4.2 - http://www.aospextended.com/
基于AOSP开发的, https://forum.xda-developers.com/le-pro3/development/rom-aospextended-rom-v4-2-t3609490 还没有尝试过download: http://downloads.aospextended.com/zl1/
ResurrectionRemix v5.8.4 - http://www.resurrectionremix.com/
基于 LineageOS, 没有尝试过!download: https://sourceforge.net/projects/resurrectionremix/files/zl1/
= 提示 =
NFC 卡模拟功能在大多数的ROM上都不行, 貌似是缺少 Smartcard Service 可以尝试这个: https://www.androidfilehost.com/?fid=673368273298973070= 其他 =
MoKee - http://www.mokeedev.com/
基于 LineageOS 添加了 XposedInstaller, 宙斯盾防启动, 自带ROOT; 中规中矩。主要是中国开发者,生存状态让人比较纠结,特别是下载 //sighMANOSP - MIUI and EMUI mod - http://www.manosp.com
微博 mandfx 小神之作, 内置了 ROOT 和 Xposed Framework。 适合那些超级爱折腾的用户download http://www.manosp.com/archives/category/letv/x720/
2017/06/03
在 MinTTY 内运行为 windows cmd 准备的程序
Git for Windows 自带的 MinTTY 是一个非常不错的命令行终端模拟器, 它是从PuTTY的代码里派生的,在MinGW32/W64 和 MSYS1/2 都有使用。 但是MinTTY对于那些为Windows Console (CMD) 定制的程序就有些行为异常。 在这种情况下 就要用到 WinPty.exe 了。
比如我在 MSYS 里面创建了一个脚本:/usr/bin/perl6 它来调用 perl6 MoarVM, 但是MoarVM 是用VC编译的,需要执行在 Windows CMD里面,脚本内容如下:
关于WinPty的更多信息: https://github.com/rprichard/winpty
Windows 上 Unix PTY 模拟程序的一些介绍: https://blog.toonormal.com/2012/11/17/gcc-msys-mintty-pdcurses-winpty-and-good-times-in-the-shell/
比如我在 MSYS 里面创建了一个脚本:/usr/bin/perl6 它来调用 perl6 MoarVM, 但是MoarVM 是用VC编译的,需要执行在 Windows CMD里面,脚本内容如下:
#!/bin/bash
/bin/winpty.exe /c/rakudo/bin/moar.exe --execname='C:\rakudo\bin\perl6.bat' --libpath="C:/rakudo/share/nqp/lib" --libpath="C:/rakudo/share/nqp/lib" --libpath="C:/rakudo/share/perl6/lib" --libpath="C:/rakudo/share/perl6/runtime" C:/rakudo/share/perl6/runtime/perl6.moarvm $*
没有 winpty.exe的话, moar.exe 和MinTTY 的交互行为就比较奇怪。关于WinPty的更多信息: https://github.com/rprichard/winpty
Windows 上 Unix PTY 模拟程序的一些介绍: https://blog.toonormal.com/2012/11/17/gcc-msys-mintty-pdcurses-winpty-and-good-times-in-the-shell/
2017/05/13
如何发现Google的所有 IP地址 / howto discover all the IP addresses of Google
Google 其实自己告诉你了, 只不过你需要掌握正确的方法来获取。
- nslookup
使用DNS 查询工具 - set server 8.8.8.8
设置 使用google的 Public DNS 服务器 - set type=txt
查询 TXT 字段 - google.com
查询 google.com - _spf.google.com
查询 网段信息 - _netblocks.google.com
2017/04/13
Emmet for Vim
Emmet for Vim - 用 Vim 开发 HTML CSS 前端的必备工具。 大幅度提高生产效率。
缺省的展开键是:
缺省的展开键是:
先按 CTRL-y 再按 ,
当然也可以通过修改: 自行修改为 CTRL-e 或者 指定其他按键!let g:user_emmet_expandabbr_key = ''
2017/04/05
我的最新的 VIMRC 文件, 备份自用!
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/gvimrc_example.vim
filetype off " required before add more bundles
set rtp+=$VIM/rust.vim
filetype plugin indent on " required
" Don't need ugly files
set nobackup
set noundofile
" Other settings
set ruler
set number
set wildmenu
set showcmd
set laststatus=2
set cmdheight=1
" Tab/Space related
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
"colorscheme oceandeep
colorscheme evening
if has("multi_byte")
set encoding=utf-8
"let &termencoding = &encoding
set termencoding=unicode
" Set default encoding as UTF-8 with BOM
setglobal fileencoding=utf-8 "bomb "bomb introduce problem for *nix
set fileencodings=ucs-bom,utf-8,gb18030,cp936,cp950,latin1
" Walkaround the encoding problem for fenc=utf-8 && enc=ucs-2
augroup i18n
autocmd!
autocmd BufReadPost * if &fileencoding == "utf-8" | let &encoding = &fileencoding | endif
augroup END
endif
" Enable the Chinese characters
set guifont=Consolas:h11:cANSI,NSimSun:h12:cGB2312
set guifontwide=NSimSun:h12:cGB2312
" IME
if has('multi_byte_ime')
"未开启IME时光标背景色
hi Cursor guifg=bg guibg=Orange gui=NONE
"开启IME时光标背景色
hi CursorIM guifg=NONE guibg=Skyblue gui=NONE
" 关闭Vim的自动切换IME输入法(插入模式和检索模式)
set iminsert=0 imsearch=0
" 插入模式输入法状态未被记录时,默认关闭IME
inoremap :set iminsert=0
endif
" Set the swap file location
set dir=c:\\temp
" display the syntax name under the cursor
map :echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "name")
" We can navigate the list by using the and
map :cnext
map :cprevious
" Let's help the tab navigation a little
map :tabprevious
map :tabnext
" Tlist
map :Tlist
set tags=./tags,../tags,../../tags,../../../tags
set path+=./,../,../../,../../../
" 设定 windows 下 gvim 启动时最大化
"if has("gui_running")
" if has("win32")
" autocmd GUIEnter * simalt ~x
" endif
"endif
2017/02/21
Add syntax highlight for your code in blogspot.com
There a lots of JavaScript syntax highlight library available, I chose highlight.js which is quite simple and straight forward in my view; and easy enough to put into your blogspot.com.
Here is the steps:
Edit your blog's template HTML by paste following codes before the </head>
For your blog poster, use
This is using the default language packs of highlight.js which support most common languages:
It is pretty simple, isn't it?
Here is the steps:
Edit your blog's template HTML by paste following codes before the </head>
<link href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/styles/railscasts.min.css" rel="stylesheet"></link>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
For your blog poster, use
<pre><code class="lang">code in lang ...</code></pre>
This is using the default language packs of highlight.js which support most common languages:
- Apache
- Bash
- C#
- C++
- CSS
- CoffeeScript
- Diff
- HTML
- XML
- HTTP
- Ini
- JSON
- Java
- JavaScript
- Makefile
- Markdown
- Nginx
- Objective-C
- PHP
- Perl
- Python
- Ruby
- SQL
and railscasts color scheme. you can goto https://highlighjs.org to find more language and color scheme.
It is pretty simple, isn't it?
$5 VPS 对比
英文原文: https://joshtronic.com/2017/02/14/five-dollar-showdown-linode-vs-digitalocean-vs-lightsaild-vs-vultr/
中文摘要: http://www.appinn.com/compare-linode-vs-digitalocean-vs-lightsail-vs-vultr/
对比了8个方面的性能; 最后, 推荐度为 Linode > DigitalOcean / Vultr > Amazon Lightsail。 现在 buyvm 的VPS也用了好几年了,是不是要考虑换换呢?
中文摘要: http://www.appinn.com/compare-linode-vs-digitalocean-vs-lightsail-vs-vultr/
对比了四家大牌 VPS 服务商
这四家服务器分别是:对比了8个方面的性能; 最后, 推荐度为 Linode > DigitalOcean / Vultr > Amazon Lightsail。 现在 buyvm 的VPS也用了好几年了,是不是要考虑换换呢?
补充
看了原文下面的评论, 提到了 https://www.ovh.com/us/vps/ OVH VPN 看起来也不错。2017/02/13
2017/01/07
2017/01/02
Perl script to convert to x Based String
#/usr/bin/perl
use strict;
use warnings;
use constant DIV => 24;
my $v = shift or die "Usage: $0 ";
my $d = 0;
my $str = '';
do {
my $c = chr(ord('A') + ($v % DIV));
$str = $c . $str;
$v = int($v / DIV)
} while ($v > 0);
print $str;
0;
2015/12/19
Easy way to prevent from GFW DNS abusing
The easiest way to distinguish the GFW DNS abusing result from real DNS responses is using iptables to block the dummy DNS response by GFW
# iptables -t mangle -I PREROUTING -s 8.8.8.8/16 -m ttl --ttl-gt 63 -j DROP
# ip6tables -t mangle -I PREROUTING -s 2001:4860:4860::8844/112 -m hl --hl-gt 52 -j DROP
2013/10/31
2013/09/04
2013/03/18
2013/01/26
PHP5 FastCGI init.d scriipt for Debian/Ubuntu
Recently, I am using Nginx + PHP5 FastCGI as the new web platform. I really need a init.d script for PHP5 FastCGI. It is not so difficult according to the skeleton.
First of all, make sure to install php5-cgi and spawn-fcgi.
First of all, make sure to install php5-cgi and spawn-fcgi.
sudo apt-get install php5-cgi spawn-fcgi
Second, create the /etc/init.d/php-fastcgi script, as below:#!/bin/sh
### BEGIN INIT INFO
# Provides: php-fastcgi
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: PHP5 FastCGI mode
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
### END INIT INFO
# Author: Yi Zhao
# Do NOT "set -e"
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="PHP5 FastCGI Service"
NAME=php5-cgi
FASTCGI_USER=www-data
FASTCGI_GROUP=www-data
SOCKET=/var/run/php-fastcgi.sock
PHP5=/usr/bin/php5-cgi
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
CHILDREN=2
DAEMON=/usr/bin/spawn-fcgi
DAEMON_ARGS="-s $SOCKET -C $CHILDREN -P $PIDFILE -u $FASTCGI_USER -g $FASTCGI_GROUP -f $PHP5"
# Exit if the package is not installed
[ -x "$DAEMON" -a -x "$PHP5" ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Load the VERBOSE setting and other rcS variables
#. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions
#
# Function that starts the daemon/service
#
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
$DAEMON_ARGS \
|| return 2
# Add code here, if necessary, that waits for the process to be ready
# to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.
}
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks
# and if the daemon is only ever run from this initscript.
# If the above conditions are not satisfied then add some other code
# that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to
# sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --name $NAME
[ "$?" = 2 ] && return 2
# Many daemons don't delete their pidfiles when they exit.
rm -f $PIDFILE
return "$RETVAL"
}
#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
#
# If the daemon can reload its configuration without
# restarting (for example, when it is sent a SIGHUP),
# then implement that here.
#
start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
return 0
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
#reload|force-reload)
#
# If do_reload() is not implemented then leave this commented out
# and leave 'force-reload' as an alias for 'restart'.
#
#log_daemon_msg "Reloading $DESC" "$NAME"
#do_reload
#log_end_msg $?
#;;
restart|force-reload)
#
# If the "reload" option is implemented then remove the
# 'force-reload' alias
#
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac
:
Add php-fastcgi into the start list
sudo update-rc.d php-fastcgi default
this will start for init level 2,3,4,5
2012/04/12
Firefox 免插件 发 新浪 weibo 大法
Firefox 具有 Smart Keywords这个功能。她让我们可以 定义一个关键字 并用这个关键字来标示一个特定的网址。 利用这个功能,我们实际上可以做很多有趣的事情,比如发Sina围脖。 具体步骤如下:
- 使用 Firefox
- 打开 baidu.com 在搜索框上点右键
- 点 "Add Keyword for this Search..."
- 这时会弹出一个对话框, 在 "Name" 项输入 "sina weibo" 其实输入什么都可以, “keyword" 可以选 wb
- 然后保存
- 用 bookmark manager 打开这个新建的 Smart Keyword, 打开 properties 属性 对话框。然后在 “Location” 里面输入 下面的代码:
javascript:(function(){f='http://v.t.sina.com.cn/share/share.php?url='+encodeURIComponent(window.location.href)+'&title=%s';a=function(){if(!window.open(f,'location=yes,links=no,scrollbars=no,toolbar=no,width=550,height=550'))location.href=f};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()
这就全部搞定了! 今后 在任何一个网页, 你只要切换到Address Bar。 可以用Ctrl+D/Ctrl+L 快速切换。 然后输入: wb 任何你想输入的文字。 回车, 这就会打开一个新的窗口/tab 提示你 围脖的内容。Over!
2011/05/06
How to create a MS Windows local account by program
There are several ways to make it happen:
- PowerShell solution: http://stackoverflow.com/questions/383390/create-local-user-with-powershell-windows-vista
- .Net solution: http://msdn.microsoft.com/en-us/library/bb384369.aspx#Y200
- Using Active Directory Service Interfaces (ADSI) COM: http://msdn.microsoft.com/en-us/library/aa705985(v=vs.85).aspx
2011/04/22
Pointers to class member functions are always interesting
This FAQ show us lot of interesting things.
订阅:
博文 (Atom)
BlockChain 相关电子书
@copyright of Sam Chadwick - https://thehub.thomsonreuters.com/groups/bitcoin/blog/2017/09/10/blockchain-paper Blockchain Papers A c...
-
Today I do update the JavaScript syntax script for VIM to 0.7.2. Until now PRC 2007.01.30-21:37 my script got: Rating 332/99, Downloaded by ...
-
This is my first VIM syntax file. Personaly, I think it is better than the Javascript syntax packaged with the VIMRUNTIME packages. Origina...
-
Win32::GuiTest is a powerful tool for Windows GUI testing. I love it! This is a small function which allow GuiTest to send Mouse Events to t...
