0%

1. 系统缺失字体

linux上第一次安装会提示 系统缺失字体: symbol, wingdings, wingdings 2, wingdings 3, Webdings, MT Extra...

可以先试试

1
sudo apt install ttf-mscorefonts-installer

可在一下地址下载字体:

http://www.8dlive.com/post/179.html

1
2
3
4
5
6
7
8
9
# 复制字体
sudo cp * /usr/share/fonts

# 生成索引
sudo mkfontscale
sudo mkfontdir

# 更新字体缓存
sudo fc-cache

之后重新打开wps即可

2. Resources

1. 常用过滤器

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 由我解决的问题
status WAS "Resolved" by currentUser()

# 我处理过的问题
status changed by currentUser() and project != 非采购类流程

# 分配给我未解决的问题
assignee = currentUser() AND resolution = Unresolved and status != closed ORDER BY updatedDate DESC

# 我提交的还在处理中的
status in (open, "In Progress", Reopened, "开发审批通过,等待测试审批", 等待申请人直属主管审批) AND reporter in (currentUser()) ORDER BY createdDate DESC
# 或者
reporter=currentUser() OR assignee =currentUser() ORDER BY priority DESC

# CRMEP 项目 1.6.0 版本 处理中的问题
project = CRMEP AND fixVersion = 1.6.0 AND status in (open, "In Progress", Reopened)

# CRMEP 未封版的问题
project = CRMEP AND fixVersion not in releasedVersions()

# CRMEP 未封版 处理中的的问题
project = CRMEP AND fixVersion not in releasedVersions() AND resolution = Unresolved AND status != closed

# CRMEP 未封版 开发一组处理中的的问题
project = CRMEP AND fixVersion not in releasedVersions() AND resolution = Unresolved AND status != closed AND assignee in membersOf(shuyun_prj_rd1_se.list)

2. Resource

1
2
3
4
5
6
# 查看目录下最大文件
# sort -r 倒序
# head -1 只显示第一个
sudo du -s * | sort -nr | head -1

du -h --max-depth=1 | grep G | sort -n

1. 浏览器配置

连接方式有 2 种:

  1. 使用本地驱动, 浏览器位于本机, 本机需要安装浏览器驱动 chromium-driver 或者 chrome-driver
1
2
// For use with ChromeDriver:
ChromeDriver driver = new ChromeDriver(options);
  1. 调用远程浏览器, 浏览器位于其他服务器上
1
2
3
4
// For use with RemoteWebDriver:
RemoteWebDriver driver = new RemoteWebDriver(
new URL("http://localhost:4444/wd/hub"),
new ChromeOptions());

1.1. ChromOptions

  1. addArguments
    通过 String 形式添加参数,如:
  • --no-sandbox 以root权限运行
  • --start-maximized 窗口最大化
  • --disable-extensions 禁止使用插件
  • --incognito 隐身模式 在浏览结束后, 会清除浏览记录(包括一些缓存文件)
  • --disable-plugins-discover 禁止发现扩展程序.
    在某些情况下, 网站通过检测扩展能够判断出是否为非法访问
  1. addEncodedExtensions
    添加编码插件
  2. addExtensions
    添加 crx 插件
  3. getExperimentalOption
  4. setAcceptInsecureCerts
    是否接受不安全的证书
  5. setBinary
    设置浏览器位置
  6. setExperimentalOption
    配置实验性参数, 如:
    禁止加载图片的配置:
1
2
3
4
Map<String, Object> prefs = new HashMap<String, Object>();
// 1: 允许 2: 不允许
prefs.put("profile.managed_default_content_settings.images", 2);
options.setExperimentalOption("prefs", prefs);
  1. setHeadless
    无界面运行
  2. setPageLoadStrategy
  3. setProxy
  4. setUnhandledPromptBehaviour

2. 测试样例

Selenium 测试view raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;

