Thursday, January 25, 2018

Downgrading LG G Pro 2 from Lollipop to KitKat

The wife recently took possession of a Xiaomi Redmi Note 4X, so her old LG G Pro 2 is mine to play around with. First order of the day is to root it. Lots of tutorials and scripts and tools around. Tried a couple of them, but didn't work. Maybe because the device has already been upgraded to stock Lollipop.

Getting impatient, I decided to use KingRoot. Big mistake. After installing and running KingRoot, it informed me that rooting was unsuccessful. Uninstalled the apk, yet KingRoot still persists. I bit the bullet, and did a factory reset. Guess what? Still there. Once in a while, I'll get a notification from Android asking if I want to disable KingRoot. I tap Yes, but it always comes back. Time for a system wipe.

The idea is to root the device, install a custom recovery, then flash a custom ROM. From what I've read in the XDA Developers forum, this is best done when the device is still on stock KitKat, which requires me to do a downgrade. Now, the problem with an "old" phone is that there are so many posts talking about the same thing, yet many of them have conflicting information. It's up to you to figure out which parts fit your situation. Worse, most of the download links to the ROMs or scripts are now broken. Either the personal domain is non-existent anymore, or the files have been taken down by the file-hosting company.

At the end of the day, I managed to get it done, and this is how I did it.

Downgrade from Stock Lollipop (D83820x) to Stock KitKat (D83810x)
Two ways to do this. Easiest way is to download a KDZ file and flash using LG Flash Tool. Here is the official procedure:
http://www.lg-phones.org/how-to-flash-unbrick-lg-g-pro-2-with-a-kdz-firmware.html

If that looks too complicated for your liking, you can try this modified flash tool from XDA:
https://forum.xda-developers.com/showthread.php?t=2797190

  1. copy KDZ file to the same folder as the flash tool
  2. power off phone
  3. hold down VolUp button, then connect phone to PC using USB cable (a.k.a. download mode)
  4. run LGFlashTool2014.exe file
  5. select KDZ file
  6. click on CSE Flash button

Normal Flash is for when you want to flash ROM without losing any data. Make sure you flash the same exact ROM as you have now, or you'll get bootloops. Used when you need to fix some system error. CSE Flash is for when you need a clean format. Obviously, all data will be wiped. Used when you need to downgrade or upgrade to stock ROM.

Next question is, where do you get the KDZ file? Lots of links on the forum, mostly dead. Well, I've got the link for you. If you're after your current ROM, use this:
http://csmg.lgmobile.com:9002/csmg/b2c/client/auth_model_check2.jsp?esn=<yourimei>
Replacing <yourimei> with your IMEI (15 digits).

You'll then be presented with the download link between the <sw_url> tags. You might also take note of the <buyer> tags, which tells you which region your phone is from.

<response req_cmd="auth_model_check" status="OK">
<auth_model_check>
<result>OK</result>
<esn>xxxxxxxxxxxxxxx</esn>
<model>LGD838</model>
<suffix>ACWTOP</suffix>
<msn>xxxxxxxxxxxxx</msn>
<esn_date/>
<sw_version>D83820B_00</sw_version>
<sw_url>
http://pkg02.cdn.gdms.lge.com/dn/downloader.dev?fileKey=xxxxxxxxxxxxxxxxxxxxxxx/D83820B_00.kdz
</sw_url>
<sw_locale_url/>
<sw_recommand_uri/>
<app_version/>
<app_url/>
<cs_em_flag>N</cs_em_flag>
<cs_em_uri>N</cs_em_uri>
<chip_type>EG</chip_type>
<prod_type>2</prod_type>
<buyer>CWT</buyer>
<file_name>D83820B_00.kdz</file_name>
</auth_model_check>
</response>

Need an older/newer KDZ from a different region/country? This link's for you:
https://lg-roms.com/LG-Firmware-List/LG%20G%20Pro%202
As of this writing, the download links still work.

