STATIC.x

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 https://github.com/fatih/vim-go.git.
  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 github.com/fatih/vim-go 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 github.com/Shougo/neocomplete.vim for more details.

  1. Get into directory ~/.vim/bundle and execute git clone https://github.com/Shougo/neocomplete.vim.git.
  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: github.com/fatih/molokai.

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 github.com/jstemmer/gotags 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 https://github.com/majutsushi/tagbar.git.
  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 https://github.com/scrooloose/nerdtree.git.
  2. Edit ~/.vimrc and add line map <C-n> :NERDTreeToggle<CR>. Now you can press <Ctrl+n> to enable/disable this feature.

Awesome work!

Advertisements


Leave a comment

Interactive Foreground Extraction using GrabCut Algorithm

Theory

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

Java Collections

1. Java Collections

A Java collection is a data structure which contains and processes a set of data. The data stored in the collection is encapsulated and the access to the data is only possible via predefined methods.

For example if your application saves data in an object of type People, you can store several Peopleobjects in a collection.

While arrays are of a fixed size, collections have a dynamic size, e.g. a collection can contain a flexible number of objects. Continue reading


Leave a comment

Function Pointers and Callbacks in C — An Odyssey

A pointer is a special kind of variable that holds the address of another variable. The same concept applies to function pointers, except that instead of pointing to variables, they point to functions. If you declare an array, say, int a[10]; then the array name a will in most contexts (in an expression or passed as a function parameter) “decay” to a non-modifiable pointer to its first element (even though pointers and arrays are not equivalent while declaring/defining them, or when used as operands of the sizeof operator). In the same way, for int func();funcdecays to a non-modifiable pointer to a function. You can think of func as a const pointer for the time being. Continue reading


Leave a comment

Curses Programming with Python

Author: A.M. Kuchling, Eric S. Raymond
Release: 2.04

Abstract

This document describes how to use the curses extension module to control text-mode displays.

What is curses?

The curses library supplies a terminal-independent screen-painting and keyboard-handling facility for text-based terminals; such terminals include VT100s, the Linux console, and the simulated terminal provided by various programs. Display terminals support various control codes to perform common operations such as moving the cursor, scrolling the screen, and erasing areas. Different terminals use widely differing codes, and often have their own minor quirks.

Continue reading


Leave a comment

Python Sockets

Python provides two levels of access to network services. At a low level, you can access the basic socket support in the underlying operating system, which allows you to implement clients and servers for both connection-oriented and connectionless protocols.

Python also has libraries that provide higher-level access to specific application-level network protocols, such as FTP, HTTP, and so on.

This tutorial gives you understanding on most famous concept in Networking – Socket Programming

What is Sockets?

Sockets are the endpoints of a bidirectional communications channel. Sockets may communicate within a process, between processes on the same machine, or between processes on different continents.

Sockets may be implemented over a number of different channel types: Unix domain sockets, TCP, UDP, and so on. The socket library provides specific classes for handling the common transports as well as a generic interface for handling the rest. Continue reading