Skip to main content

· One min read
Hreniuc Cristian-Alexandru

Show indexes for a specific table:

SHOW INDEXES FROM TABLE_NAME;

Note: INDEX_TYPE ='HASH' is slower than INDEX_TYPE ='BTREE'

Show indexes for tables from a specific database or all databases:

SELECT *
FROM INFORMATION_SCHEMA.STATISTICS
[WHERE TABLE_SCHEMA = 'database_name'];

Add new index for a specific table:

ALTER TABLE `table_name` ADD INDEX `index_name` USING BTREE(`column1`, `column2`);

Rename table:

ALTER TABLE current_table_name RENAME new_table_name;

Show global system variables:

SHOW GLOBAL variables;

Set global variable:

SET GLOBAL long_query_time = 20;

This will have effect only if the field is dynamic, check the documentaion for each variable.

Show global status:

SHOW GLOBAL status;

Get size total size of all MEMORY tables:

SELECT (data_length+index_length)/(1024*1024*1024) table_size,
TABLE_NAME,
TABLE_SCHEMA
FROM information_schema.tables
WHERE ENGINE LIKE 'MEMORY'
ORDER BY table_size DESC;

· One min read
Hreniuc Cristian-Alexandru

This is how you can download an archive using curl:

curl -L -O https://github.com/prometheus/mysqld_exporter/releases/download/v0.11.0/mysqld_exporter-0.11.0.linux-amd64.tar.gz
  • -L - Follow redirects
  • -O - Write output to a file named as the remote file

· One min read
Hreniuc Cristian-Alexandru

Copy files from a different server and preserv file owners, permissions.

rsync -avprog user@dns:/path/scripts destination
  • a - Archive, don't know what it does
  • v - Verbose
  • p - Preserve file permissions
  • r - Reccursive
  • o - Preserve file owners Needs root
  • g - Preserve file group Needs root

· One min read
Hreniuc Cristian-Alexandru

Create a build folder for each project called project_name, which will contain multiple subfolders for each build_type.

Go to Tools -> Options -> Build & Run -> Default build directory:

/path/to/builds/%{JS: Util.asciify("%{CurrentProject:Name}/build-%{CurrentProject:Name}-%{CurrentKit:FileSystemName}-%{CurrentBuild:Name}")}

This will result in a a tree of folders:

  • builds
    • project_name
      • build-project_name-Kit_name-Build_type
    • project_name2
    • build-project_name2-Kit_name-Build_type

Or we can set it to :

/path/to/builds/%{JS: Util.asciify("%{CurrentProject:Name}/%{CurrentBuild:Name}")}

This will result in a a tree of folders:

  • builds
    • project_name
      • Release
      • Debug
    • project_name2
    • build_type

· One min read
Hreniuc Cristian-Alexandru

On the server side:

tcpdump -n -i interface -n "src host client-host.com and dst port server-port"

You can get the client host using lsof:

lsof -itcp -a -p server_pid

This will print all active tcp connections to the server app with the specific pid.

On the client side:

tcpdump -n -i interface -n "dst host server-host.com and dst port server-port"

interface can be taken via ip addr

· One min read
Hreniuc Cristian-Alexandru

How to debug using strace:

strace -s 80 -f -p 24274 2>&1 | stdbuf -i0 -o0 -e0 grep write
  • -s number - Strace usually prints only a few chars for each system call, to make it print more chars use -s number of chars
  • -f - Follow all threads opened by parent pid
  • -p pid - Pid to follow
  • 2>&1 - Reddirect stderr to stdin to be able to grep it
  • stdbuf -i0 -o0 -e0 - Flush each line to grep

· One min read
Hreniuc Cristian-Alexandru

First, download the prometheus collector from their webpage: https://github.com/prometheus/mysqld_exporter or use docker.

Next you need to add an new user in the database:

CREATE USER 'mysqld_exporter'@'%' IDENTIFIED BY 'password' WITH MAX_USER_CONNECTIONS 3;

GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'mysqld_exporter'@'%';

I used % for host of the user, to allow logging in from everywhere. I did this because I encountered some errors when I used localhost: ERRO[0026] Error pinging mysqld: dial tcp :0: connect: connection refused source="exporter.go:119"

export DATA_SOURCE_NAME='mysqld_exporter:password@(127.0.0.1:3306)/' && \
nohup ./mysqld_exporter --no-collect.info_schema.tables --no-collect.slave_status > nohup.out 2>&1 &

Use this dashboard from grafana: https://grafana.com/dashboards/7362

· One min read
Hreniuc Cristian-Alexandru

Let's say we have this diagram of servers:

A:9104 -> B -> C:9104

Connect from server A to server C via server B:

# We are here on server A and we run the following command:
ssh -N -f -L \*:9104:C:9104 user@B
# -N do not run any command on remote server
# -f run in background
# -L local forward
# \* - the 9014 port will be publically visible from outside of server A

Now to access C:9104, you will be able to do it from A like this A:9104.

Why would you want to do this? When you can't access directly the server C from server A, but you can access it from server B. And from server A you can access B. Voila!

· 5 min read
Hreniuc Cristian-Alexandru

The main source of inspiration were this thread and this thread.

