Saturday, September 30, 2017

LineageOS 14.1 on the Galaxy S4 Mini

Ever since the wife started using the LG G Pro 2 (D838), the Samsung Galaxy S4 Mini (GT-I9195T) has been gathering dust on a shelf. Decided to put a custom ROM on it, and was pleasantly surprised that it's already running CM13.1 (Android 6.0.1). Can't remember when I did that. And given that it already has a TWRP custom recovery on it, flashing LOS14.1 on it is a cinch.

Download latest firmware here:
https://download.lineageos.org/serranoltexx

Get Google Apps here:
http://opengapps.org/
Choose either the pico, nano, or micro variant of the Android 7.1 gapps (ARM platform).

If you want to get root, download the addonsu package from https://download.lineageos.org/extras

Copy all three files to a microSD card, and let's start.

  1. Boot into recovery (Vol Up & Home & Power).
  2. Wipe the Cache, System, and Data partitions.
  3. Flash the LOS firmware, gapps, and the addonsu zips.
  4. Reboot system.

First boot takes a very long time, so don't be tempted to restart the phone. Just let it finish its work. Once booted, Go to Settings, About Phone. Tap the build number seven times to enable Developer Options. Change root access to your desired method.

Sunday, September 17, 2017

Xiaomi Mijia Infrared Motion Sensor Dimmable LED Night Light Review

For this post, I'm reviewing the Xiaomi Mijia night light. Well, the title pretty much mentions all the features of this item.
  • The light has 120-degree sensing angle and sensing distance up to 5 to 7 meters. Using advanced photosensitive sensor and human infrared sensor technology with anti-infrared interference function, the light can turn on automatically in the dark and light up for 15 seconds.
  • The light is powered by 3 AA batteries (not included). In standby mode, ultra-low power consumption of only 0.25mW. Toggle switch chooses between two luminance levels - 0.7Lm and 3.8Lm, with battery life of 12 months and 6 months, respectively.
  • Applied Fresnel ultra-thin lens to enhance the sensor performance. Fish scale total reflection structure reflect the light to the diffuse reflector and the light spreads evenly in the lampshade to bring a better visual experience.
Okay, first impression. The night light is much smaller than what I expected, having only seen it from the online product listings. The build and finish is excellent though - clean and minimalist. The top and side surfaces of the night light is very smooth, with some grooves at the bottom to provide some grip. Still took me a while to open up the night light to install the three AA batteries.

It works as advertised. Doesn't activate or turn on during daytime. In the dark, it senses movement almost instantaneously, even from afar, and lights up. Even at 3.8Lm, the 2700K warm white light is not too glaring, yet bright enough to light up its immedate surroundings. Light comes out from a circular strip around the top surface. Output is quite uniform and even.

In terms of installation, it can be attached to flat surfaces via double-sided tape. A plastic film with a hole can be stuck to the night light, which can them be suspended/mounted on a hook or nail. In my case, it's just positioned on the floor facing the hallway entrance. Turns on every time someone passes by.

Tuesday, September 12, 2017

Book 2017.09.12 - The Boy Kings: A Journey into the Heart of Social Network

As employee number 51, Katherine Losse writes about her stint at Facebook. From her start as a lowly $20/hour customer support to internationalization product manager to Mark Zuckerberg's ghost writer.

It was an interesting read on how Facebook developed into the all-encompassing behemoth it is now - Mark's obsession on being "technical" and making everything "transparent". Lots of anecdotes about the boy kings and personalities who make up Facebook and philosophical musings about real life, friendships, connections, and technology.

The tl;dr version - Facebook may be good for your "social" life, but not your social life.

After five long years with Facebook, Kate had enough of the cult, and sold off her Facebook shares (pre-IPO), and moved to Marfa, Texas to write this book.

