Search

Tech Tip's : Do's and dont's

Month

June 2015

How to turn Vim into a full-fledged IDE suitable for C/C++/python and many more

If you code a little, you know how handy an Integrated Development Environment (IE) can be. Java, C, Python, they all become a lot more accessible when the IDE software is checking the syntax for you, compiling in the background, or importing the libraries you need. On the other hand, if you are on Linux, you might also know how handy Vim can be when it comes to text editing. So naturally, you would like to get all the features of an IDE from Vim.
In fact, there are quite a few ways to do so. One could think of c.vim which attempts to transform Vim into a C oriented IDE, or Eclim which merges Vim into Eclipse. However, I would like to propose you a more generalist approach using only plugins. You do not want to bloat your editor with too many panels or features. Instead, the plugin approach lets you choose what you put into your Vim. As a bonus, the result will not be language-specific, allowing you to code in anything. So here is my top 10 list of plugins which brings IDE features to Vim.

Bonus: Pathogen

First of all, we might not all be familiar with plugins for Vim, and how to install them. This is why the first plugin that I recommend is Pathogen, as it will allow you to install other plugins more easily. That way, if you want to install another plugin for Vim not listed here, you will be able to do so easily. The official page is really well documented, so go visit it to download and install. From there installing the rest of the plugins will be easy.

1. SuperTab


The first thing we get used to in an IDE is auto-completion feature. For that, I like the plugin SuperTab which comes in quite handy, giving “super powers” to the tabulation key.

2. Syntastic


If you tend to code in more than one language, it is really easy to confuse the syntax at some point. Hopefully, syntastic will check it for you, and tell you if should put brackets or parentheses for that conditional, or remind you that you forgot a semi-colon somewhere.

3. Auto Pairs

Another thing that drives most of the coders insane: did I write this last parenthesis or not?! Everyone hates counting with your finger all the parentheses you put so far. To deal with that, I use Auto Pairs, which automatically inserts and formats parentheses and brackets.

4. NERD Commenter

Then if you are looking for a quick shortcut to comment code, regardless of the programming language, you can turn to NERD Commenter. Even if you are not a programmer, I really really recommend this plugin as it just so efficient while commenting bash scripts or anything in your system.

5. Snipmate

Any programmer knows that a good coders codes, but an excellent one reuses. For that, snipmate will easily insert code snippets into your file and greatly reduce your typing. It comes by default with a lot of snippets for various languages, but you can also easily add yours to the list.

6. NERDTree


To manage a big project, it is always a good idea to split the code into different files. Just basic good coding practices. And to keep all this files in mind, NERDTree is a nice file browser to use straight from Vim.

7. MiniBufferExplorer


To complement a file explorer, there is nothing better than a good buffer manager to have more than one file open at any time. MiniBufferExplorer does the job well and efficiently. It even sets different colors for your buffers as well as easy shortcuts to switch the focus.

8. Tag List


When you have more than one file open at any given time, it is easy to forget what you put in them. To prevent that, Tag List is a code visualizer that will display the different variables and functions written in a nice compact format.

9. undotree


For all of us who like to undo, redo, and undo again some modifications to see how the compilation evolves, undotree is a nice plugin to see your undo and redo edits in a tree. This kind of functionality is clearly not limited to code, so this is a plugin that I like a lot.

10. gdbmgr

Finally, last but not least, anyone needs a good debugger at some point. If you like gdb, then gdbmgr is for you as it integrates the famous debugger to Vim.
To conclude, whether you are an insane coder or not, it is always handy to have a few extra functions of Vim at hand at any time. Like I said in the introduction, you do not have to install all these plugins if you do not need them, or you might want to install different ones. But this is definitely a solid basis.

Advertisements

Install Audacity Audio Editor 2.1.0 in Ubuntu, Linux mint and other debian systems From PPA with resolution to Fails with the Pa_GetStreamHostApiType Error

