Standard escape codes are prefixed with Escape:
- Ctrl-Key:
^[ - Octal:
\033 - Unicode:
\u001b - Hexadecimal:
\x1B - Decimal:
27
| #!/usr/bin/env bash | |
| set -eou pipefail | |
| if [ "$#" -ne 2 ]; then | |
| echo "Usage: $0 input_file output_file" | |
| exit 1 | |
| fi | |
| input_file="$1" |
| use std::str; | |
| fn main() { | |
| // -- FROM: vec of chars -- | |
| let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}']; | |
| // to String | |
| let string1: String = src1.iter().collect::<String>(); | |
| // to str | |
| let str1: &str = &src1.iter().collect::<String>(); | |
| // to vec of byte |
| // ConsoleHandler formats slog.Logger output in console format, a bit similar with Uber's zap ConsoleEncoder | |
| // The log format is designed to be human-readable. | |
| // | |
| // Performance can definitely be improved, however it's not in my priority as | |
| // this should only be used in development environment. | |
| // | |
| // e.g. log output: | |
| // 2022-11-24T11:40:20+08:00 DEBUG ./main.go:162 Debug message {"hello":"world","!BADKEY":"bad kv"} | |
| // 2022-11-24T11:40:20+08:00 INFO ./main.go:167 Info message {"with_key_1":"with_value_1","group_1":{"with_key_2":"with_value_2","hello":"world"}} | |
| // 2022-11-24T11:40:20+08:00 WARN ./main.go:168 Warn message {"with_key_1":"with_value_1","group_1":{"with_key_2":"with_value_2","hello":"world"}} |
| #!/bin/sh | |
| /usr/bin/dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.SetActive boolean:true && /usr/bin/sleep 3 && /usr/bin/dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.SetActive boolean:false |
| package main | |
| import ( | |
| "fmt" | |
| "io" | |
| "log" | |
| "net/http" | |
| "os" | |
| ) |
介绍不同分词器的文章不少,较经典的有BosonNLP 11款开放中文分词引擎大比拼
可惜这11款分词器只有IK和结巴一直在更新elastic的分词器插件,Boson的插件已经很久没更新
所以加上elastic自带的smartcn 也就只有三种分词器可选。
注1:smartcn基于中科院的ictclas 但用的是1.0, 似乎没再更新
| use std::io::prelude::*; | |
| use std::process::{Command, Stdio}; | |
| fn main() { | |
| let mut child = Command::new("ffmpeg") | |
| // Overwrite file if it already exists | |
| .arg("-y") | |
| // Interpret the information from stdin as "raw video" ... | |
| .arg("-f") | |
| .arg("rawvideo") |
| --[[ | |
| Prevent the screen from blanking while a video is playing. | |
| This script is a workaround for the GNOME+Wayland issue documented in the | |
| [Disabling Screensaver] section of the mpv manual, and depends on | |
| gnome-session-inhibit (usually provided by the gnome-session package) to set up | |
| the inhibitors. | |
| #!/bin/sh | |
| # ref https://unix.stackexchange.com/a/457902 | |
| journalctl --rotate | |
| journalctl --vacuum-time=1s |