Friday, August 12, 2016

Split single line into multiple lines separated with ;

cat t.txt | xargs | sed 's/;/\n/g'

Combine multiple lines into single line separated using ;

cat t.txt |xargs | sed -e 's/\n/;/g'

How to get print from android makefile

Add below line to get print from android makefile
$(info "I want this print")

Delete single line from multiple files containing specific word

To delete line which contains alsa-lib word from all .xml file, use
for f in *.xml; do sed -i '/alsa-lib/d' $f ; done

How to change linux console/terminal column width

To change linux console/terminal column width use stty, e.g. to change width to 180 column use
stty cols 180

Tuesday, August 2, 2016

Tensorflow on Windows

Get tensorflow installed and working on Windows.
  • Download docker toolbox for windows from https://www.docker.com/products/docker-toolbox
    Use default selections, once installed it will create few shortcuts on your desktop.
  • Click on "Docker Quickstart Terminal" shortcut on desktop
  • Now press Windows key + R and type cmd, it will open new command terminal. Enter following in terminal
     docker-machine ssh default 
  • Start docker using below command
     docker run -it b.gcr.io/tensorflow/tensorflow:latest-devel 

    If Its first time it will display following error and download it, which takes some time. Unable to find image 'b.gcr.io/tensorflow/tensorflow:latest-devel' locally latest-devel: Pulling from tensorflow/tensorflow
  • check tensorflow, by typing following
    >>> import tensorflow as tf
    >>> msg = tf.constant("Hello, World")
    >>> sess = tf.Session()
    >>> print sess.run(msg)
    Hello, World
    >>> 
    
  • To use windows shared folder with docker

  • Click "Oracle VM VirtualBox" shortcut on desktop.
  • Goto Settings-> "Shared Folders"
  • Click Folder+ Icon
  • Provide Folder Path, Folder Name, check Automount. e.g. I have folder name as dl_share
  • Now start docker by mounting share folder dl_share to /home/
    docker-machine ssh default
    sudo mkdir /win-share
    sudo mount -t vboxsf dl_share /win-share
    docker run -it -v /win-share:/home b.gcr.io/tensorflow/tensorflow:latest-devel
    

  • Convert audio from one format to other using ffmpeg


  • Convert wav format to dts format
     ./ffmpeg -i ~/sine_440Hz_2ch.wav -codec dts -strict -2 ~/sine_440Hz_2ch.dts 
  • Use mka container for above dts file
     ./ffmpeg -i ~/sine_440Hz_2ch.dts -vn -acodec copy -f matroska ~/sine_440Hz_2ch.mka 
  • Convert file from one container format to other
     ffmpeg -i input.mp4 -vcodec copy -acodec copy output.mkv 
  • Convert wav to ac3 format
     ./ffmpeg -i ~/sine_500Hz_2ch.wav -acodec ac3_fixed -ab 768k -ar 48000 test.ac3 
  • Use mka container for ac3
     ./ffmpeg -i test.ac3 -vn -acodec copy -f matroska ~/sine_500Hz_2ch-ac3.mka 
  • To grant all permission to android app


    To grant all permissions to app, use -g as argument while installing with adb
     adb install -g myapp.apk 

    Cross Compiling Linux kernel for ARM

  • Get latest stable kernel source code
     git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
    To get kernel-next branch clone
     git clone https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 
  • Get toolchain, e.g you can download linaro toolchain from Linaro toolchain for arm
  • set your path variable /path/to/linaro/binary/linaro/aarch64-unknown-linux-gnu_4.9-2014.05-01/bin
     export PATH=$PATH:/path/to/linaro/binary/linaro/aarch64-unknown-linux-gnu_4.9-2014.05-01/bin 
  • Setup defconfig file
     make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- O=output defconfig 
  • Make kernel image
     make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- O=output -j8 
  • To modify kernel configuration use
  •  make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- O=output menuconfig 
  • To save your modified defconfig file
     make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- O=output savedefconfig 
    This will create defconfig file in output directory. Copy this file to your arch/arm64/configs directory