A new stable release of the free and open-source Audio Editor and Recorder, Audacity 2.1.0, was announced a few days ago.
The new release brings Real-Time Preview feature and lots of improvements and bug fixes. Here’s the release highlights:

  • For a long time, we have wanted Real-Time Preview for effects. It seemed nearly unachievable without major restructuring. But with Audacity 2.1.0, we have it in LADSPA, VST, and Audio Unit (OS X) effects! Thanks to Leland Lucius for these great new capabilities!
  • Much improved Noise Reduction effect replaces Noise Removal. Thanks to new contributor Paul Licameli!
  • Lots of other improvements to effects, also thanks to Leland, including:
    • VST: FXB preset banks, hosting multiple plugins
    • All effects can now be used in Chains, and can be sorted on name, publisher, or class.
    • Most Nyquist effects now have Preview button.
  • Redesigned Meter Toolbars show a lot more information in smaller area. Thanks, Leland Lucius and James Crook!
  • Spectral Selection in Spectrogram view. Thanks to Paul Licameli!

For more details, see the release note.
Audacity 2.1.0 in Ubuntu
Install / Upgrade to Audacity 2.1.0 in Ubuntu / Linux Mint:
Since Audacity Team only provides an daily build PPA with latest development packages and Ubuntu repositories still provide old versions in Software Center, I’ve uploaded Audacity 2.1.0 into this PPA.
So far, Ubuntu 12.04, Ubuntu 14.04, Ubuntu 14.10, Ubuntu 15.04, Linux Mint 13 and 17 are supported.
1. To add the PPA, open terminal from the Dash, Menu, or by pressing Ctrl+Alt+T on keyboard. When it opens, run command:

sudo add-apt-repository ppa:ubuntuhandbook1/audacity
 

2. After adding the PPA, you can upgrade the editor using Software Updater (or Updater Manager).
Or just run below commands one by one in terminal:

sudo apt-get update

sudo apt-get install audacity audacity-dbg

Try Running audacity from Terminal by typing:

sudo audacity

If Audacity loads for you alright then skip the rest of this post to save your time.

Most users face ” Fails with the Pa_GetStreamHostApiType Error “

audacity: symbol lookup error: audacity: undefined symbol: Pa_GetStreamHostApiType

The undefined symbol, Pa_GetStreamHostApiType, I knew that my PortAudio installation had messed something up. Thanks to the ubuntu forum for providing a solution to this issue which is simple and as follows
So, to see the shared library dependencies of Audacity, I did:

 
ldd /usr/bin/audacity | grep portaudio

and sure enough, the dependency was pointing to /usr/local/lib.

The solution was to remove the libportaudio files from the /usr/local/lib, by doing:

 
rm -rf /usr/local/lib/libportaudio*
ldconfig

And, then try running Audacity and voila!! There you go with a fresh installation of the latest Audacity in Ubuntu, linux mint and debian systems

 
 
 

Writing your research paper in Latex: Useful commands and tips

To PDF from tex select PDFLatex from Quick Build, (the default option will take a long time or hang during building process)
2. Bibtex problem – Question mark instead of number for reference

To update you bibtex citations, select BibTex from Quick Build and compile, then select PDFLatex and compile twice to update the citation numbers in the PDF. Rebuilding it a few times replace the .aux and .bbl files that were made when you used before.
Common citation mistake , putting spaces between comma seprated bibtex keys:

\cite{zhao2003face,samal1992automatic,yang2002detecting}

Don’t put spaces before the keys!
3. How to center cell contents of a LaTeX table whose columns have fixed widths?

Use

\usepackage{array}

in the preamble
them this:

1
\begin{tabular}{| >{\centering\arraybackslash}p{.5cm} | >{\centering\arraybackslash}p{8cm} |}

note that “m” for fixed with column is provided by the array package, and will give you vertical centering (if you don’t want this just use “p”)
4. Latex command reference
To find the latex command for different symbols click here and here.
5. Big Parenthesis in an Equation
replace ( with \left( and ) with \right), which automatically expand to fit the material between them. Note that every \left… requires a \right… (but the type of bracket may be different, i.e. \left(…\right] also works).
6. In-line equations
There are three essentially equivalent ways to code in LaTeX the same anti-derivative formula from calculus as an in-line equation. In the first case, mathematics mode is delimited by dollar signs.
This is an in-line $\int \frac{d\theta}{1+\theta^2} =
\tan^{-1}\theta+C$ equation.
In the next case, mathematics mode is delimited by the \( and \) pair.