The first time I ran the tool, the screens are showing gibberish. Window text is possibly in a foreign language, as I can only see question marks. Clicked a few default buttons, and the software quit. Re-ran the tool, and this time the text was in English. First try didn't work because one of the screens has one button to exit from the tool (while in the middle of flashing), which I clicked. Second try worked just fine.

If, for some reason this method didn't work, then you'll have to use flash method #2 mentioned here:
http://www.lg-phones.org/how-to-flash-lg-g-pro-2-with-a-tot-firmware.html
Similar information here:
https://forum.xda-developers.com/showthread.php?t=2475045

From there you can get download links to the flash tool, the crack, and the TOT/DLL files. That said, I wasn't able to find any working download links to the TOT/DLL files that I needed. Good thing the KDZ method worked for me.

Friday, January 19, 2018

周杰倫 - 等你下課 (with 楊瑞代)

周杰倫 - 等你下課 (with 楊瑞代)

作詞:周杰倫
作曲:周杰倫


你住的巷子裡
nǐ zhù de xiàngzi lǐ
我租了一間公寓
wǒ zūle yī jiàn gōngyù
為了想與你不期而遇
wèile xiǎng yǔ nǐ bù qī ér yù
高中三年我為什麼
gāo zhòng sān nián wǒ wèishéme
為什麼不好好讀書
wèishéme bù hǎo hǎo dúshū
沒考上跟你一樣的大學
méi kǎo shàng gēn nǐ yīyàng de dàxué

我找了份工作
wǒ zhǎole fèn gōngzuò
離你宿舍很近
lí nǐ sùshè hěn jìn
當我開始學會做蛋餅
dāng wǒ kāishǐ xuéhuì zuò dàn bǐng
才發現你不吃早餐
cái fāxiàn nǐ bù chī zǎocān
喔你又擦肩而過
ō nǐ yòu cā jiān érguò
你耳機聽什麼
nǐ ěrjī tīng shénme
能不能告訴我
néng bùnéng gàosù wǒ

躺在你學校的操場看星空
tǎng zài nǐ xuéxiào de cāochǎng kàn xīngkōng
教室裡的燈還亮著你沒走
jiàoshì lǐ de dēng hái liàngzhe nǐ méi zǒu
記得我寫給你的情書
jìdé wǒ xiě gěi nǐ de qíngshū
都什麼年代了
dōu shénme niándàile
到現在我還在寫著
dào xiànzài wǒ hái zài xiězhe
總有一天總有一年會發現
zǒng yǒuyītiān zǒng yǒuyī nián huì fāxiàn
有人默默的陪在你的身邊
yǒurén mòmò de péi zài nǐ de shēnbiān
也許我不該在你的世界
yěxǔ wǒ bù gāi zài nǐ de shìjiè
當你收到情書
dāng nǐ shōu dào qíngshū
也代表我已經走遠
yě dàibiǎo wǒ yǐjīng zǒu yuǎn

Gary:
學校旁的廣場
xuéxiào páng de guǎngchǎng
我在這等鐘聲響
wǒ zài zhè děng zhōng shēngxiǎng
等你下課一起走好嗎
děng nǐ xiàkè yīqǐ zǒu hǎo ma
Jay:
彈著琴唱你愛的歌
dànzhuó qín chàng nǐ ài de gē
暗戀一點都不痛苦
ànliàn yīdiǎn dōu bù tòngkǔ
Gary:
一點都不痛苦
yīdiǎn dōu bù tòngkǔ
Jay:
痛苦的是你
tòngkǔ de shì nǐ
合:
根本沒看我
gēnběn méi kàn wǒ
Jay:
我唱這麼走心
wǒ chàng zhème zǒu xīn
Gary:
這麼走心
zhème zǒu xīn
Jay:
卻走不進你心裡
què zǒu bù jìn nǐ xīnlǐ
Gary:
進你心裡
jìn nǐ xīnlǐ
Jay:
在人來人往
zài rén lái rén wǎng
合:
找尋著你守護著你
zhǎoxúnzhe nǐ shǒuhùzhe nǐ
不求結局
bù qiú jiéjú
合:
喔
ō
Gary:
你又擦肩
nǐ yòu cā jiān
合:
而過
érguò
Jay:
我唱告白氣球
wǒ chàng gàobái qìqiú
終於你回了頭
zhōngyú nǐ huíle tóu

