Monday, September 27, 2010

Executing commands in shell and accepting the output in Vim

Source: http://www.linux.com/archive/feed/57727

:r ! ls

It is also possible to select certain lines in Vim with v, V or ctrl+v and send it to a Bash command. The selected lines (input for Bash command) will be replaced by the output from Bash. Typical line number specification is also allowed.

:5,7 ! xargs ls -alh

Friday, September 24, 2010

Forcing Floating Point Calculation in Python

Sources:
  • http://docs.python.org/tutorial/floatingpoint.html
  • http://stackoverflow.com/questions/1267869/how-can-i-force-division-to-be-floating-point-in-python

Method-1:Just write any of the parameters in the division operation in floating-point format (eg. 4.0, 3.0)
>>> 4.0 /  3
or, >>> 4 / 3.0

Method-2:
from __future__ import devision
Method-3:
>>> from decimal import Decimal
>>> Decimal(2.675)
Decimal('2.67499999999999982236431605997495353221893310546875')

Tuesday, September 21, 2010

Latex: Incorrect references for Tables, Figures etc.

Just put the \label{} inside \caption{}. 
See the following example.

\begin{table}[!ht]
\begin{center}
\caption{ \label{tab:blah} Blah Caption}
\begin{tabular}{c|c|c|c||c} A1 & B1 & C1 & D1 & E1 & F1 & G1 & & H1
\hline  
aa &bb &cc &dd &ff \\  
aa &bb &cc &dd &ff \\
\end{tabular}
\end{center}
\end{table}

Monday, September 20, 2010

Installing DMG or PKG from command-line on Mac, Apple TV

  • mounting dmg
hdid package.dmg
or, hdiutil attach package.dmg
or, hdiutil mount package.dmg
  • change directory
cd /Volumes/package/
  • install pkg
sudo installer -verbose -pkg package.pkg -target /
or, sudo /usr/sbin/installer -verbose -pkg package.pkg -target /
  • unmounting dmg
hdiutil detach /Volumes/package
or, hdiutil detach /Volumes/package -force




Wednesday, September 8, 2010

Install Windows from portable USB drive

This Windows tool [1] can apparently convert a Windows CD/ISO image (and also other Live CD/DVD images) into a boot-able USB stick. For whatever it is worth, it's Good to know there exists such a thing for Windows installation.

[1] http://www.wintoflash.com/home/en/