This is an in-line \(\int\frac{d\theta} {1+\theta^2}=
\tan^{-1} \theta+C\) equation.

In the third case, mathematics environment is delimited by the \begin{math} and \end{math} pair.

This is an in-line \begin{math}\int\frac
{d\theta}{1+\theta^2} = \tan^{-1}
\theta+ C\end{math} equation.

The advantage of using a dollar sign to delimit mathematics mode is that it is easy to type. On the other hand, using different opening and closing delimiters facilitates error detection and correction.
7. Scale image to page width
Use \textwidth for the width of the text block, and \paperwidth if you want to fit it into the paper width. You could also use \linewidth if you want to fit the image within the line width, which may vary depending on the environment you’re in (for example, within a list like enumerate).

\begin{figure}[!htbp]
\label{fig:1}
\centering
\includegraphics[width=\textwidth]{sample-faces.png}
\caption{Sample images from (a) FERET, (b) Indian and (c) in-house database}
\end{figure}

8. Quotation marks

use two ‘ signs instead of one ” sign, like this “quoted”.
9. Tables: How to span over variable number of cells

Use multicolumn. Example –

\begin{table}[!htbp]
% table caption is above the table
\caption{The recognition accuracy of different orientation featured Gabor phase representations for 200 subjects.}
\label{tab:1}       % Give a unique label
% For LaTeX tables use
\begin{tabular}{|>{\centering\arraybackslash}p{.25cm}|>{\centering\arraybackslash}p{8.25cm}|>{\centering\arraybackslash}p{1.5cm}|>{\centering\arraybackslash}p{.5cm}|>{\centering\arraybackslash}p{.5cm}|>{\centering\arraybackslash}p{.5cm}|}
\hline
No. & Description & Complexity & \multicolumn{3}{|c|}{Recognition Accuracy (\%)}  \\
\hline
...

10. Squeezing space with LaTeX
Make your text block as big as pos­si­ble. The sim­plest way to do that is using the geom­e­try package:

\usepackage[text={16cm,24cm}]{geometry}

More on this here.
Following code will set the space between floats (including caption) and the surrounding text to 0pt, which is stretchable by 2pt.

\setlength{\intextsep}{0pt plus 2pt}   % default value 12pt plus 2pt minus 2pt,

11. Float problem – How to use the placement options [t], [h] with figures?

In short, the placement options means allowing placement at certain locations:
h means here: Place the figure in the text where the figure environment is written, if there is enough room left on the page
t means top: Place it at the top of a page.
b means bottom: Place it at the bottom of a page.
p means page: Place it on a page containing only floats, such as figures and tables.
! allows to ignore certain parameters of LaTeX for float placement, for example:
\topfraction: maximal portion of a page (or column resp., here and below), which is allowed to be used by floats at its top, default 0.7
\bottomfraction: maximal portion of a page, which is allowed to be used by floats at its bottom, default value 0.3
\textfraction: minimal portion of a page, which would be used by body text, default value 0.2
\floatpagefraction: minimal portion of a float page, which has to be filled by floats, default value 0.2. This avoids too much white space on float pages.
topnumber: maximal number of floats allowed at the top of a page, default 2
bottomnumber: maximal number of floats allowed at the bottom of a page, default 1
totalnumber: maximal number of floats allowed at whole page, default 3
This means, if you add !, the float will be placed if it fits onto the current page and if there aren’t further waiting float objects of the same type, ignoring predefined propotions of text and floats as above. Such floats are also called bang floats.
Fractions can be changed by \renewcommand, numbers are counters which can be changed by \setcounter, further there are lenghts for spacing before, after, and between floats. This gives an impression how LaTeX automatically takes care of sensible figure placement, which you could adjust yourself – or override by ! if meaningful.
These options can be combined, such as [!htbp]. Their order doesn’t matter, LaTeX itself attempts using allowed places in order h, t, b, p, even if [pbth] was used.
You should even consider combining as many options as sensible. If a figure cannot be placed, it blocks subsequent figures. This can be a reason why figures end up very late, as you noticed. Specifically, ensure that the figures are not too big to fit into the margins.
12. How do I order citations by appearance using BibTeX?

