Splitting a file in Linux, combining it on Windows

First lets check the md5sum:

#md5sum android-studio-bundle-162.4069837-windows.exe
0a8d2931afab56d407f4eb0ef7e54486  android-studio-bundle-162.4069837-windows.exe

Cut in into pieces:

split -b 100m android-studio-bundle-162.4069837-windows.exe

It gives pieces named xaa .. xat

I download it on Windows, combine them:

copy /b x*.* out.exe

Check the integrity:

CertUtil -hashfile out.exe MD5
MD5 hash of file out.exe:
0a 8d 29 31 af ab 56 d4 07 f4 eb 0e f7 e5 44 86
CertUtil: -hashfile command completed successfully.

You can see that the MD5 matches, so it has been transferred successfully.
I needed to do this because after transferring the huge 1.88 GB file, it failed to install while meant it was damaged while being downloaded. This way, if one of the pieces was transferred incorrectly, I could just redownload that alone.


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Install Wikimedia editor on Windows

How to install Wikimedia editor:
Install node.js
Open a command line as admin.

npm install --global --production windows-build-tools

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Using letsencrypt certbot to manually deploy SSL certificates on webmin

If server is running apache on debian 8:

sudo apt-get install python-certbot-apache -t jessie-backports
sudo certbot -d wiki.entosce.com --manual --preferred-challenges dns certonly
$sudo certbot -d wiki.entosce.com --manual --preferred-challenges dns certonly
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Obtaining a new certificate
Performing the following challenges:
dns-01 challenge for wiki.entosce.com

-------------------------------------------------------------------------------
NOTE: The IP of this machine will be publicly logged as having requested this
certificate. If you're running certbot in manual mode on a machine that is not
your server, please ensure you're okay with that.

Are you OK with your IP being logged?
-------------------------------------------------------------------------------
(Y)es/(N)o: y

-------------------------------------------------------------------------------
Please deploy a DNS TXT record under the name
_acme-challenge.wiki.entosce.com with the following value:

0MEpem0O24coudtJNfAU9zEOXaW8_nJ6oaQ1pOsOIKM

Once this is deployed,
-------------------------------------------------------------------------------
Press Enter to Continue

Once deployed, the certificates are key are listed under:
/etc/letsencrypt/live/wiki.entosce.com/

$l /etc/letsencrypt/live/wiki.entosce.com/
total 12K
drwxr-xr-x 2 root root 4.0K Jun 21 16:15 .
drwx------ 5 root root 4.0K Jun 21 16:15 ..
lrwxrwxrwx 1 root root   40 Jun 21 16:15 cert.pem -> ../../archive/wiki.entosce.com/cert1.pem
lrwxrwxrwx 1 root root   41 Jun 21 16:15 chain.pem -> ../../archive/wiki.entosce.com/chain1.pem
lrwxrwxrwx 1 root root   45 Jun 21 16:15 fullchain.pem -> ../../archive/wiki.entosce.com/fullchain1.pem
lrwxrwxrwx 1 root root   43 Jun 21 16:15 privkey.pem -> ../../archive/wiki.entosce.com/privkey1.pem
-rw-r--r-- 1 root root  543 Jun 21 16:15 README

Copy these to virtualserver root:

cp /etc/letsencrypt/live/wiki.entosce.com/*pem /home/entosce/domains/wiki.entosce.com

Now if using webmin, add these to the configuration:
Virtualmin > wiki.entosce.com > Server configuration > Manage SSL certificate > Update certificate and key:


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Install MediaWiki a self hosted wikipedia like app on your server

Install php-apcu:

sudo apt-get install php5-apcu

Now download the latest package and install it:

wget https://releases.wikimedia.org/mediawiki/1.28/mediawiki-1.28.2.tar.gz
tar xvf mediawiki-1.28.2.tar.gz
mv mediawiki-1.28.2 wiki
chown -R www.www *

Now visit yoursite.com/wiki and complete installation there.
In your shell, create a mysql database, user and grant access:

mysql -u root -p
MariaDB [(none)]> create database if not exists mydbname;
use mydbname;
create user 'dbusr'@'localhost' identified by 'password';
grant all on mydbname.* to 'dbusr'@'localhost';
FLUSH PRIVILEGES;
quit;

Now use these auth details on the site.

After installation is done, to change password:
Find user by email id:

mysql -u root -p
show databases;
use oscewiki;
show tables;
SELECT user_name FROM wikiuser WHERE user_email = [email protected]';
quit;
cd maintenance
sudo php changePassword.php --user=myusername --password=newpassword

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Setting default php version in Webmin(Virtualmin)

I found that after a routine cron based automatic update of webmin, a newly created site couldnt load php. I found that it was due to php version 7. Apparently it was broken.

To change php version for new sites:
Virtualmin > System settings > Server templates > Default settings > Edit template section > Apache website > Default PHP version

To change for an individual server:
Virtualmin > Server configuration > PHP versions

If you get a message stating “This virtual server is using the mod_php execution mode for PHP, such does not allow per-directory version selection.”:


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

How to dump your Whatsapp chat messages to a csv file

Pre-requisites:
Linux pc with java jdk installed (Does not work with oracle jdk).
adb in the path

First get your whatsapp database:
adb pull /sdcard/WhatsApp/Databases/msgstore.db.crypt12
Decrypt the file:
git clone https://gitlab.com/digitalinternals/whatsapp-crypt12.git
javac -classpath “lib/whatsapp_spongycastle.jar:.” crypt12.java
Now pull the key for whatsapp from your phone (Requires root):
adb shell
su
cp /data/data/com.whatsapp/files/key /sdcard
exit
adb pull /sdcard/key
java -cp “lib/whatsapp_spongycastle.jar:.” crypt12

sqlite3
sqlite> .open msgstore.db
sqlite> .tables
chat_list messages_fts_content
frequents messages_fts_segdir
group_participants messages_fts_segments
group_participants_history messages_links
media_refs messages_quotes
media_streaming_sidecar messages_vcards
message_thumbnails messages_vcards_jids
messages props
messages_edits receipts
messages_fts status_list
sqlite> .schema messages
sqlite> .mode csv
sqlite> .headers on


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Remove print protection from a pdf file

Some journal publishers are crazy. They dont allow printing journals in this era of open source and collaboration. The following list linux tools (also available on Windows) to remove print protection from a pdf file:

pdftk DOC-20170515-WA0030.pdf output out.pdf allow AllFeatures
WARNING: The creator of the input PDF:
   DOC-20170515-WA0030.pdf
   has set an owner password (which is not required to handle this PDF).
   You did not supply this password. Please respect any copyright.

Using qpdf:

qpdf --decrypt input.pdf output.pdf

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Sign a compiled apk for apktool

Create a key:

keytool -genkey -v -keystore my-release-key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias joel

Sign:

apksigner sign --ks my-release-key.jks --out newsigned.apk newsc.apk

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

How to flash OTA without downloading the full rom in a rooted Oneplus 3

Oneplus updater detects root and offers only the full download (around 1.3GB) even if actually need only around 70 MB if an actual OTA is downloaded. This outlines how to bypass that and install only the OTA.

The thing is you need to temporarily unroot.
Assuming you’ve installed Superuser in a systemless mode (by default it it so), your root part is in your bootloader and certain changes by the Superuser apk. The only changes in your /system is the busybox binary and bash (if you installed it).

So with a root explorer, delete busybox binary and all of its symlinks.
Go to chainfire superuser, and choose to unroot fully.
The phone will reboot.
Next, go to Settings>Apps
Wipe storage for this app.
Now check for updates. It should now download only the small update.
If you have TWRP, flash the stock recovery now, or check whether TWRP can flash the OTA (probably not).
Allow the update downloader to reboot to recovery to install the update.

Yea, I know the flow of words isnt smooth. I’m busy.


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Compile mpv player for Ubuntu from source.

mpv is the default player for latest smplayer. Since mplayer didnt work after compiling its latest version from source (see my previous post), I decided to recompile mpv.

Code:

git clone https://github.com/mpv-player/mpv-build.git
cd mpv-build/
sudo apt install libfribidi-dev libfribidi-bin yasm
./rebuild -j4
sudo ./install

Note: There may be other dependencies.
Thus I upgraded my mpv 0.14.0 to 0.25.0-26-gde225e3.


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.