Tuesday, October 18, 2011

Voice Interface

Since Apple brilliantly introduced the touch interface, I thought now it's time to introduce Voice interface. It's especially useful when a car driver has to focus on the road. You just speak some commands and a smartphone responses back to you. I mean, you need some kind of feedback. The difficulty seems to me the intelligence of signal processing. Such a device needs to know the context when it hears someone talking. Is it talking to the device? Is it someone just talking to someone else etc...

From what I know, there are ear devices, like ear aids, which can hear from which directions the sound comes from. We can also filter the sound for speech and we have overcome two problems: Direction and speech filtering (with noise reduction). Next is to distinguish real speech commands from normal speech conversation. But that's up to the intelligence of the software to interpret. Another helpful thing is to recognize the right voice. If someone else is talking, the device can ignore it. If this is designed very well, it should be possible to create a good device that listens to you and help you performing some tasks, while focusing on other more important things (like watching the road for obstacles, though today smart cars can warn you for obstacles too).

My colleagues at work don't believe this as a good solution to safely drive a car while commanding a navigation device to set a new location. But I believe this will be a great solution, just like Apple did with the touch interface. Apple was always ahead with design and usability, while others stick to the old fashion technology. Well, I'm not that kind of people, I'm more like Steve Jobs :-)

To be continued...

Monday, October 10, 2011

Git tips!

When you work on a project managed by Git, you have to type a lot to see status and results. For example, to seen which branch you're working on, you have to type:
#git branch
You'll see a list of branches and the one with an asterisk is the current branch you are on at the moment.

If you want to switch to another branch you have to do like:
#git chekout nameofbranch

There are some nice stuff we can do, like showing the current branch in the prompt!
Put the following lines in your .bashrc file:
export GIT_PS1_SHOWDIRTYSTATE=1
export PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\]\w\[\033[01;33m\]$(__git_ps1)\[\033[01;34m\] \$\[\033[00m\] '


Furthermore, adding .gitconfig file in your home directory will automatically change the behavior of Git. My .gitconfig looks like following:


[user]
name = My Name
email = My.Email@gmail.com


[alias]
ci = commit
co = checkout
st = status
di = diff
br = branch


[pager]
color = true


[color]
ui = true


[core]
editor = vim


[format]
pretty = oneline

Especially those alliases are cool. If I want to checkout to a branch, I can do this:
#git co nameofbranch

Thursday, October 6, 2011

Vim - Omnicompletion - ctags!

How to get intellisense like (omnicompletion) feature on Vim for standard C libraries!
If you're a Vim user and also code C sources in Vim, than you quickly find yourself switching between terminals or browser to look for the type of arguments you need for standard C functions like strcmp() or strtok() or whatever. Well, not anymore! I found a lot of examples how to use omnicompletion whitin Vim, but almost all of them assume you need omnicompletion for C++, php, python or whatever. I googled my ass off to find an example of omnicompletion for standard C libraries.
First, what I did that didn't work. I looked at the folders where those standard c include files reside and found those in /usr/include/ directory. So I was analyzing the files for C only headers like stdio.h and such. I was also looking for Linux's systemcall files, like sockets etc...
Since version Vim 7.0 Vim supports omnicompletion and to work with that feature Vim needs a ctagged file (a file that is generated by ctags). This tag files contains a list of functionnames, prototypes, defines and other C related stuff, formatted in an indexed way so it can be looked up in a fast and efficient way (I guess, I'd rather use an SQLite engine as a solution). So to put it all together, we need to make a tag file using ctags. On Linux distros like Ubuntu, it's installed by default, but if you don't have one, google for exuberant ctags, download it and install it.
To generate a ctags file, you need to do the following:
# ctags /usr/include/*.h
This will generate a ctags file named tags.
If you open a c file and try out omnicompletion on the word "prin" by hitting Ctrl+x Ctrl+o, Vim won't give you a printf in the list of possible functions. Well, that sucks :(
One of the solutions is figure out how ctags work! Well, I'm sorry, I just don't have the time to do that just because I happen to want omnicompletion for standard C libraries in Vim.
The other solution is this: Be sure you downloaded and installed apt-file. If you never used apt-file than run "apt-file update". After that do the following:
Create file "libcs-ignore" with the following content:
__attribute__
__attribute_deprecated__
__attribute_format_arg__
__attribute_format_strfmon__
__attribute_malloc__
__attribute_noinline__
__attribute_pure__
__attribute_used__
__attribute_warn_unused_result__
__wur
__THROW
__nonnull+


Than execute:
# apt-file list libc6-dev | grep -o '/usr/include/.*\.h'> ~/.vim/tags/libc6-filelist
Finally do this:
# ctags --sort=foldcase --c++-kinds=+p --fields=+iaS --extra=+q -I./libc6-ignore -f ~/.vim/tags/libc6 -L ~/.vim/tags/libc6-filelist

And voila! You're done, you're finished! Try it out, but don't forget to set the tags in Vim:
# :set tags+=path/to/tag

Somehow, when ctags process the files, it gets fooled by those attributes listed in libc6-ignore file. -I option tells ctags to ignore thow words, so functionname will be parsed with the right functionname instead of __attribute__ etc... 



.


I found this solution from the following link:
http://stackoverflow.com/questions/1632633/ctags-does-not-parse-stdio-h-properly

NSNotification example