The parting paragraph: "I think that this may be the truth of these technologies that we carry around: We film and post and read social media constantly in order to capture something, some exciting moment or feeling or experience that we are afraid to miss, but the things about life that we most want to capture may not be, in the end, capturable. And, perhaps, planning and efficiency themselves, the things that technologies like Facebook want to make easy and constant, are not as easily grasped as we think. Because, in all of our newfound efficiencies, what have we lost? What, like the moment at the Ice Plant when the glass shattered, is too unplanned and ephemeral to predict and capture with our technologies? Should we keep trying, or should we take a breath, and let some things go unshared and unrecorded, realizing that this ineffability may be the essence of life itself?"

Sunday, September 10, 2017

張惠妹 - 快樂眼淚

張惠妹 - 快樂眼淚

作詞:林夕
作曲:楊陽
編曲:吳慶隆



看著你久違卻 熟悉的臉龐
kan zhuo ni jiu wei que shu xi de lian pang
那些煙遠往事 畫上了圓滿
na xie yan yuan wang shi hua shang liao yuan man
因為你快變成 別人的新郎
yin wei ni kuai bian cheng bie ren de xin lang

你終身的對象 一定很理想
ni zhong shen de dui xiang yi ding hen li xiang
否則你又何必 終止糾纏
fou ze ni you he bi zhong zhi jiu chan
只好微笑祝福 你們的浪漫
zhi hao wei xiao zhu fu ni men de lang man

Chorus:
我終於變得不多愁善感
wo shi zhong bian de bu duo chou shan gan
回憶還像心跳那麼難忘
hui yi huan xiang xin tiao na me nan wang
擁抱的熱 還留在我們的身上
yong bao de re huan liu zai wo men de shen shang
緣分卻不能反抗
yuan fen que bu neng fan kang
愛人不變朋友實在太難
ai ren bu bian peng you shi zai tai nan
希望離別 能讓以後
xi wang li bie neng rang yi hou
更快樂 更幸福 更美滿
geng kuai le geng xing fu geng mei man

漫長路上你幫我背的行囊
man chang lu shang ni bang wo bei de xing nang
因為有你的汗 變成珍藏
yin wei you ni de han bian cheng zhen cang
我給你的補償 是為你打扮
wo gei ni de bu chang shi wei ni da ban

Repeat Chorus

那次大雨中下班
na ci da yu zhong xia ban
你拿一把雨傘 來接我
ni na yi ba yu san lai jie wo
想起來 難免傷感
xiang qi lai nan mian shang gan

感謝你愛我一場
gan xie ni ai wo yi chang
難得敘舊笑談
nan de xu jiu xiao tan
依然溫暖
yi ran wen nuan
有浪漫 沒緣分
you lang man mei yuan fen
總不算遺憾
zong bu suan yi han

我終於變得不多愁善感
wo zhong yu bian de bu duo chou shan gan
回憶還像心跳那麼難忘
hui yi huan xin tiao na me nan wang
擁抱的熱 還留在我們的身上
yong bao de re huan liu zai wo men de shen shang
緣分卻不能反抗
yuan fen que bu neng fan kang
愛人不變朋友實在太難
ai ren bu bian peng you shi zai tai nan
希望離別 能讓以後
xi wang li bie neng rang yi hou
更快樂 更幸福 更美滿
geng kuai le geng xing fu geng mei man
我快樂 的眼淚 在流轉
wo kuai le de yan lei zai liu zhuan

Sunday, September 3, 2017

Downloading Segmented Vimeo Videos

Have blogged about this before. Downloading Vimeo videos used to be a matter of clicking the download button that appears below the video player. Download disabled? No problem. Just plug in the Vimeo video URL to the many online video downloaders that supposedly can do the job. youtube-dl might even do the job.

Lately, I've noticed that a lot of the premium Vimeo videos are chopped up and sent to the client browser as m4s segments. I've written a blog post before re: downloading Brightcove videos, but this one is totally different. As far as I can tell, there is no main mp4 link that can be obtained. You'll have to save all these m4s segments and somehow piece them all together to get the complete video.