躺在你學校的操場看星空
tǎng zài nǐ xuéxiào de cāochǎng kàn xīngkōng
教室裡的燈還亮著你沒走
jiàoshì lǐ de dēng hái liàngzhe nǐ méi zǒu
記得我寫給你的情書
jìdé wǒ xiě gěi nǐ de qíngshū
都什麼年代了
dōu shénme niándàile
到現在我還在寫著
dào xiànzài wǒ hái zài xiězhe
總有一天總有一年會發現
zǒng yǒu yītiān zǒng yǒu yī nián huì fāxiàn
有人默默的陪在你的身邊
yǒurén mòmò de péi zài nǐ de shēnbiān
也許我不該在你的世界
yěxǔ wǒ bù gāi zài nǐ de shìjiè
當你收到情書
dāng nǐ shōu dào qíngshū
也代表我已經走遠
yě dàibiǎo wǒ yǐjīng zǒu yuǎn

Saturday, December 30, 2017

Speeding Up an Old iPad

Was gifted a pre-loved iPad 2 (64GB, WiFi, Model A1395) in time for my kid's new school year, which requires a BYOD (bring your own device). As expected, the tablet of choice by the school is an Apple iPad. Good thing they didn't specify a particular model.

The iPad 2, with its 132 ppi resolution and 1 GHz dual-core A5 processor, is starting to show its age, but still runs fine, though a bit sluggish. Most of the "suggested" apps downloaded and installed just fine on IOS 9.3.5. A few required IOS10 or IOS11, and simply won't install. Apple's iWork productivity suite (Pages, Numbers, and Keynote) and GarageBand reported incompatibility with the iPad.

As a workaround, go to the App Store app, and tap on Purchased. Select "Not on this iPad". Select again the apps that wouldn't install. If there is an older version that is compatible with the current firmware/hardware, you will be given the option to download that instead. Managed to get the iWork apps installed this way.

Next step is to speed up the old clunker. Most obvious choice is to disable the features that you don't really need:
  • Spotlight indexing
  • App Store auto-update
  • background app refresh
  • notifications
  • multi-finger gestures
  • keyboard auto-correct, auto-capitalizaiton, check spelling
  • location services
  • perspective zoom on the home and lockscreen wallpapers
  • transparency
You can also enable reduce motion, deleted rarely-used apps to recover diskspace, upgrade to the latest IOS, and restart the iPad once in a while.

Rotating Vertical Videos

Everyone on the Internet is saying never to take videos in portrait mode (vertically). However, there are some scenarios that call for vertical videos, much like pictures that look better in portrait mode.

Thing is, once downloaded from my DSLR, those vertical videos show up as horizontal videos on my PC, with the subject lying down. Usually, I just use Freemake Video Converter to rotate them into portrait mode again. However, there are some videos that Freemake is not able to handle, for whatever reason. The MOV file loads fine, but when I click the "Edit/Play" button, the program (version 4.1.10) just quits/exits with no warning. Thanks to Google, I found a way to do the same thing using VLC.

So this is how to rotate your portrait-mode videos:

  1. Run VLC.
  2. Under Tools, selects Effects and Filters (Ctrl+E).
  3. Click on Video Effects tab, then click on Geometry sub-tab.
  4. Enable Transform, and select "Rotate by 90 degrees" from the drop-down list, and click Close. There is another option to Rotate, but this is more if you want to rotate using a specific angle, instead of the preset ones.
  5. Go back to Tools --> Preferences. Under Show settings, select All.
  6. From the left pane, select Stream output, then Sout stream, then Transcode.
  7. Under Video filter, enable Video transformation filter. Click Save.

You can test that the whole process works by playing your vertical video. It should now play right side up.

