Monday, January 22, 2018

Building AOSP on Mac


To build Android on MacBookPro High Sierra, I had to overcome few obstacles.
I looked up the MacOS SDK version, I am currently running:
$ ls /Applications/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
MacOSX.sdk  MacOSX10.13.sdk
Then changed build/soong/cc/config/x86_darwin_host.go to:
darwinSupportedSdkVersions = []string{
    "10.8",
    "10.9",
    "10.10",
    "10.11",
    "10.12",
    "10.13",
}
I also had to get a case-sensitive file system USB-C SSD disk.
build/core/main.mk:105: warning: 
Please move your source tree to a case-sensitive filesystem.

Resources:


Wednesday, January 3, 2018

Why developers should use Google Nexus / Pixel devices

It is January 2018. I sitting in front of two 2017 FLAGSHIP phones from Huawei and Samsung and the sample code app that I am trying will not run on neither of them (Android 7, API 24), but it does run on the Google Pixel C tablet that is 3 years old and discontinued but has been already updated to Android 8, API 26.

This really teaches me a lesson, get Pixel phone as a next phone.




Thursday, December 21, 2017

Missing xcrun on macOS High Sierra


Error

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

error: "" unsupported

Solution:


  • Re-install XCode from App Store (~20 minutes)
    • Open XCode and agree to lice agreement
    • Allow it to "Instal components..."
This resolved my problem, but optionally you can try the following:
  • xcode-select --install
  • sudo xcodebuild -license
  • xcode-select --reset





Thursday, September 21, 2017

sed command line tool

The sed command line tool allows you to pipe a string of text and substitute part of it.

Note that it does for the first occurrence only:



$ echo "my, this is my sentence" | sed 's/my/My/'
My, this is my sentence


Escaping forward slashes with the backslashes:


$ echo "convert /usr/local/bin to /common/bin" | sed "s/\/usr\/local\/bin/\/common\/bin/"
convert /common/bin to /common/bin



$ echo "Repeat me 5 times." | sed 's/[0-9]/& & & & &/'

Repeat me 5 5 5 5 5 times.

Friday, September 15, 2017

How to change Python version using Anaconda?

$ python --version

Python 3.6.1 :: Anaconda 4.4.0 (x86_64)

$ conda create -n py27 python=2.7 anaconda

$ source activate py27

$ python --version

Python 2.7.13 :: Anaconda 4.4.0 (x86_64)


Also posted on GitHub

How to show hidden files in Apple OS X Finder (AppleShowAllFiles)


Open Terminal and execute the following line:

$ defaults write com.apple.finder AppleShowAllFiles YES

Thursday, August 10, 2017

Python CAN bus

Install Python CAN library


~ uki$ sudo pip install python-can
Collecting python-can
Downloading python-can-1.5.2.tar.gz (77kB)
100% |████████████████████████████████| 81kB 3.3MB/s
Installing collected packages: python-can
Running setup.py install for python-can ... done
Successfully installed python-can-1.5.2

Follow the Directions


https://python-can.readthedocs.io/en/latest/installation.html

Monday, July 17, 2017

Android Adaptive Icons

Android allows us to create adaptive icons (various shapes for one icon for different devices) for:
  • launcher icons
  • shortcuts
  • Setting app
  • sharing dialogs
  • overview screen
You have to provide the following layers 108x108 dp:
  • top mask (circle, squircle, rounded square, square) provided by device OEM (e.g. Samsung)
  • foreground layer 72x72 dp should be visible in the mask viewport
  • background layer

The edge 18 dp are reserved for system's special effects.

Use Android Studio 3.0 Asset Studio to create these adaptive icons.



Reference:

https://developer.android.com/preview/features/adaptive-icons.html

Tuesday, April 25, 2017

Python UnicodeDecodeError



When you are reading CSV file (spreadsheet), make sure you set encoding="utf-8", or you might get:

UnicodeDecodeError: 'utf-8' codec can't decode byte
(result, consumed) = self._buffer_decode(data, self.errors, final)



def read_rows(CSV_file_path: str):
 
    import sys
    print("default encoding", sys.getdefaultencoding())
    import csv
    rows = []
    with open(CSV_file_path, 'rt', encoding="utf-8") as csvfile:
        cvs_reader = csv.reader(csvfile, delimiter=',', quotechar='"')
        for row in cvs_reader: # row is a list
            rows.append(row)
    return rows

Sunday, April 16, 2017

Using Docker containers on Mac

Install Docker on Mac


https://download.docker.com/mac/stable/Docker.dmg


$ docker --version
Docker version 17.03.1-ce, build c6d412e

$ docker-compose --version
docker-compose version 1.11.2, build dfed245

$docker-machine --version
docker-machine version 0.10.0, build 76ed2a6

Docker for Udacity Machine Learning

$ docker pull kyoungrok0517/tensorflow-udacity

Docker for Raspberry Pi

Having created a large Pi cluster, the next logical step is to deploy various microservices in Docker containers on Pi.

https://www.raspberrypi.org/blog/docker-comes-to-raspberry-pi/