Don't know what went wrong, but I tried setting a breakpoint in web2py's web interface and the application hanged completely (i.e. I couldn't open it any more no matter what I tried). The only thing I could think of was to restart apache, but it wouldn't restart because the ports were already bound.
I don't know if these are related, but in the end I had to kill -9 all apache2 processes and then run /etc/init.d/apache2 start to get apache up. Application is also now running.
Thursday, 16 May 2013
Thursday, 18 April 2013
Working with Vim on large projects
Labels:
programming,
vim
I've been learning to use Vim for past two weeks and I'm finally getting to grips with it. Learning the basics is the easy part (there are plenty of tutorials) but to get it to work in a real project is a bit more work as it involves installing a host of plugins etc.
I'm getting there as well and this is a sort of first look at what I have found so far. I might follow-up on this if there are any new interesting findings.
Firstly, I tried Janus, which is a collection of plugins rolled into one plus some modifications. Not a good idea, it adds far too much stuff and you have no idea what.
Now I think I have a usable setup although there are still lots of small things to improve. And I know there are useful plugins that I should add.
So far I have added the following:
I'm getting there as well and this is a sort of first look at what I have found so far. I might follow-up on this if there are any new interesting findings.
Firstly, I tried Janus, which is a collection of plugins rolled into one plus some modifications. Not a good idea, it adds far too much stuff and you have no idea what.
Now I think I have a usable setup although there are still lots of small things to improve. And I know there are useful plugins that I should add.
Plugins
To start with, a plugin manager is a good idea. Pathogen is the older one, Vundle newer. I opted for the latter. Vundle helps with the installation etc. issues although I did find that using the built-in installer doesn't seem to work reliably. It says it installs the plugin, but you can't use it. So it's better to find the address for the plugin and adding this to .vimrc.So far I have added the following:
- NERDTree - File explorer. I mapped F5
to toggle. - vim-fugitive - Plugin for Git.
- vim-gitgutter - Shows changes made to file in the left column compared to HEAD. I toggle this with F4.
- CRefVim - C reference helper. You can get reference info for standard C functions.
- cvim - C plugin for Vim. Includes a host of useful stuff for C coding, like file templates, commenting (mark an area and hit \cc to comment and \co to uncomment for instance) etc.
- Gundo - Vim undo explorer. Vim has a more complex undo system than most (it can branch) and this visualises the undo path. I have mapped this to F7.
- Tagbar - Shows tags for current file in a window. I have mapped this to F6
. - CCTree - Call graph visualizer. This shows the call graph of selected item, either forward or reverse. I have mapped this to F8
. - Powerline - Makes the status bar much better. Looks better, includes stuff like current git branch and colours it depending on vim mode.
- Minibufexpl - A very compact buffer explorer.
- OmniCppComplete - Code completion.
- SuperTab - Improves tab. I use this with OmniCppComplete.
There are some other stuff I have done as well, but those add the most value. There have been a few hickups on the way and I still do. Plus I have only started configuring the key mappings.
Handling files in multiple directories
To make CCTree, tags and completion to be useful was to be able to add 3rd party sources to the search tree and in a way that I can actually have more than one project. There are some project oriented plugins but I haven't looked at them yet. I managed this more easily in the following manner.
First of all I wrote a script that creates a file with all the files I'm interested in. It looks something like
I already have the paths defined in my build environment so this was simple. I save the output to cscope.files in my main source directory (=basically root directory of my own project).
Then I can just call
ctags --C-kinds=+p --fields=+aS --extra=+q -L cscope.files
To generate the tags file. For cscope I'm so far fine with just cscope -R.
For CCTree I need to do :CCTreeLoadXRefDB
This way I can have separate tags files for separate projects and I only need to add
tags+=./tags
into my .vimrc to get OmniCppComplete to see all the tags in this project.
I have omitted basic installation of these plugins from this post because it would make this very long and this info is easily available already. The stuff I have explained here needed a bit more digging than just following the instructions even though it wasn't that hard either.
Powerline
Powerline needed a bit of tweaking before it started working. Here's how.
First of all, the Vundle line in .vimrc needs to be
Bundle 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}
Then I cloned the patched fonts repository to ~/.fonts and run fc-cache -fv in it. I originally tried to save just one font with Save As in my browser but this somehow messed the file and fc-cache wouldn't even recognize it.
Lastly I added these lines to .vimrc:
" For Powerline
set encoding=utf-8
if has("gui_running")
set guifont=Droid\ Sans\ Mono\ for\ Powerline\ 11
endif
let g:Powerline_symbols = 'fancy'
I liked Droid the most of the fonts available. It's possible to add your own patched fonts as well, but I didn't find any need for that.
Minor tweaks
I have made a couple of other minor tweaks (and this is something I guess vim users never stop doing). Firstly, I like to see which files I have edited but not saved so I added this to .vimrc.
It's also nice to be able to move between windows easily, especially when you work with some of the plugins I have installed.
" quick moving between windows
map j
map k
map h
map l
It's really annoying that Vim keeps creating all these temporary and swap files in the current directory so
set backupdir=$HOME/.vim/_backup//
set directory=$HOME/.vim/_temp//
Usually I want Vim's current dir to be the one I opened the file in so I added a mapping just for changing that:
nnoremap ,cd :cd %:p:h:pwd
And what does all this look then? Below is an example screenshot. Obviously I don't keep all those windows open all the time, this is just for demonstration. Left-most panel is Gundo. Top part shows the undo tree and bottom part the changes done in this revision. Next is NERDTree, then code window and the right-most window is TagBar. You can also see OmniCppComplete in action, the window above the code window is showing info about the selected struct member. Also check out the status line
Second example shows more stuff. Left-most window is the CCTree window. It shows a forward trace from main(). Above the code window is vim-fugitive's window after :Gstatus, which shows the same output as "git status" on the command line. Top-most small area is the minibufexplorer. In the code window you can also see that I have added the file header comment. This is shown by gitgutter.
Second example shows more stuff. Left-most window is the CCTree window. It shows a forward trace from main(). Above the code window is vim-fugitive's window after :Gstatus, which shows the same output as "git status" on the command line. Top-most small area is the minibufexplorer. In the code window you can also see that I have added the file header comment. This is shown by gitgutter.
Monday, 25 March 2013
Downgrading packages in Linux (and keeping them down!)
Labels:
linux ubuntu
I kept hitting this same issue every time I updated packages in my Ubuntu at work. We have a certain build system that for some reason requires libtool version 2.2.6 rather than 2.4.2 that comes with Ubuntu. With the newer version, the build fails.
So I kept fixing this with
apt-cache showpkg libtool
sudo apt-get install libtool=2.2.6b-2ubuntu1
Finally I found a solution that should prevent Ubuntu from upgrading the version:
sudo echo "libtool hold" |sudo dpkg --set-selections
The same should work for any package.
So I kept fixing this with
apt-cache showpkg libtool
sudo apt-get install libtool=2.2.6b-2ubuntu1
Finally I found a solution that should prevent Ubuntu from upgrading the version:
sudo echo "libtool hold" |sudo dpkg --set-selections
The same should work for any package.
Wednesday, 2 January 2013
Ubuntu desktop failed to start
New year didn't start so well at work. My Ubuntu box (12.04) wouldn't start any graphical desktops. /var/log/lightdm/x-0-greeter.log showed errors like:
** (at-spi2-registryd:2036): WARNING **: Failed to register client: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files ** (at-spi2-registryd:2036): WARNING **: Unable to register client with session manager CRITICAL: g_error_free: assertion `error != NULL' failed WARNING: IndicatorObject class does not have an accessible description. WARNING: Getting layout failed: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface `com.canonical.dbusmenu' on object at path /com/canonical/indicator/users/menu CRITICAL: ido_calendar_menu_item_set_date: assertion `IDO_IS_CALENDAR_MENU_ITEM(menuitem)' failed MESSAGE: Couldn't find primary device WARNING: invalid cast from `GtkMenuItem' to `IndicatorMenuItem'
Turned out that for some reason ~/.Xauthority was now owned by root. Looked like this was changed during an upgrade I made on Dec 14th. I chowned it back to myself and that solved the issue.
Tuesday, 4 December 2012
Pidgin pounces and viewing files in Linux command line
Couple of quick hints:
I was getting a bit annoyed with all the Pidgin pounces (popups telling me someone has logged in). I tried to remove them by selecting the buddy from the contacts list, "Add buddy pounce" and removing the selections but this did exactly nothing.
The way to remove this is not quite as obvious: Select Tools -> Plugins. Select libnotify in the list and click "Configure plugin". There you can deselect "Buddy signs on" and "Buddy signs off".
An even simplier trick that has helped me with using the command line: I usually search for files, even PDF's and the like with command line tools (find etc) since it's the fastest way. But what to do when you find what you are looking for? Open the directory with Nautilus? Tedious. I added the following to .bashrc:
alias v='xdg-open $1'
After this I can open any file with "v " provided file type has a default application.
I was getting a bit annoyed with all the Pidgin pounces (popups telling me someone has logged in). I tried to remove them by selecting the buddy from the contacts list, "Add buddy pounce" and removing the selections but this did exactly nothing.
The way to remove this is not quite as obvious: Select Tools -> Plugins. Select libnotify in the list and click "Configure plugin". There you can deselect "Buddy signs on" and "Buddy signs off".
An even simplier trick that has helped me with using the command line: I usually search for files, even PDF's and the like with command line tools (find etc) since it's the fastest way. But what to do when you find what you are looking for? Open the directory with Nautilus? Tedious. I added the following to .bashrc:
alias v='xdg-open $1'
After this I can open any file with "v
Tuesday, 6 November 2012
Gnome tweaking
Default Gnome with Code Composer Studio (Texas Instruments' IDE based on Eclipse) has an annoying issue: tooltips are black text on black background. This obviously isn't very nice. The way to fix this is to install gnome-color-chooser and set the tooltip background color from there. Took me ages to figure out that this can't be set inside CCS.
Initially I set this to quite a bright color but Chrome OTOH uses a very light color as the font color, so that wasn't very good either. I have now settled for #C6C636 which works nicely both ways.
I also played around a bit with themes and found that Adwaite Cupertino SL as Window Theme and GTK+ theme and Ubuntu-mono-dark icon theme works best for me. These are installed by unzipping the packages to ~/.themes and selected using gnome-tweak-tool.
Initially I set this to quite a bright color but Chrome OTOH uses a very light color as the font color, so that wasn't very good either. I have now settled for #C6C636 which works nicely both ways.
I also played around a bit with themes and found that Adwaite Cupertino SL as Window Theme and GTK+ theme and Ubuntu-mono-dark icon theme works best for me. These are installed by unzipping the packages to ~/.themes and selected using gnome-tweak-tool.
Friday, 26 October 2012
Thunderbird oddity
Labels:
software,
thunderbird
I had a minor but really annoying issue with Thunderbird: every time I opened a message, it would search for the first occurence of "no" and select that. This meant that if that "no" was in the middle of the message I needed to scroll to top of message.
In the end the reason was simple enough, I had a quick filter set at some point (Ctrl-F), but I can't think of any other application that works quite this way (remembers the setting & applies it automatically).
In the end the reason was simple enough, I had a quick filter set at some point (Ctrl-F), but I can't think of any other application that works quite this way (remembers the setting & applies it automatically).
Subscribe to:
Posts (Atom)


