Kunal Dawn

Leave a comment

Setup VIM for Go development

Install Pathogen

Pathogen is a plugin manager of VIM, which tons of plugins support it. So, one time forever, let’s install it.

  1. Go to Pathogen home page, find the ZIP archive of package.
  2. Download and unzip, you’ll have a directory called autoload put the file named pathogen.vim to ~/.vim/autoload/pathogen.vim.
  3. Edit ~/.vimrc file and add call pathogen#infect() to the top.


Install VIM-GO

Now, let’s install plugins we want.

  1. Get into directory ~/.vim/bundle then execute git clone
  2. Edit ~/.vimrc file and add following content(the last line is for not auto-installing missing packages, which may need long time):
syntax enable  
filetype plugin on  
set number  
let g:go_disable_autoinstall = 0  
  1. Great, now you can follow some instructions on to custom. Note that use <C-x><C-o> call code completion, and better call it after you type ..


Install neocomplete

This is the plugin gives you real-time code completion, but it has special requirements for your VIM, see for more details.

  1. Get into directory ~/.vim/bundle and execute git clone
  2. Edit ~/.vimrc file and add line let g:neocomplete#enable_at_startup = 1. Now the real-time feature will be enabled automatically every time you start your VIM.


Install molokai theme

The same author wrote a molokai theme for VIM:

To install it, just download his molokai.vim and put it into ~/.vim/colors . Then add colorscheme molokai to your ~/.vimrc file.


Install tagbar

This one is optional, but I installed it just because it looks so cool!

  1. First of all, you have to install ctags, I use Mac so just simply brew install ctags.
  2. Then execute go get -u to install Go parser.
  3. Add following lines to your ~/.vimrc file:
let g:tagbar_type_go = {  
    \ 'ctagstype' : 'go',
    \ 'kinds'     : [
        \ 'p:package',
        \ 'i:imports:1',
        \ 'c:constants',
        \ 'v:variables',
        \ 't:types',
        \ 'n:interfaces',
        \ 'w:fields',
        \ 'e:embedded',
        \ 'm:methods',
        \ 'r:constructor',
        \ 'f:functions'
    \ ],
    \ 'sro' : '.',
    \ 'kind2scope' : {
        \ 't' : 'ctype',
        \ 'n' : 'ntype'
    \ },
    \ 'scope2kind' : {
        \ 'ctype' : 't',
        \ 'ntype' : 'n'
    \ },
    \ 'ctagsbin'  : 'gotags',
    \ 'ctagsargs' : '-sort -silent'
\ }
  1. Just like install other plugins, get into ~/.vim/bundle and execute git clone
  2. Edit ~/.vimrc file and add line nmap <F8> :TagbarToggle<CR>. This is a key mapping, which allows you use F8 to enable/disable the feature.

Install file browser nerdtree

  1. Get into ~/.vim/bundle and execute git clone
  2. Edit ~/.vimrc and add line map <C-n> :NERDTreeToggle<CR>. Now you can press <Ctrl+n> to enable/disable this feature.

Awesome work!

Leave a comment

Security-Enhanced Linux in Android

SELinux operates on the ethos of default denial. Anything that is not explicitly allowed is denied. SELinux can operate in one of two global modes: permissive mode, in which permission denials are logged but not enforced, and enforcing mode, in which denials are both logged and enforced. SELinux also supports a per-domain permissive mode in which specific domains (processes) can be made permissive while placing the rest of the system in global enforcing mode. A domain is simply a label identifying a process or set of processes in the security policy, where all processes labeled with the same domain are treated identically by the security policy. Per-domain permissive mode enables incremental application of SELinux to an ever-increasing portion of the system. Per-domain permissive mode also enables policy development for new services while keeping the rest of the system enforcing. Continue reading

Leave a comment

Interactive Foreground Extraction using GrabCut Algorithm


GrabCut algorithm was designed by Carsten Rother, Vladimir Kolmogorov & Andrew Blake from Microsoft Research Cambridge, UK. in their paper, “GrabCut”: interactive foreground extraction using iterated graph cuts . An algorithm was needed for foreground extraction with minimal user interaction, and the result was GrabCut. Continue reading

Leave a comment

Building and deploying JavaFX Applications on Android


What do you need in order to build and deploy JavaFX Applications on Android?

  1. You need the Android SDK. You can download this here. The SDK is sufficient if you only want to develop applications (in the .apk format). If you want to install the applications on devices, or run emulators, you need to download the ADT bundle. Make sure to remember where you download it into.
  2. You need a JavaFX-Dalvik Runtime. You can either download it here (easy) or build this yourself (less trivial). Always download the latest version of the runtime. The latest version is currently dalvik-sdk-b4.
  3. You need a regular JavaFX Application, compiled with Java 7.
  4. You need the gradle buildsystem (on Linux, Gradle 1.4 is reported to be successful, on Windows, Gradle 1.9 has been used with success) Continue reading

Leave a comment

Layout in Android (and JavaFX)

One of my clients allowed me to write an Android application. I have done Java and mobile development before, so it basically comes down to learning the new framework. And that’s something Java developers do on a fairly regular basis. There were some special things, like connecting to a bluetooth barcode scanner, but nothing that some coding-by-googling wouldn’t fix. The application initially was aimed at Android 2.2+ and phones, but in the meantime it’s been upgraded to Android 4.0+ and 10″ tablets, because it needed a stronger visual screen (with loads of images) and the screens of the phones were simply too small.I’d like to share some of the experiences I had with this project. Continue reading