Subsections of Command
Git CMD
Init global config
git config --list
git config --global user.name "AaronYang"
git config --global user.email aaron19940628@gmail.com
git config --global pager.branch false
git config --global pull.ff only
git --no-pager diff
change user and email (locally)
git config user.name ""
git config user.email ""
list all remote repo
git remote -v
Get specific file from remote
git archive --remote=git@github.com:<$user>/<$repo>.git <$branch>:<$source_file_path> -o <$target_source_path>
Clone specific branch
git clone -b slurm-23.02 --single-branch --depth=1 https://github.com/SchedMD/slurm.git
Update submodule
git submodule add –depth 1 https://github.com/xxx/xxxx a/b/c
git submodule update --init --recursive
Save credential
login first and then execute this
git config --global credential.helper store
Delete Branch
- Deleting a remote branch
git push origin --delete <branch> # Git version 1.7.0 or newer git push origin -d <branch> # Shorter version (Git 1.7.0 or newer) git push origin :<branch> # Git versions older than 1.7.0
- Deleting a local branch
git branch --delete <branch> git branch -d <branch> # Shorter version git branch -D <branch> # Force-delete un-merged branches
Prune remote branches
git remote prune origin
Update remote repo
git remote set-url origin http://xxxxx.git
Linux
useradd
sudo useradd <$name> -m -r -s /bin/bash -p <$password>
telnet
a command line interface for communication with a remote device or serve
telnet <$ip> <$port>
lsof (list as open files)
everything is a file
lsof <$option:value>
awk (Aho, Weinberger, and Kernighan [Names])
awk
is a scripting language used for manipulating data and generating reports.
# awk [params] 'script'
awk <$params> <$string_content>
ss (socket statistics)
view detailed information about your system’s network connections, including TCP/IP, UDP, and Unix domain sockets
ss [options]
clean files 3 days ago
find /aaa/bbb/ccc/*.gz -mtime +3 -exec rm {} \;
ssh without affect $HOME/.ssh/known_hosts
ssh -o "UserKnownHostsFile /dev/null" root@aaa.domain.com
ssh -o "UserKnownHostsFile /dev/null" -o "StrictHostKeyChecking=no" root@aaa.domain.com
sync clock
[yum|dnf] install -y chrony \
&& systemctl enable chronyd \
&& (systemctl is-active chronyd || systemctl start chronyd) \
&& chronyc sources \
&& chronyc tracking \
&& timedatectl set-timezone 'Asia/Shanghai'
set hostname
hostnamectl set-hostname develop
add remote key to other server
ssh -o "UserKnownHostsFile /dev/null" \
root@aaa.bbb.ccc \
"mkdir -p /root/.ssh && chmod 700 /root/.ssh && echo '$SOME_PUBLIC_KEY' \
>> /root/.ssh/authorized_keys && chmod 600 /root/.ssh/authorized_keys"
set -x
This will print each command to the standard error before executing it, which is useful for debugging scripts.
set -x
set -e
Exit immediately if a command exits with a non-zero status.
set -x
sed (Stream Editor)
sed <$option> <$file_path>
fdisk
list all disk
fdisk -l
create CFS file system
Use mkfs.xfs command to create xfs file system and internal log on the same disk, example is shown below:
mkfs.xfs <$path>
modprobe
program to add and remove modules from the Linux Kernel
modprobe nfs && modprobe nfsd
disown
disown
command in Linux is used to remove jobs from the job table.
disown [options] jobID1 jobID2 ... jobIDN
generate SSH key
ssh-keygen -t rsa -b 4096 -C "aaron19940628@gmail.com"
create soft link
sudo ln -sf <$install_path>/bin/* /usr/local/bin
append dir into $PATH (temporary)
export PATH="/root/bin:$PATH"
copy public key to ECS
ssh-copy-id -i ~/.ssh/id_rsa.pub root@10.200.60.53
Maven
1. build from submodule
You dont need to build from the head of project.
./mvnw clean package -DskipTests -rf :<$submodule-name>
you can find the <$submodule-name>
from submodule ’s pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.flink</groupId>
<artifactId>flink-formats</artifactId>
<version>1.20-SNAPSHOT</version>
</parent>
<artifactId>flink-avro</artifactId>
<name>Flink : Formats : Avro</name>
Then you can modify the command as
./mvnw clean package -DskipTests -rf :flink-avro
2. skip some other test
For example, you can skip RAT test by doing this:
./mvnw clean package -DskipTests '-Drat.skip=true'
Gradle
1. spotless
keep your code spotless, check more detail in https://github.com/diffplug/spotless
And the, you can execute follwoing command to format your code.
./gradlew spotlessApply
./mvnw spotless:apply
2. shadowJar
shadowjar could combine a project’s dependency classes and resources into a single jar. check https://imperceptiblethoughts.com/shadow/
./gradlew shadowJar
3. check dependency
list your project’s dependencies in tree view
./gradlew dependencies --configuration compileClasspath
./gradlew :<$module_name>:dependencies --configuration compileClasspath
Elastic Search DSL
Basic Query
Returns documents that contain an indexed value for a field
.
GET /_search
{
"query": {
"exists": {
"field": "user"
}
}
}
The following search returns documents that are missing an indexed value for the user.id
field.
GET /_search
{
"query": {
"bool": {
"must_not": {
"exists": {
"field": "user.id"
}
}
}
}
}
Returns documents that contain terms similar to the search term, as measured by a Levenshtein edit distance.
GET /_search
{
"query": {
"fuzzy": {
"filed_A": {
"value": "ki"
}
}
}
}
Returns documents that contain terms similar to the search term, as measured by a Levenshtein edit distance.
GET /_search
{
"query": {
"fuzzy": {
"filed_A": {
"value": "ki",
"fuzziness": "AUTO",
"max_expansions": 50,
"prefix_length": 0,
"transpositions": true,
"rewrite": "constant_score_blended"
}
}
}
}
rewrite:
- constant_score_boolean
- constant_score_filter
- top_terms_blended_freqs_N
- top_terms_boost_N, top_terms_N
- frequent_terms, score_delegating
Returns documents based on their IDs. This query uses document IDs stored in the _id
field.
GET /_search
{
"query": {
"ids" : {
"values" : ["2NTC5ZIBNLuBWC6V5_0Y"]
}
}
}
The following search returns documents where the filed_A
field contains a term that begins with ki
.
GET /_search
{
"query": {
"prefix": {
"filed_A": {
"value": "ki",
"rewrite": "constant_score_blended",
"case_insensitive": true
}
}
}
}
You can simplify the prefix query syntax by combining the <field>
and value
parameters.
GET /_search
{
"query": {
"prefix" : { "filed_A" : "ki" }
}
}
Returns documents that contain terms within a provided range.
GET /_search
{
"query": {
"range": {
"filed_number": {
"gte": 10,
"lte": 20,
"boost": 2.0
}
}
}
}
GET /_search
{
"query": {
"range": {
"filed_timestamp": {
"time_zone": "+01:00",
"gte": "2020-01-01T00:00:00",
"lte": "now"
}
}
}
}
Returns documents that contain terms matching a regular expression.
GET /_search
{
"query": {
"regexp": {
"filed_A": {
"value": "k.*y",
"flags": "ALL",
"case_insensitive": true,
"max_determinized_states": 10000,
"rewrite": "constant_score_blended"
}
}
}
}
Returns documents that contain an exact term in a provided field.
You can use the term query to find documents based on a precise value such as a price, a product ID, or a username.
GET /_search
{
"query": {
"term": {
"filed_A": {
"value": "kimchy",
"boost": 1.0
}
}
}
}
Returns documents that contain terms matching a wildcard pattern.
A wildcard operator is a placeholder that matches one or more characters. For example, the * wildcard operator matches zero or more characters. You can combine wildcard operators with other characters to create a wildcard pattern.
GET /_search
{
"query": {
"wildcard": {
"filed_A": {
"value": "ki*y",
"boost": 1.0,
"rewrite": "constant_score_blended"
}
}
}
}