Skip to content

Instantly share code, notes, and snippets.

ubuntu 下 chrome web app 启动器路径
~/.local/share/applications/chrome-app-list.desktop
对应着安装在其中的 app 也在同一个路径下,
chrome-xxxxxxxx-Default.desktop
@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 / 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);
@Chunlin-Li
Chunlin-Li / 11212222.md
Created November 21, 2015 14:25
tcpdump linux 下抓包工具 的使用.
tcpdump -q src port 8080    
获取已本机 8080 端口作为源的数据传输包简要信息.
-q 是 quiet, 显示简要信息.
src 指定源, 可以换成 dst 指定目的地.
port 指定端口, 如果是指定特定主机, 可以换成 host

@Chunlin-Li
Chunlin-Li / 11261223.md
Created November 26, 2015 04:33
node / javascript performance:

Performance Comparison:

node version : v4.1.2 platform: Intel I7, 16G DDR3, Ubuntu x64

Section 1

use '+' to concatenate string and variables

Section 2

@Chunlin-Li
Chunlin-Li / 171157.md
Last active January 7, 2016 05:48
nginx 使用 htpasswd 添加用户验证功能

参考文档

  1. 安装 htpasswd: sudo apt-get install apache2-utils
  2. 创建用户和密码并创建验证信息文件 : sudo htpasswd -c /etc/nginx/.htpasswd John /etc/nginx/.htpasswd 是保存用户验证信息的文件路径.
  3. 继续添加用户 : sudo htpasswd -n Tom 在 STDOUT 会输出user:password 格式的信息, 将其追加到上一步生成的配置文件中即可. 注意不要反复使用 -c 参数反复创建文件.
  4. 编辑 ngixn 配置文件, 在需要的 Block 范围中(比如 location 或 server 等)添加验证配置:
    auth_basic "Restricted";
    auth_basic_user_file /etc/nginx/.htpasswd;
@Chunlin-Li
Chunlin-Li / 5e6b4b0d325.md
Created January 7, 2016 11:23
shell 中字符串的操作

str -> shell 变量

获取字符串长度

${#str}  
expr length $str

某个字符在 str 的 index (从1开始)