How to install Cyanogenmod 13 on LG G2 (d802)

I’ve been a fan of Cyanogenmod since 2012 when I installed it on my HTC Hero. The Hero went and the LG G2 came, which I used for some time with the stock ROM, but I knew the time for Cyanogenmod would come. After using CM12 for some time I wanted to try installing CM13 again. My original problem was that I would be stuck in a bootloop when using CM13. After a while I found that this was caused by using the wrong bootloader, and I installed a “hybrid” bootstack from this source:

http://forum.xda-developers.com/lg-g2/development/boot-g2-hybrid-bootstacks-t3183219

After that I rebooted into recovery and flashed the bootstack, CM13, and the Google apps all in a row. CM13 was working, yay! Unfortunately my recovery wasn’t working anymore. It seems that with this bootstack, you need a “bumped” recovery. I just assumed that the default recovery would be bumped, but I was mistaken.

Before I proceeded to get a working recovery again, I decided to do a backup of my otherwise working and already set up system following  this guide:

http://forum.xda-developers.com/showthread.php?t=1818321

In the guide it mentions that you need Busybox, but you don’t need it if you run Cyanogenmod 12. I run the backup then with the following commands:

Shell 1:

adb forward tcp:5555 tcp:5555
adb shell
su
nc -l -p 5555 dd if=/dev/block/mmcblk0

Note that I ommited the “-e” option since it gave me an error.

Shell 2:

adb forward tcp:5555 tcp:5555
cd /path/to/store/the/backup
nc 127.0.0.1 5555 | pv -i 0.5 > mmcblk0.raw

This backup worked quite nice (as it seems), but it took the whole night to complete. Plus, I have no idea how this should be recovered. I’ll have to check that thread in that case.

Now, back to my original problem. I couldn’t boot into recovery due to the following error message:

ERROR: boot certification verify
 [690] ---------------------------------------
 [740] 
 [...] Secure booting Error!
 [...] Cause: boot certification verify
 [...]
 [...] ---------------------------------------

I tried flashing a new TWRP recovery (3.0.2-1 from blastagator) as provided in this thread:

http://forum.xda-developers.com/lg-g2/development/twrp-twrp-2-8-0-0-kernel-f2fs-tools-t2898705

Since my recovery was broken, I couldn’t use that one to flash it. I tried flashify, but it didn’t work. Then I installed the Cyanogenmod recovery (which worked), but I couldn’t flash blastagator’s recovery from there either due to a failure in signature verification.

Well, that’s the end for now I guess: I have a working basic recovery (without backup options), so for now I’m happy with a working Cyanogenmod 13 and just did a first backup with Online Nandroid .

PayPal REST SDK for Ruby:

Just for the record: I saw on some official PayPal site the use of “PayPal::SDK::Merchant” encouraged. Don’t do that, it’s highly outdated.

If you’ve successfully executed a payment, you can get the shipping address by loading the payment object once again and then calling @payment.payer.payer_info.shipping_address. The “inspect” method is your friend here!

Picking a random (Chinese) character in ruby

Here’s a simple way to choose a random Chinese character in ruby:

[*"\u4E00".."\u9FFF"].sample(1)

The asterisk expands the range, and “sample(1)” gives you one of the entries.

The unicode block 4E00 to 9FFF contains more than 20000 Chinese characters. If that’s not enough for you, you can find more code blocks here: https://en.wikipedia.org/wiki/CJK_Unified_Ideographs

Shoutout to http://yankist.com/blog/2012/11/28/generate-random-string-in-ruby/ for the many versions on how to create a random string.

I need this random Chinese character for my Factory Girl. She’ll create a new Hanzi everytime I call “let”:

let(:hanzi) { FactoryGirl.create(:hanzi) }

This is my Hanzi factory:

factory :hanzi do
sequence(:character) { |n| [*"\u4E00".."\u9FFF"].sample(1).join("") }
sequence(:components) { |n| [*"\u4E00".."\u9FFF"].sample(3).join("") }
end

The sequence is required to pick a new sample for every test run.