Use

\bibliographystyle{ieeetr}

13. Multiline equations
Use

\usepackage{amsmath}

and put aligned command around the equations

\begin{equation}
\begin{aligned}
H_{\mu,v,r}=(h_{\mu,v,r} (0),h_{\mu,v,r} (1),\dots,h_{\mu,v,r} (B-1) ) \\
\mbox{where, } h_{\mu,v,r}(i)=\sum_{(x,y)\in R_r}\delta(LGBP_{\mu,v}(x,y)-i),i=0,1,\dots,B-1
\end{aligned}
\end{equation}

14. Text Embedded in Displayed Equations

Text can be embedded in displayed equations (in LaTeX) by using \mbox{embedded text}. For example,

\begin{equation}
\begin{aligned}
H_{\mu,v,r}=(h_{\mu,v,r} (0),h_{\mu,v,r} (1),\dots,h_{\mu,v,r} (B-1) ) \\
\mbox{where, } h_{\mu,v,r}(i)=\sum_{(x,y)\in R_r}\delta(LGBP_{\mu,v}(x,y)-i),i=0,1,\dots,B-1
\end{aligned}
\end{equation}

15. Combining multiple image files into a single figure
a) approach using tabular

\documentclass[a4paper,12pt]{article}
\usepackage{graphicx}
\usepackage{subcaption}
 
\begin{document}
\begin{figure}[htb]
\centering
  \begin{tabular}{@{}cccc@{}}
    \includegraphics[width=.23\textwidth]{example-image-a} &
    \includegraphics[width=.23\textwidth]{example-image-b} &
    \includegraphics[width=.23\textwidth]{example-image-c} &
    \includegraphics[width=.23\textwidth]{example-image}   \\
    \includegraphics[width=.23\textwidth]{example-image-a} &
    \includegraphics[width=.23\textwidth]{example-image-b} &
    \includegraphics[width=.23\textwidth]{example-image-c} &
    \includegraphics[width=.23\textwidth]{example-image}   \\
    \includegraphics[width=.23\textwidth]{example-image-a} &
    \includegraphics[width=.23\textwidth]{example-image-b} &
    \includegraphics[width=.23\textwidth]{example-image-c} &
    \includegraphics[width=.23\textwidth]{example-image}   \\
    \multicolumn{4}{c}{\includegraphics[width=.23\textwidth]{example-image-a}}
  \end{tabular}
  \caption{This is   some figure side by side}
\end{figure}
\end{document}

output:
latex_fig1
b) using subcaption that provides a subfigure command.

\documentclass[a4paper,12pt]{article}
\usepackage{graphicx}
\usepackage{subcaption}
 
