archan’s emacs 20022014

February 20, 2014

;; emacs 18022014

;; add package repository and install missing packages
(require 'package)
(setq package-archives '(("melpa" . "")))
(setq package-list '(autopair dart-mode flymake-cursor flymake-google-cpplint flymake-python-pyflakes flymake-easy google-c-style jedi-direx direx jedi auto-complete epc ctable concurrent deferred pony-mode popup web-mode))
;; find : C-h v package-activated-list
(when (not package-archive-contents)
(dolist (package package-list)
  (when (not (package-installed-p package))
    (package-install package)))

;; default customization
 '(inhibit-splash-screen t)
 '(inhibit-startup-message t)
 '(tool-bar-mode nil)
 '(column-number-mode t)
 '(cua-mode 1 nil (cua-base))
 '(global-font-lock-mode 1)
 '(global-linum-mode t)
 '(ido-mode t nil (ido))
 '(make-backup-files nil)
 '(show-paren-mode t)

;; set all windows (emacs's “frames”) to some defaults
(setq initial-frame-alist '((width . 100) (height . 54)))
(setq default-frame-alist
      '((menu-bar-lines . 1)
        (tool-bar-lines . 0)
        (width . 100)
        (height . 52)
(set-frame-parameter nil 'font "Dejavu Sans Mono-9")
(global-hl-line-mode 1)
;(load-theme 'misterioso)
(set-face-background 'highlight "white smoke")

;; Prevent accidentally killing emacs.
(global-set-key [(control x) (control c)]
  '(lambda ()
     (if (y-or-n-p-with-timeout "Exit Emacs ? " 4 nil)

;; enable autopairing
(require 'autopair)
(setq autopair-autowrap t)

;; custom key-bindings
(define-key global-map (kbd "RET") 'newline-and-indent)
(global-set-key "\M-l" 'goto-line)
(global-set-key (kbd "<f2>") 'save-buffer)
(global-set-key (kbd "<f10>") 'switch-to-buffer)
(global-set-key (kbd "<f11>") 'next-buffer)
(global-set-key (kbd "<f12>") 'prev-window)
(defun prev-window ()
   (other-window -1))

;; text-mode hooks
(add-hook 'text-mode-hook 'text-file-handle)
(defun text-file-handle()
  (set-fill-column 80)
  (setq indent-tabs-mode nil )
  (setq tab-width 4 )

;; python-mode hooks
(require 'python-mode)
(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
(add-hook 'python-mode-hook 'python-file-handle)
(defun python-file-handle()
  ; remove whitespaces
  (add-hook 'before-save-hook 'delete-trailing-whitespace)
  ; python indentation
  (setq indent-tabs-mode t)
  (setq tab-width (default-value 'tab-width))
; flymake-python-pyflakes
(require 'flymake-python-pyflakes)
(add-hook 'python-mode-hook 'flymake-python-pyflakes-load)
(setq flymake-python-pyflakes-executable "flake8")
; python-jedi auto-complete
(require 'jedi)
(add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:setup-keys t)
(setq jedi:complete-on-dot t)
; flymake faces
 '(flymake-errline ((((class color)) (:background "ivory1"))))
 '(flymake-warnline ((((class color)) (:background "ivory2")))))

;; dart-mode hooks
(require 'dart-mode)
(add-to-list 'auto-mode-alist '("\\.dart\\'" . dart-mode))
(add-hook 'dart-mode-hook 'dart-file-handle)
(defun python-file-handle()


Here is my honest confession about Ubuntu and Tizen. I seriously dislike them as they are bloated and designed & developed by nuts. Anyway, I wanted the Tizen SDK to run on my ArchLinux box (for code review & curiosity).

Here is the HOWTO on running Tizen on ArchLinux (using Ubuntu chroot) : I know it is SICK!!

Create preliminary Ubuntu chroot in ArchLinux :

  1. aurget –deps -Sy –nodiscard –noedit –noconfirm –asroot debootstrap

  2. mkdir /home/ubuntu-chroot

  3. cd /home/ubuntu-chroot

  4. debootstrap –arch=amd64 quantal ubuntu-quantal-amd64

  5. ln -s /proc/mounts ubuntu-quantal-amd64/etc/mtab

  6. rm ubuntu-quantal-amd64/etc/resolv.conf

  7. echo “nameserver” > ubuntu-quantal-amd64/etc/resolv.conf

  8. echo “log:x:19:” >> ubuntu-quantal-amd64/etc/group

  9. update /etc/apt/sources (curl > ubuntu-quantal-amd64/etc/apt/sources.list )

Chrooting to Ubuntu chroot :

  1. cat

xhost +
mount -o bind /proc/ ubuntu-quantal-amd64/proc/
mount -o bind /dev/ ubuntu-quantal-amd64/dev/
LC_ALL=en_US.UTF-8 chroot ubuntu-quantal-amd64 bash
killall -gq dbus-launch

killall -gq /usr/lib/rtkit/rtkit-daemon

sleep 3
umount ubuntu-quantal-amd64/proc/
umount ubuntu-quantal-amd64/dev/

Setting-up Ubuntu chroot :

  1. apt-get update

  2. apt-key adv –keyserver –recv-keys 16126D3A3E5C1192

  3. apt-key adv –keyserver –recv-keys C2518248EEA14886

  4. dpkg-divert –local –rename –add /sbin/initctl

  5. ln -sf /bin/true /sbin/initctl

  6. apt-get -y –no-install-recommends install locales wget curl debconf devscripts gnupg vim aptitude mc

  7. apt-get -y –no-install-recommends install build-essential git-core

  8. locale-gen en_US.UTF-8

  9. update-locale en_US.UTF-8

  10. ln -sf /usr/share/zoneinfo/Asia/Kolkata /etc/localtime

  11. adduser USERNAME

  12. gpasswd -a USERNAME root

  13. gpasswd -a USERNAME users

  14. gpasswd -a USERNAME sudo

Apps/themes [optional] :

  1. apt-get -y –no-install-recommends install vim-gtk

  2. apt-get -y –no-install-recommends install gtk2-engines-oxygen gtk3-engines-oxygen oxygen-icon-theme

  3. echo “gtk-theme-name = \”oxygen-gtk\”” > /etc/gtk-2.0/gtkrc

  4. echo “gtk-icon-theme-name = \”oxygen\”” >> /etc/gtk-2.0/gtkrc

  5. echo “gtk-font-name = \”Liberation Sans 9\”” >> /etc/gtk-2.0/gtkrc

  6. cat /etc/gtk-2.0/gtkrc > /etc/gtk-3.0/gtkrc

Preparing for Tizen development :

  1. apt-get –no-install-recommends install oracle-java6-installer

  2. apt-get -y –no-install-recommends install procps gettext libdbus-1-3 libcurl3 expect gtk2-engines-pixbuf grep zip make qemu-user-static libwebkitgtk-1.0-0 libgnome2-0 pciutils libxtst6 libglu1-mesa libv4l-0

  3. apt-get -y –no-install-recommends install xdg-utils unzip

  4. apt-get -y –no-install-recommends install qemu-kvm

  5. su – USERNAME

  6. mkdir -p ~/.local/share/desktop-directories/

  7. wget

  8. bash ./tizen-sdk-2.0-ubuntu64.bin

  9. su – tizen-dev

  10. /home/tizen-dev/tizen-sdk/ide/ &


Xoom-ing into ICS

July 14, 2012

I got really impatient due to non-availability of ICS/JB for my Motorola Xoom MZ601. So, I decided to hack and switch to MZ604 firmware for GED Xoom to receive OTA update of ICS build. I had to compromise with non-working 3G, but it is okay for time-being …(till my next hack).

Here is the quick howto :

  1. Make sure to have adequate (full) charge in your Xoom.
  2. Download the official Build HWI69 for US Retail from Motorola device software page.
  3. Switch to fastboot mode by holding “vol down” + “power” buttons (ref).
  4. Connect the Xoom with Computer (Linux/Windows/Mac – assuming that you have the Android tools/drivers installed).
  5. Run following commends from terminal (you may void your warranty)
    • fastboot oem unlock
    • Following on-screen instructions.
    • fastboot reboot
  6. Once rebooted, switch back to bootloader
    • adb reboot bootloader
    • Wait for the reboot and switch to fastboot mode
    • From the terminal change to MZ604 firmware directory where you unzipped official Build HWI69 for US Retail firmware.
    • cd /home/experiments/MZ604_HWI69/
    • fastboot flash boot boot.img
    • fastboot flash system system.img
    • fastboot flash recovery recovery.img
    • fastboot flash userdata userdata.img
    • fastboot erase cache
    • fastboot reboot
  7. Once rebooted, you will get HW169 firmware loaded into Xoom.
  8. Connect to WiFi and do system update (OTA process).
  9. You should get automatic OTA which will upgrade firmwares in sequence :
    • HMJ37 -> HTJ85B -> HTK55D -> HTK75D -> IML77
  10. Once you have IML77, you are into ICS (android ice cream sandwich 4.0)
  11. Finally, a factory is not a bad thing to do.


Did I forgot to say that I am not responsible for any damages caused by using above instructions?

If you have Android source repo, here are the simple 3 steps to switch to Android releases branch :
  1. repo init -b gingerbread-release
  2. repo start gingerbread-release –all
  3. repo checkout gingerbread-release


January 14, 2012

I have finally decided to retire my Kindle2 and buy a Tablet. The timing could not have been better as online retailers started to sell Motorola Xoom in discounted price. So it’s Xoom-ing time.

I am yet to root and hack into the device, till then, let me enjoy Motorola’s superior design, power of Tegra2 and openness of Android.

  1. When the STB is on, switch off from the power-source.
  2. Switch on the STB directly from power-source.
  3. Press “back” button twice from remote when “please wait initializing” message comes to the screen.
  4. Immediately, press 2465 from remote and software will start downloading. (keep the STB on till it reboots twice)
Use the above instructions in your own risk. I am not responsible if you make your STB a brick.

After long time, I am again back to OS classics (my CS favorite) and reading Minix code in depth.

$ git clone git://