The first steps are to install the specific tools on linux to be able to flash a new OS on the phone. On my PC I have Arch Linux, I had to install android-tools : sudo pacman -S android-tools

Check if the phone is rooted

Before trying to root your phone, check if it\'s not already rooted(The Chinese phones come already rooted).

To do this you need to follow this steps:

  • activate USB debugging in your phone(Developer options).
  • Connect the phone via USB(Choose File transfer when the USB popup appears on the phone)
  • Check if the device is visible in adb: adb devices, it should show a device, not an empty list.
  • Run command sudo adb reboot bootloader, this will reboot the phone in bootloader mode. Another method is to press and hold volume up and power buttons. Source: here or with images here.
  • Check if the device is visible when running sudo fastboot devices
  • Now check if the device is rooted: sudo fastboot oem device-info

After you installed android tools, you will have adb and fastboot commands available.

The command from above will generate something like this:

(bootloader)   Device tampered: false
(bootloader) Device unlocked: true
(bootloader) Device critical unlocked: true
(bootloader) Charger screen enabled: false
(bootloader) Serial console enabled: false
(bootloader) Serial hw output enabled: false
(bootloader) Display panel:

If the line Device unlocked is set to true, Ex: Device unlocked: true it means that the device is already rooted. But if you have this line: Device unlocked: falseit means that the device is not rooted.

Root the phone

The next steps should be made only if you had this line Device unlocked: false.

Start quote source: here . The next few paragraphs were copy-pasted, because I haven\'t tested them, my phone was already rooted so I didn\'t had to do these things, but I pasted them here just in case someone needs them. You can also check the original thread.

Downgrade to 01D Rom In some EUI roms you don\'t have to downgrade to 01D rom, but if you don\'t know if your rom can be unlocked or if you wanna feel more confortable and to avoid problems, is better to downgrade -firmware WIXCNFN5802005041S (see Settings > About Phone to confirm whether you\'re on this firmware or a different one... if you\'re on a different firmware on 20s, you don\'t need to downgrade) -stock 26s (if your x722 came with 26s, you need to downgrade to 01D)

you can find the file here: Download Basically: Attetion!!! This update is to be used in the official recovery, TWRP will hard brick, don\'t flash it with TWRP

  • Put update.zip file inside your sdcard
  • Reboot to recovery(steps above)
  • Click on install update, and 01D rom will be installed
  • Now you can reboot to fastboot mode and unlock your bootloader
  • In fastboot mode type fastboot oem unlock-go
  • Check if the phone is rooted with the steps from above.

Now, under Stock 20S unlocked folder you\'ll have a stock rom, cleaned, unlocked and friendly to root, you can intall in fastboot by opening flash.bat

End quote

Flash TWRP

  • Download TWRP from here
  • Boot your phone to Recovery Mode(adb reboot bootloader or Buttons Volume Up + Power pressed until something appears on the screen.)
  • Flash the twrp image: sudo fastboot flash recovery ./twrp-3.2.3-0-20181031-codeworkx-zl0.img
  • Boot again to Recovery Mode: sudo fastboot boot ./twrp-3.2.3-0-20181031-codeworkx-zl0.img(Or using the buttons like I said above). You should get the twrp menu.
  • Voila

Flash AICP and Gapps

Here is the original thread: https://forum.xda-developers.com/le-pro3/development/rom-aicp-13-0-pro3-aka-zl1-x727-x720-t3698058

  • Download the latest version of AICP
  • Download Gapps from here, choose mini or pico(the difference between them is the google apps, you can download the changelogs and compare them to see.)
  • Deactivate USB debugging
  • Copy archives on your phone via USB(you may need to connect the phone to a windows PC and install the Qualcomm USB drivers: here or here)
  • Activate USB debugging
  • Reboot into Recovery Mode(buttons or adb reboot bootloader and sudo fastboot boot ./twrp-3.2.3-0-20181031-codeworkx-zl0.img)
  • Wipe the System, Cache, Data and ART/Dalvik cache.
  • Go to install and search for your AICP archive and swipe to install it.
  • Go back to install and search for Gapps archive and swipe to install it.
  • You can flash the Magisk app here, I covered them below. It\'s better if you do them here. Short: Copy archive and install it.
  • Reboot the system(Optional: Do not install the TWRP app when asked).

Flash and install Magisk

  • Check the main thread from XDA formus and download the latest version, the zip archive.
  • Deactivate USB debugging
  • Copy it on your phone via USB(you may need to connect the phone to a windows PC and install the Qualcomm USB drivers: here or here)
  • Activate USB debugging
  • Reboot into Recovery Mode(buttons or adb reboot bootloader and sudo fastboot boot ./twrp-3.2.3-0-20181031-codeworkx-zl0.img)
  • Go to install and search for your archive, swipe to install it and reboot the system.
  • After reboot, open the Magisk app, it will ask you to install the full version, do it.
  • After everything is done, you will notice that it installed Magisk Manager app, and it removed the Magisk app.
  • Open Magisk Manager and click on install Magisk, choose the zip version, it will download it.
  • Reboot into recovery mode and install again the Magisk zip archive.
  • Reboot the system.
  • Voila.