\begin{document}
\begin{figure}[htb]
\centering
  \begin{subfigure}[b]{.24\linewidth}
    \centering
    \includegraphics[width=.99\textwidth]{example-image-a}
    \caption{A subfigure}\label{fig:1a}
  \end{subfigure}%  
  \begin{subfigure}[b]{.24\linewidth}
    \centering
    \includegraphics[width=.99\textwidth]{example-image-b}
    \caption{A subfigure}\label{fig:1b}
  \end{subfigure}% 
  \begin{subfigure}[b]{.24\linewidth}
    \centering
    \includegraphics[width=.99\textwidth]{example-image-c}
    \caption{A subfigure}\label{fig:1c}
  \end{subfigure}% 
  \begin{subfigure}[b]{.24\linewidth}
    \centering
    \includegraphics[width=.99\textwidth]{example-image}
    \caption{A subfigure}\label{fig:1d}
  \end{subfigure}\\%  
  \begin{subfigure}[b]{.24\linewidth}
    \centering
    \includegraphics[width=.99\textwidth]{example-image-a}
    \caption{A subfigure}\label{fig:1e}
  \end{subfigure}%
  \begin{subfigure}[b]{.24\linewidth}
    \centering
    \includegraphics[width=.99\textwidth]{example-image-b}
    \caption{A subfigure}\label{fig:1f}
  \end{subfigure}%
  \begin{subfigure}[b]{.24\linewidth}
    \centering
    \includegraphics[width=.99\textwidth]{example-image-c}
    \caption{A subfigure}\label{fig:1g}
  \end{subfigure}%
  \begin{subfigure}[b]{.24\linewidth}
    \centering
    \includegraphics[width=.99\textwidth]{example-image}
    \caption{A subfigure}\label{fig:1h}
  \end{subfigure}\\%    
  \begin{subfigure}[b]{.24\linewidth}
    \centering
    \includegraphics[width=.99\textwidth]{example-image-a}
    \caption{A subfigure}\label{fig:1i}
  \end{subfigure}%
  \begin{subfigure}[b]{.24\linewidth}
    \centering
    \includegraphics[width=.99\textwidth]{example-image-b}
    \caption{A subfigure}\label{fig:1j}
  \end{subfigure}%
  \begin{subfigure}[b]{.24\linewidth}
    \centering
    \includegraphics[width=.99\textwidth]{example-image-c}
    \caption{A subfigure}\label{fig:1k}
  \end{subfigure}%
  \begin{subfigure}[b]{.24\linewidth}
    \centering
    \includegraphics[width=.99\textwidth]{example-image}
    \caption{A subfigure}\label{fig:1l}
  \end{subfigure}\\% 
  \begin{subfigure}[b]{.24\linewidth}
    \centering
    \includegraphics[width=.99\textwidth]{example-image}
    \caption{A subfigure}\label{fig:1m}
  \end{subfigure}%   
  \caption{This is   lot of figures arranged side by side in matrix form with captions for each and a main caption}\label{fig:1}
\end{figure}
\end{document}

output:
latex_fig2
c) Using new subfig (subfigure is obsolete):

\documentclass[a4paper,12pt]{article}
\usepackage{graphicx}
\usepackage{subfig}
 
 
\begin{document}
\begin{figure}[htb]
\centering
  \subfloat[A subfigure]{%
    \includegraphics[width=.24\textwidth]{example-image-a}}\hfill
  \subfloat[A subfigure]{%
    \includegraphics[width=.24\textwidth]{example-image-b}}\hfill
  \subfloat[A subfigure]{%
    \includegraphics[width=.24\textwidth]{example-image-c}}\hfill
  \subfloat[A subfigure]{%
    \includegraphics[width=.24\textwidth]{example-image}}\\
  \subfloat[A subfigure]{%
    \includegraphics[width=.24\textwidth]{example-image-a}}\hfill
  \subfloat[A subfigure]{%
    \includegraphics[width=.24\textwidth]{example-image-b}}\hfill
  \subfloat[A subfigure]{%
    \includegraphics[width=.24\textwidth]{example-image-c}}\hfill
  \subfloat[A subfigure]{%
    \includegraphics[width=.24\textwidth]{example-image}}\\
  \subfloat[A subfigure]{%
    \includegraphics[width=.24\textwidth]{example-image-a}}\hfill
  \subfloat[A subfigure]{%
    \includegraphics[width=.24\textwidth]{example-image-b}}\hfill
  \subfloat[A subfigure]{%
    \includegraphics[width=.24\textwidth]{example-image-c}}\hfill
  \subfloat[A subfigure]{%
    \includegraphics[width=.24\textwidth]{example-image}}\\
  \subfloat[A subfigure]{%
    \includegraphics[width=.24\textwidth]{example-image}}
  \caption{This is   lot of figures arranged side by side in matrix form with captions for each and a main caption}\label{fig:1}
\end{figure}
\end{document}

16. Inserting n number of blank lines
Use

\vspace*{n * \baselineskip} % empty line

Where n=\{1,2,3..\} (an integer)

Create a free website or blog at WordPress.com.

Up ↑