And this is how to convert the video permanently:

  1. Under Media, select Convert/Save (Ctrl+R).
  2. Add the video file you want to rotate.
  3. Click on the drop-down arrow beside the Convert/Save button and select Convert (Alt+C).
  4. Specify a destination file for the converted output.
  5. Default profile is MP4 container using H.264 video and MP3 audio. Click on the Tools icon on the right to edit the settings.
  6. Click on the Audio codec tab. Select MP3 as codec and sample rate of 48000. This is so because my original video uses PCM and 48000 sample rate, which I'd like to keep.

So far, this gives me the best results. I tried the "Keep original video track" option to preserve video quality, but in this case, the video was not rotated.


Wednesday, December 27, 2017

Grand Pacific Drive Day Out

Planned the day's itinerary using Google search. As simple as typing in "Sydney Wollongong itinerary". Next step is to put in the multiple stops in Google Maps as one trip.

First stop is the Sri Venkateswara Temple in Helensburg, around an hour's drive away. Been to this Hindu temple before, but never went in. Nothing much to it, all you need to do is to take off your footwear. High ceilings, open spaces, mats on the floor for devotees to sit on, hundred of deities all round the temple. Behind the temple is a hall for functions, and a canteen serving food for eat-in or takeaway.

Next stop is the Bald Hill Lookout. Don't make the mistake of putting in Stanwell Tops Lookout in Google Maps. It'll take you to a totally different spot. Bald Hill Lookout is where you get 180-degree panoramic view of the Illawara escarpment, the Sea Cliff Bridge and the Tasman Sea. It's also quite popular with hang gliders. The Sydney Hang Gliding Centre is just nearby. There's also a monument to Lawrence Hargrave, an Australian pioneer of flight.

Driving down Lawrence Hargrave Drive, it eventually becomes the 665-meter long Sea Cliff Bridge. Thought of taking a short bridgewalk, but all available parking spaces along the bridge are taken.
Took a right at Cliffton School Parade after the bridge and stopped at Rube Hargrave Park. There's a nice playground for the kids and a public toilet. Parking is limited, but doesn't matter as the tourists simply parked along both sides of the street. A group of Chinese tourists even took the last remaining disabled parking. None of them looked disabled to me. Across the highway is the Moronga Park. Took a short stroll on the bridge and went back, as it started to get hot.

Next stop is Austinmer Beach, about 10 minutes' drive away. There's a carpark between the beach and the drive, but it's usually full. Street parking is not much better. Lunch is basically burger, fish and chips and chicken nuggets and chips from Shells Diner. Then, it's off to the rock pools to get our feet wet. There are toilets and showers and change rooms nearby.

Original plan was to go to the Wollongong Lighthouse, then Nan Tien Temple. However, as time is running short, we decided to head straight for Kiama instead. That's another hour of driving. Got to see the blowhole in action and the lighthouse. Farmer's market is on from 3pm till 6pm, but there's absolutely no parking spot to be found nearby. Time to head home.

Monday, December 18, 2017

Mr. Robot Fight Club

So I heard some good things about Mr. Robot. Being a computer nerd, I decided to watch the series.

It starts off interesting enough. Interesting plot, quirky characters, believable hacking scenarios. Geeky cyber-security engineer saves his company's biggest client from a malicious cyber attack, and becomes entangled with a hacker group called fsociety, who wants to bring down E Corp, the world's largest conglomerate.

Thing is, the more episodes I watched, the most I felt I've seen this before.

  • Long, gloomy shots with an olive-green tint? Check.
  • The loner main character, who has bouts of depression and paranoia? Check.
  • An underground group who wants to destoy consumer debt records, so everyone gets a clean slate? Check.
  • An alter ego who occassionaly takes over and runs the show without the person's awareness?? Tyler Durden, is that you? No, it's Mr. Robot!

Needless to say, I stopped watching Mr. Robot after season one.

Friday, November 24, 2017

iA Writer - Denote Alternative