Did a bit of research, and looks like someone already wrote a python script that should be able to do this. Installation is pretty simple:

  1. Install additional requirements using pip install.
  2. Install ffmpeg.
  3. Extract the master URL (http://...master.json?base64_init=1) and plug into the vimeo-download command.

vimeo-download.py script should probably work fine with a Windows python and ffmpeg installation, but I decided to go with Linux. See my blog post about Linux VM. As mentioned, python comes pre-installed in Linux Mint, but not pip.

sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get install python-pip

Once pip in installed, it's time to install the additional required packages:

pip install -r requirements.txt

Got an error message saying: ImportError: No module named setuptools

sudo pip install -U setuptools

Next error message is about OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/asn1crypto'

sudo pip install -r requirements.txt

Which now works fine until we get to:

build/temp.linux-x86_64-2.7/_openssl.c:12:24: fatal error: pyconfig.h: No such file or directory compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

This requires additional packages to be installed.

sudo apt-get install python-dev

Then we get: build/temp.linux-x86_64-2.7/_openssl.c:434:30: fatal error: openssl/opensslv.h: No such file or directory

sudo apt-get install build-essential libssl-dev libffi-dev

All the packages from requirements.txt were installed after these additional commands.

Next up is the ffmpeg installation. As instructed in the installation notes, tried to set mc3man/trusty-media as a PPA repository. Got the below error message, which indicates xenial (Linux Mint 18) is too new and not supported by the PPA.

This PPA does not support xenial

Why not just get ffmpeg from the official repositories? Which is what I did.

sudo apt-get install ffmpeg

Next question: How do we extract the master URL of a segmented vimeo video?

  1. Enable Developer Tools (Ctrl + Shift + I)
  2. Go to the Network tab.
  3. Play the Vimeo video.
  4. Look for the entry which says master.json?base64_init=1
  5. Right-click and Copy link address

Usage syntax is:
python vimeo-download.py --url "http://...master.json?base64_init=1" --output <optional_name>

From that master.json URL, we get the base video and audio URLs, and all the segments are retrieved. The v.mp4 video file and the a.mp3 audio file are muxed using ffmpeg to come up with the final vimeo video in the output directory.

Linux Virtual Machine

Sometimes, it's easier to get something done in Linux, compared to Windows. Yet, it might be a one-time job that doesn't warrant a special partition on the hard disk, or even a live CD-ROM or USB stick. For those time, you just want to run Linux on a virtual machine. You can delete the VM once you're done, or just keep VM file the run it again the next time you need it.

For desktop virtualization, it's a tossup between VMWare and Oracle's VirtualBox. Decided to go with the latter, since it's open-source and I feel easier to install and configure. Lots of pre-built images to choose from, but I decided to build the VM from scratch. It's just a matter of creating the VM and specifying the memory and hard disk space. On first boot, specify which Linux ISO to boot from and do a clean install.

Started off with Ubuntu Server, since I have no need for a GUI. For some reason, I was not able to install the VirtualBox guest additions. Tried:

sudo mkdir --p /media/cdrom
sudo mount -t auto /dev/cdrom /media/cdrom/
cd /media/cdrom/
sudo sh VBoxLinuxAdditions.run

and:

sudo apt-get install virtualbox-guest-utils

Seemed to do something, yet not able to get full-screen window and cut-and-paste between host and guest, so I guess it didn't work.

Moved on to Lubuntu. Window resolution was so low that the installation screens are cropped out. Managed to get the OS installation going. Again, had a hard time getting the guest additions working, even though I got the Guest Additions CD image mounted.

Lastly, I tried Linux Mint 18. With this, everything just worked. No cropped installation screens. Full-screen window *before* I installed guest additions. And now I can open multiple terminals, do cut-and-paste between host and guest, and shared folders. Bonus points - python comes pre-installed (but not pip).