Skip to main content

· One min read
Hreniuc Cristian-Alexandru

First Time Install / Clean Flash

  1. Reboot to Recovery
  2. Download the proper ZIP for your device
  3. Wipe Data/Cache/System when coming from non-AOSP ROMs
  4. Flash MIUI 11 vendor/firmware for your device variant
  5. Flash the ROM
  6. Reboot to System
  7. Reboot to Recovery
  8. Flash Magisk (Optional)
  9. Reboot to System and #KeepEvolving

Update / Dirty Flash

  1. Reboot to Recovery
  2. Download the proper ZIP for your device
  3. Flash the ROM
  4. Reboot to System and #KeepEvolving

Install tools:

 sudo apt-get install android-tools-adb android-tools-fastboot

Use sideload to flash:

sudo adb devices

sudo adb reboot recovery

Wait for recovery to load, you should end up in twrp menu. Go to Advanced -> ADB Sideload and

 adb sideload EvolutionX_4.20.1_raphael-10.0-20200417-0747-OFFICIAL.zip

# optional, update Magisk
adb sideload Magisk-v20.4.zip

Source: https://forum.xda-developers.com/k20-pro/development/rom-evolution-x-3-3-t4002669

To do:

· 2 min read
Hreniuc Cristian-Alexandru

1. Rebase ony one(or X) commits from a brach over another branch:

One commit:

git rebase --onto origin/devel branch_name~1 branch_name

Multiple commits:

git rebase --onto origin/devel branch_name~4 branch_name

2. Add a git worktree:

git worktree add --track -b new_branch_name name_of_folder_to_be_created_for_worktree branch_to_start_from

Example:

git worktree add --track -b branch_1 project_1 master

3. Checkout a single file from a specific commit:

git checkout commit_or_branch file_path

4. Overwriting local branch with remote branch:

git checkout branch
git fetch --all
git reset --hard origin/branch

be careful, this will remove any changes from your working tree!


5. Merge two branches witout checking out on the branch that me want to merge:

I want to merge the chreniuc_548 into devel.

One way to do it is this, but this does a checkout:

git checkout devel
git merge chreniuc_548

Without checking out, you can do this:

# Merge local branch foo into local branch master,
# without having to checkout master first.
# Here `.` means to use the local repository as the "remote":
git fetch . chreniuc_548:devel

# Merge remote branch origin/foo into local branch foo,
# without having to checkout foo first:
git fetch origin foo:foo

Source: https://stackoverflow.com/a/17722977


6. Push current branch:

git config --global push.default current
# Afterwards:
git push

Source: https://stackoverflow.com/questions/14031970/git-push-current-branch-shortcut


7. Aliases:

$ git config --global alias.co checkout
$ git config --global alias.br branch
$ git config --global alias.ci commit
$ git config --global alias.st status

# Afterwards:

git st

Source: https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases

Or, we can define them in .bashrc:

alias status='git status'
alias branch='git branch'
alias commit='git commit'
alias checkout='git checkout'
alias push='git push'
alias fetch='git fetch origin -p'
alias add='git add'
alias merge='git merge'

· One min read
Hreniuc Cristian-Alexandru

Build project with : -fsanitize=address -fsanitize-recover=address

Run the excutable with this enviroment variable: ASAN_OPTIONS=halt_on_error=0. Source: https://github.com/google/sanitizers/wiki/AddressSanitizer.

Ex:

ASAN_OPTIONS=halt_on_error=0 ./executable

When the address sanitizer will find a problem, it will not abort the execution of the exe as it ussualy does.

· One min read
Hreniuc Cristian-Alexandru

Where are the coredumps generated?

$ cat /proc/sys/kernel/core_pattern

/tmp/core-%e.%p.%h.%t

Before running your executable, set the limit for the coredump:

$ ulimit -c unlimited

You can add ulimit -n 99999 in your ~/.bashrc. But if you want all gui apps(qtcreator) to use it, you should also include it in your ~/.xsession:

#!/bin/bash

ulimit -n 99999

You mai also need to update the limits(only if setting the limit returns error):

sudo nano /etc/security/limits.conf

* hard nofile 99999

# --------------------

sudo nano /etc/pam.d/common-session

session required pam_limits.so

· One min read
Hreniuc Cristian-Alexandru

Start up Thunderbird, open the Config Editor (Tools -> Options -> Advanced -> General -> Config Editor), and change the mail.server.default.check_all_folders_for_new setting to true.

Or in newer versions: Thunderbird menu -> Preferences -> Preferences -> Advanced -> General -> Config Editor

Source: here

· 4 min read
Hreniuc Cristian-Alexandru

There is a tutorial here

Install filebeat:
curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.5.4-linux-x86_64.tar.gz
tar xzvf filebeat-6.5.4-linux-x86_64.tar.gz

Create the config file:

filebeat.inputs:
- type: log
enabled: true
paths:
- /mnt/projects/log_investigation/*.log
# Multiline log, it starts with: 2019-09-25 11:55:30.378|
multiline.pattern: '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}\|'
multiline.negate: true
multiline.match: after
# Just in case multiple apps are using the same logstash.
fields:
app.name: server_app


#----------------------------- Logstash output --------------------------------
output.logstash:
# Listen for logstash
hosts: ["127.0.0.1:5044"]

Test the config file:

filebeat test config -c filebeat.yml

Start filebeat:

filebeat run -c filebeat.yml

Logstash
wget https://artifacts.elastic.co/downloads/logstash/logstash-7.3.2.zip
unzip logstash-7.3.2.zip

Config file:

input {
# Filebeat port
beats {
port => 5044
}
}


filter {
grok {
# Patterns for ndc and thread
patterns_dir => ["./patterns"]
# Regex
match => { "message" => "%{TIMESTAMP_ISO8601:log_time}\|%{ISO8601_TIMEZONE:server_timezone}\|%{TZ:server_tz}\|%{HOSTNAME:server_hostname}\|%{WORD:app_name}\|%{LOGLEVEL:log_level}\|%{NDC:ndc}\|(?<logger>[A-Za-z0-9$_.]+)\|%{THREAD:thread}\|%{NUMBER:message_size}\|%{GREEDYDATA:message_logged}" }
}
# ndc will become an array:
kv {
# https://www.elastic.co/guide/en/logstash/current/plugins-filters-kv.html
# This works with values like this: "key1=value key2=value", it doesn't support "key" like we have for query.
source => "ndc"
target => "ndc_context"
# You will be able to access them like this: [ndc_context][username]"
# "ndc_context" => {
# "interface" => "client",
# "ke2" => "value",
# "username" => "chreniuc"
# },
}

# Convert to UTC(Logs may come from different servers with different timezones)
mutate {
add_field => [ "log_time_tz", "%{log_time} %{server_timezone}" ]
}
date {
# log_time_tz looks like this: 2019-09-25 11:55:30.378 -0500
match => [ "log_time_tz" , "yyyy-MM-dd HH:mm:ss.SSS Z" ]
target =>["log_time_tz"]
timezone => "UTC"
}

# Get the date in this format: dd-mm-yyyy(We will use this for the log file name)
# The log files will be per day
mutate
{
# Convert the date back to string.
convert => ["log_time_tz","string"]
}
# Extract the date
grok {
# Patterns for LOG_DATE
patterns_dir => ["./patterns"]
# 2019-10-02T21:09:45.290Z
match => { "log_time_tz" => "%{LOG_DATE:log_date}%{GREEDYDATA:ignored_log_date}" }
}

# We can remove the unwanted fields afterwards.
mutate {
remove_field => [ "log_time_tz" ]
remove_field => [ "ignored_log_date" ]
# We have the ndc context in "ndc_context" so we can avoid sending this forward.
remove_field => [ "ndc" ]
}
}

output {
# Print on console, just for debug purpose
stdout {
codec => rubydebug
}
# This is how you access nested fields
if ([ndc_context][username] != "") { # Centralise log files per user and per days from multiple servers.
file {
path => "/mnt/projects/log_investigation/out_put_logs/%{log_date}/%{[ndc_context][username]}.log"
codec => line { format => "%{message}"}
}
}

}

./patterns content:

NDC ([0-9A-Za-z=\+\-\s\_])*

THREAD 0x[0-8a-f]+

LOG_DATE [0-9]{4}\-[0-9]{2}\-[0-9]{2}

Start logstash:

logstash -f logstash.conf

Test it:

echo '2019-09-25 11:55:30.378|-0500|CST|server|server_app|INFO|interface=client|request_response|0x7f7461f38700|295|Message' >> file.log

# Multiline:

printf '2019-09-25 11:55:30.378|-0500|CST|server|server_app|INFO|interface=client username=username key2=value query|request_response|0x7f7461f38700|295|Message\ndada\ndas\n' >> file.log

The output of logstash should be:

{                                                                                                                                                                                             
"host" => {
"name" => "chreniuc-sv"
},
"input" => {
"type" => "log"
},
"thread" => "0x7f7461f38700",
"fields" => {
"app" => {
"name" => "server_app"
}
},
"logger" => "request_response",
"@timestamp" => 2019-10-02T22:41:40.464Z,
"tags" => [
[0] "beats_input_codec_plain_applied"
],
"message_logged" => "Message\ndada\ndas",
"log_time" => "2019-09-25 11:55:30.378",
"app_name" => "server_app",
"offset" => 6490,
"@version" => "1",
"server_timezone" => "-0500",
"server_hostname" => "server",
"log_date" => "2019-09-25",
"beat" => {
"name" => "chreniuc",
"hostname" => "chreniuc",
"version" => "6.5.4"
},
"log" => {
"flags" => [
[0] "multiline"
]
},
"prospector" => {
"type" => "log"
},
"server_tz" => "CST",
"message_size" => "295",
"message" => "2019-09-25 11:55:30.378|-0500|CST|server|app|INFO|interface=client username=username key2=value query|request_response|0x7f7461f38700|295|Message\n
dada\ndas",
"source" => "/mnt/projects/log_investigation/file.log",
"log_level" => "INFO",
"ndc_context" => {
"username" => "username",
"key2" => "value",
"interface" => "client"
}
}

Resources:

· One min read
Hreniuc Cristian-Alexandru

As root user:

cd /mnt
mkdir mount_folder

sshfs -o allow_other user@ip:/remote_folder /mnt/mount_folder/

# -o allow_other -> Needed so every user can see the folder.