/**
* @author raven
* @date 2018-07-02 20:45
*/
public class SeleniumTest {

@org.junit.Test
public void test() {
// Create a new instance of the Firefox driver
// Notice that the remainder of the code relies on the interface,
// not the implementation.
WebDriver driver = new ChromeDriver();
// WebDriver driver = new HtmlUnitDriver(true);
// WebDriver driver = new FirefoxDriver();

// And now use this to visit Google
driver.get("https://www.baidu.com/");
// Alternatively the same thing can be done like this
// driver.navigate().to("http://www.google.com");

// Find the text input element by its name
WebElement element = driver.findElement(By.id("kw"));

// Enter something to search for
element.sendKeys("Cheese!");

// Now submit the form. WebDriver will find the form for us from the element
element.submit();

// Check the title of the page
System.out.println("Page title is: " + driver.getTitle());

// Google's search is rendered dynamically with JavaScript.
// Wait for the page to load, timeout after 10 seconds
(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.getTitle().toLowerCase().startsWith("cheese!");
}
});

// Should see: "cheese! - Google Search"
System.out.println("Page title is: " + driver.getTitle());

//Close the browser
driver.quit();
}
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 替换全部匹配内容
sed -i 's/aaa/bbb/g' file.txt

# 查看匹配的行
sed -n '/aaa/p'

# 查看某时间段到现在的系统日志
sed -n '/May 20 17/,$p' /var/log/messages | less

sed -n '/2019-12-02 09:27/,/2019-12-02 09:30/p' logfile
sed -n '/2010-11-17 09:[0-9][0-9]:[0-9][0-9]/,/2010-11-17 16:[0-9][0-9]:[0-9][0-9]/p' logfile

# 合并连续空行
sed -e '/^$/{N;/\n$/D};' $file


# 修改内容
# 修改类似于 `ZSH_THEME="robbyrussel"` 改成 `ZSH_THEME="gnzh"`
# 这个方式必须要指定被替换部分的前后, 如下列, 前半部分: \(^ZSH_THEME=\"\) 后半部分: \(\"\$\)
sed -i "s@\(^ZSH_THEME=\"\).*\(\"\$\)@\1gnzh\2@g" ~/.zshrc_bak
# 修改类似于 ` <version>1.0-snapshot</version>`
sed -i "s@\(.*<$property_name>\).*\(</$property_name>.*\)@\1$sdk_version\2@g" $pom_file

sed -i "s/^-Xms.*/-Xms$xms_size/g" "$file"
sed -i "s/^-Xmx.*/-Xms$xmx_size/g" "$file"
sed -i "s@\(^-XX:ReservedCodeCacheSize=\).*\($\)@\1$cache_code_size\2@g" "$file"

# 删除指定行及之后的后2行
sed -i '/export NVM_DIR/,+2d' ~/.bashrc

1. Resource

https://blog.csdn.net/ha_weii/article/details/80754284

1. 多个变量复制

  1. 方式 1
1
2
3
4
5
# 注意这2个 `<` 中间有空格, 而且后面的 `<` 紧挨着 `(`
read year month day < <(echo '2018-07-11' | awk -F- '{print $1,$2,$3}')
echo "year: $year"
echo "month: $month"
echo "day: $day"
  1. 方式 2
1
2
3
4
5
6
echo "2018-07-11" | awk -F- '{print $1,$2,$3}' | while read year month day
do
echo "year: $year"
echo "month: $month"
echo "day: $day"
done

2. 打印最后一个参数

1
awk '{print $(NF)}' $file

3. 打印奇/偶数行

1
2
awk 'NR%2 == 0' $file
awk 'NR%2 == 1' $file

4. 匹配打印

1
2
# 匹配第二列形如 `my.*` 的行, 并打印第一列
docker ps | awk '($2 ~ /my.*/){print $1}'

1
2
3
# 排序去重
sort -u
uniq

1
sudo apt install -y expect