python re.sub

sub(pattern, repl, string, count=0, flags=0)
    Return the string obtained by replacing the leftmost
    non-overlapping occurrences of the pattern in string by the
    replacement repl.  repl can be either a string or a callable;
    if a string, backslash escapes ...
more ...

HHKB初体验

首先庆祝一下COC冠军杯

COC冠军杯

今天的主角: HHKB

HHKB

  • 同事漂洋过海从岛国带回一个无刻版HHKB Pro2
  • 因为是无刻版,到现在都非常痛苦
  • 不记得键位,所以下面先来一个HHKB Professional 2 Layout

HHKB Professional 2 Layout

键盘设置

  • 什么?键盘还要设置?又不是鼠标还要设置PPI?
  • 是的你没有听错,这键盘就是要设置,主要是满足不同系统需要
  • HHKB Pro 2 是有一排跳线6个开关,理论上是可以有2^6==64种不同的组合
  • 先来看看跳线的模式说明

跳线模式

  • 再来看看跳线前两位模式的说明 模式说明

  • 如果看懂了这个,你也就配置好了自己的键盘

本人配置
  • 本人工作在windos环境!(对!你没有看错,就是万恶的windows!!!)
  • 跳线打开1、3、5
  • Delete键改为BackSpace键
  • 最下面一排按键为:win、alt、空格、alt、win
  • 这样基本满足在windows下面的操作

FAQ

- 如何退格?
- 使用Fn + Delete ...
more ...

python const

  • python 没有const 这样的语法,但是在项目中可能会有这样的需求?
  • 自己动手丰衣足食!!!

const.py

  • 首先创建一个const.py文件,代码如下
# -*- coding: UTF-8 -*-

'''
Last modified time: 2015-06-09 09:49:29
Edit time: 2015-06-09 09:55:07
File name: const.py
Edit by caimaoy
'''

__author__ = 'caimaoy'

class _const(object):
    class ConstError(TypeError): pass
    class ConstCaseError(TypeError): pass

    def __setattr__(self, name, value ...
more ...

python split

str.split

Help on method_descriptor:

split(...)
    S.split([sep [,maxsplit]]) -> list of strings

    Return a list of the words in the string S, using sep as the
    delimiter string.  If maxsplit is given, at most maxsplit
    splits are done. If sep is not specified or is None, any
    whitespace string ...
more ...

VIM 去掉重复行

不难理解的方法

  • 先想想思路:
    • 先排序
    • 然后去掉重复的行
  • 看看具体命令
:sort u
g/^\(.*\)\n\1$/d

下面讲解一下:

:sort u             <-- 排序
g/^\(.*\)\n\1$/d    <-- kjkj
g/            /d    <-- g命令delete 满足要求的行
  ^\(.*\)\n         <-- 一行的开始到换行
           \1$      <-- \1 是前面(.*\)的内容,也就是说和前面的行内容相等
             $      <-- 结束符,两行相等是匹配条件

一些高级vim语法的操作

参考博文

  • 先看一下命令
g/\%(^\1\n\)\@<=\(.*\)$/d
g/\v%(^\1\n)@<=(.*)$/d

看一下原本博客中的解释

g/\%(^\1\n\)\@<=\(.*\)$/d ...
more ...


pyinstaller生成exe中文路径无法运行解决方案

pyinstaller生成的exe中文路径不能运行,错误信息如下:

D:\测试>"D:\测试\caimaoy_tool.exe"
Traceback (most recent call last):
  File "<string>", line 21, in <module>
  File "D:\Python27\Lib\site-packages\PyInstaller\loader\pyi_importers.py", line
 507, in install
  File "D:\Python27\Lib\site-packages\PyInstaller\loader\pyi_importers.py", line
 156, in __init__
ImportError: Can't load frozen ...
more ...