Just noticed that my Denote notes on the smartphone are not being synced back to Dropbox. I did change my Dropbox password recently, so I thought that must've been the problem.

On Denote, I don't see any option to change/update the Dropbox password, so I assume it's probably done during initial setup after installation.

I promptly uninstalled and re-installed Denote. No prompt to sync with Dropbox. While most newer apps would have a three-dot settings/overflow icon on the action bar, none can be found anywhere in the UI. Given that Denote was last updated October 2013, I'm not surprised.

Some tablets and mobiles have a bottom navigation bar, which may be used to call up the settings menu, but my Samsung Galaxy S7 does not display this. After some research, the workaround is to enable Assistant menu under Accessibility --> Dexterity and interaction. A floating icon shows up where you can call up the settings menu. From this point on, I was able to get Denote to start talking to Dropbox. However, my notes are still not showing up.

Turns out Dropbox dropped support for its v1 API on Sept 2017 in favour of v2. 2Storks, the developer of Denote, didn't update the app to make use of v2, hence sync functionality is broken. I was thinking of switching to Textfile, but turns out that that one was also not updated.

All I want is a text editor that syncs (two-way) with Dropbox. After evaluating a few apps, it came down to Monospace and iA Writer.

Despite what Monospace says, I can't find the option to sync with Dropbox. Syncing with Google Drive is a pro/paid feature. That said, I quite like the hashtag feature for file organization.

From my limited time with iA Writer, it seems to fit the bill. Syncs properly with Dropbox. Even supports Markdown. Swipe left and right to change views.

Tuesday, October 17, 2017

Check Running Process

What we'd like to do here is to check for the presence of a running process. If present, do x (echo Running). If not, do y (restart said process).

First step is typically done by running ps and doing a grep on the output for the process name (ps -ef|grep process). This merely checks for presence and not the state of the process. In the case of no match, grep will still match the original grep command, thus reporting a hit. To get around this, do an inverse-match for grep (ps -ef|grep -v grep|grep process). Another option is to use pgrep.

So you'd have something like this:
#!/bin/sh

if ps ax | grep -v grep | grep process > /dev/null
then
    echo "Running"
else
    echo "Not running. Starting."
    /opt/process/bin/process restart
fi

If you plan to run the script as a cron job, best to silence all output (/opt/process/bin/process restart &> /dev/null).
Or better yet, run the check commands as the cron job itself (every 15 minutes):
*/15 * * * * pgrep process > /dev/null || /opt/process/bin/process restart &> /dev/null

Cron, Cron Jobs, and Crontab

Cron in a Linux/Unix utility/daemon that runs tasks (cron jobs) in the background at regular intervals.
A crontab (cron table) is basically a file that contains the schedule of cron jobs to be run at specific times.

  • crontab -l to list the crontab entries
  • crontab -e to edit the crontab file
  • crontab -r to remove your crontab file

Cron entries use the following syntax:
*     *     *   *    *        command to be executed
-     -     -   -    -
|     |     |   |    |
|     |     |   |    +----- day of week (0 - 6, where Sunday=0)
|     |     |   +------- month (1 - 12)
|     |     +--------- day of month (1 - 31)
|     +----------- hour (0 - 23)
+------------- min (0 - 59)

Entry: Minute when the process will be started [0-60]
Entry: Hour when the process will be started [0-23]
Entry: Day of the month when the process will be started [1-28/29/30/31]
Entry: Month of the year when the process will be started [1-12]
Entry: Weekday when the process will be started [0-6] [0 is Sunday]

* in the minute field means command will be executed every minute.
*/10 means command will be executed every minute. This repeat pattern is not supported by all OS, so better to just use 0,10,20,30,40,50.
You can also use "-" to represent a range of values. For example, 0 1-2 * * * means command will be run at 1am and 2am only.
For readability, you can also use sun, mon, tue, wed, thu, fri, or sat for day of the week. 7 is also acceptable for Sunday.

After editing the crontab, remember to run "service crond reload" to take the new jobs into effect.

Not sure about your crontab syntax? Try crontab.guru.