Skip to content

Instantly share code, notes, and snippets.

@Chunlin-Li
Chunlin-Li / pc
Last active July 31, 2016 14:49
xkb 配置文件 pc 和 us. 原路径 /usr/share/X11/xkb/symbols
default partial alphanumeric_keys modifier_keys
xkb_symbols "pc105" {
key <ESC> { [ Escape ] };
// The extra key on many European keyboards:
key <LSGT> { [ less, greater, bar, brokenbar ] };
// The following keys are common to all layouts.
key <BKSL> { [ backslash, bar ] };
@Chunlin-Li
Chunlin-Li / disKB.py
Last active July 21, 2016 16:59
用于自动识别外接键盘的插拔, 并完成笔记本内置键盘的停用和启用
#!/usr/bin/python
__author__ = 'jonny'
import re
import commands
import time
kbid_pattern = re.compile('(?<=id=)\d+', re.I)
masterid_pattern = re.compile('\d+(?=\)\])', re.I)
ubuntu 下 chrome web app 启动器路径
~/.local/share/applications/chrome-app-list.desktop
对应着安装在其中的 app 也在同一个路径下,
chrome-xxxxxxxx-Default.desktop
@Chunlin-Li
Chunlin-Li / versionStringCompare.java
Created June 17, 2015 10:32
版本字符串的比较
/**
* 比较两个版本。 0 :两个版本相等; 1 : version1 > version2; -1 : version1 < version2
* 仅适用于由数字和 "." 符号构成的版本号字符串。 对应正则规则 \d+(\.\d+)+
* 如果 version1 和 version 2 均为 empty 返回0 , 否则 empty 恒小于任意字符串。
*/
private static int compareVersionString(String version1, String version2) {
if(StringUtils.isEmpty(version1)) {
if(StringUtils.isEmpty(version2)){
return 0;
} else {
@Chunlin-Li
Chunlin-Li / bash-prompt.md
Created August 5, 2015 14:34
Ubuntu Linux 命令提示符 格式修改

编辑当前用户的 home 路径下的 .bashrc 文件

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
#    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '    this is default settings
     PS1='${debian_chroot:+($debian_chroot)}\u : \W\$ '     this is set the prompt to  user : currentDir$ ls
fi
@Chunlin-Li
Chunlin-Li / 10291442.sh
Created October 29, 2015 06:41
Linux 下创建一个 service. create a Linux daemon / service
#! /bin/sh
NAME=XXXXXXXXXX
DESC="XXXXXXXXXXXXXXXX"
PIDFILE="/var/run/${NAME}.pid"
LOGFILE="/var/log/${NAME}.log"
# path to the target executable file
DAEMON="/PATH/TO/EXECUTABLE/FILE"
@Chunlin-Li
Chunlin-Li / 11031130.md
Created November 3, 2015 03:49
Linux 日期 Date Command 使用 example usage date format
@Chunlin-Li
Chunlin-Li / 1141141.md
Last active November 4, 2015 06:35
Linux 压缩 compress 7z 7za gizp bzip bzip2 使用 example
# 7z
# compress
7za a -t7z compressed.txt.7z origin.txt
#decompress
7za x compressed.txt.7z

# gzip  (replace origin file)
# compress
gzip origin.txt
@Chunlin-Li
Chunlin-Li / 1151538.md
Last active December 18, 2020 03:03
Linux soft raid, mdadm md disk 软 RAID

Linux soft RAID

使用 mdadm 工具. apt-get install mdadm

用于做 RAID 的磁盘, 可以是分区并格式化之后的, 比如 sda1 sdb1 等.

所用的磁盘需要 umount 掉.

# RAID0
@Chunlin-Li
Chunlin-Li / 11111959.md
Last active November 18, 2015 03:00
javascript eval

eval(code) 直接使用时, code 中的Scope是 caller 的 scope.

如果要让 code 无法获取调用者的 scope, 需要使用间接调用( indirect call ). 注意 eval 还是能够获取 global, 并可以对其进行修改.

间接调用的常见方式:

  • (1, eval)(code)
  • var e = eval; e(code);
  • (function(e){e(code)})(eval);
  • eval.call(this, code);
  • eval('eval')(code);