Ah, underfull and overfull hboxes and vboxes in latex.....
You can do certain things:
a) if they look fine - disregard those warnings
b) for overfull/underfull hboxes, you need to rewrite the line that has the problem (latex will report it), or resize the figures (if they are the cause) accordingly
c) for overfull/underfull vboxes - you need to either allow some flexibility in the interline and/or interparagraph spacing (e.g, give \baselineskip, \lineskip, and
\parskip some stretchability), or else tell LaTeX that you want \raggedbottom pages. Underfull boxes are a consequence of not enough flexibility in the vertical spacing, and lines that don't happen to exactly fill the page size. Just type \raggedbottom at the beginnning in the preamble, and that should cure underful vboxes.
Wednesday, November 15, 2006
Monday, November 13, 2006
Kill by name!
This is an extremely useful command that I use all the time.
I assume everyone is familiar with the linux "kill" command.
For whatever reason, I had started 10 instances of a command named "xycommand". And, now I want to kill all the 10 instances.
If I wer using "kill", I would have to first do a "ps | grep xycommand" to identify the process ids, and kill each instance separely.
An efficient way of accomplishing the same is to use the "killall" command.
Thus,
$killall xycommand
kills off all the instances with the name xycommand.
I assume everyone is familiar with the linux "kill" command.
For whatever reason, I had started 10 instances of a command named "xycommand". And, now I want to kill all the 10 instances.
If I wer using "kill", I would have to first do a "ps | grep xycommand" to identify the process ids, and kill each instance separely.
An efficient way of accomplishing the same is to use the "killall" command.
Thus,
$killall xycommand
kills off all the instances with the name xycommand.
Sunday, November 12, 2006
ps pissing you off?
The linux "ps" command is very useful as we all know. However, it just pains me when it strips off the larger commands.
Thus if you wanted to do something like
ps aux | grep "xxcommand"
it will only grep through the length that is fitted in the screen.
Thus if you have a command like the foll., no matches will be found:
xxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxcommand
What is the workaround? Use --columns along with ps to specify the number of columns that is outputted. Normally it defaults to tthe number of columns in the terminal leading to the above problem.
e.g.
ps aux --columns=1000 | grep "xxcommmand" ....and your o/p will be what you are seeking.
Peace with ps...
Thus if you wanted to do something like
ps aux | grep "xxcommand"
it will only grep through the length that is fitted in the screen.
Thus if you have a command like the foll., no matches will be found:
xxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxcommand
What is the workaround? Use --columns along with ps to specify the number of columns that is outputted. Normally it defaults to tthe number of columns in the terminal leading to the above problem.
e.g.
ps aux --columns=1000 | grep "xxcommmand" ....and your o/p will be what you are seeking.
Peace with ps...
Tuesday, October 24, 2006
Use control to delete faster!
Ctrl-Backspace will delete the entire word to the left of your cursor in one keystroke, and Ctrl-Delete will delete the entire word to the right of the cursor. I was surprised to find that this works across all text editors/composers in linux!
For example, if I am typing a email within opera, I can use this trick to make fast edits.....in fact I can do this within blogger too...as I am editing this post..
For example, if I am typing a email within opera, I can use this trick to make fast edits.....in fact I can do this within blogger too...as I am editing this post..
Wednesday, October 11, 2006
The power of finding!
Everyone with a *nix box has used the "find" command. However, the keyword here is exploring its full potential.
Lets start with the basics:
To find files recursively, we execute
$find . -name "*.txt"
Should find all .txt files recursively starting from the directory it was executed in. If you want to search in some other directory replace the "." e.g.
$find ~/Documents -name "*txt"
Now for the fun part...
Did you know that you can tune the find command just to look for directories/links?
e.g. I executed the foll. in my home directory
$find . -type d -name "d*"
And obtained the foll:
./.gconf/desktop
./.gconf/desktop/gnome/screen/default
./.gnome2/panel2.d/default
./downloads
./.wine/dosdevices
./.wine/drive_c
./.wine/drive_c/windows/system32/drivers
./.wine/drive_c/Program Files/FreeMind/backup/doc
./.wine/drive_c/Program Files/wine_gecko/res/dtd
./.openoffice.org2/user/registry/data
./.openoffice.org2/user/database
./.openoffice.org2/user/psprint/driver
Cool, isn't it? But, we are not done yet....
Try this:
$find ~/Documents -size +128M
Nice, it finds file greater than 128MB. Ever think what the + sign was for? There must be a - equivalent, right?
Try this:
$find ~/Documents -size -128M
This finds files smaller than 128M
Finish up by trying this:
$find ~/Documents -size -128M -size +16M
Do remember when you type multiple args, you are in effect ANDing them, to or them type a -o before the args, and to perform an inverse type "!"
If you have been following this blog, I have shown you in the past how to combine find with xargs to perform actions on the files you found.
Some more examples
$find ~/Documents -name "*.jpg" -name "Pictures" | xargs -0 mv ~/tmp
$find ~/Documents -name "*.jpg" -o "*.gif" -o -name "Pictures" | xargs -0 mv ~/tmp
$find . -user mani -name *.mpg ! -name tosee* | xargs -0 rm
Hope I have helped you find the power in find!
Lets start with the basics:
To find files recursively, we execute
$find . -name "*.txt"
Should find all .txt files recursively starting from the directory it was executed in. If you want to search in some other directory replace the "." e.g.
$find ~/Documents -name "*txt"
Now for the fun part...
Did you know that you can tune the find command just to look for directories/links?
e.g. I executed the foll. in my home directory
$find . -type d -name "d*"
And obtained the foll:
./.gconf/desktop
./.gconf/desktop/gnome/screen/default
./.gnome2/panel2.d/default
./downloads
./.wine/dosdevices
./.wine/drive_c
./.wine/drive_c/windows/system32/drivers
./.wine/drive_c/Program Files/FreeMind/backup/doc
./.wine/drive_c/Program Files/wine_gecko/res/dtd
./.openoffice.org2/user/registry/data
./.openoffice.org2/user/database
./.openoffice.org2/user/psprint/driver
Cool, isn't it? But, we are not done yet....
Try this:
$find ~/Documents -size +128M
Nice, it finds file greater than 128MB. Ever think what the + sign was for? There must be a - equivalent, right?
Try this:
$find ~/Documents -size -128M
This finds files smaller than 128M
Finish up by trying this:
$find ~/Documents -size -128M -size +16M
Do remember when you type multiple args, you are in effect ANDing them, to or them type a -o before the args, and to perform an inverse type "!"
If you have been following this blog, I have shown you in the past how to combine find with xargs to perform actions on the files you found.
Some more examples
$find ~/Documents -name "*.jpg" -name "Pictures" | xargs -0 mv ~/tmp
$find ~/Documents -name "*.jpg" -o "*.gif" -o -name "Pictures" | xargs -0 mv ~/tmp
$find . -user mani -name *.mpg ! -name tosee* | xargs -0 rm
Hope I have helped you find the power in find!
Tuesday, September 26, 2006
Going deep?
Every so often, we have a longish path that we navigate to open a file. e.g.
$vim ~/xxx/yyy/ddd/eee/fff/file1.txt
While editing, we realise we want to open file2.txt which is in the same directory as file1.txt
I find it very annoying have to type :sp ~/xxx/yyy/.....
The other option is to close vim, navigate to the said directory and open the files, which too I find annoying.
There is solace - two solutions
1) Use the command :cd %:h in vim 6 to navigate vim to the particular directory the file that you are editing is placed in. Now you just have to do a :e file2.txt to open the other files.
2) I don't like that solution either because, I change my vim's path. What if I want to open a file from the original place I started vim. Add the following to your vimrc:
if has("unix")
map ,e :e=expand("%:p:h") ."/"
else
map ,e :e=expand("%:p:h") ."\\"
endif
Now in command mode, press ",e", presto, the directory path gets filled in! You can continue to use :e for the original directory you started vim in.
$vim ~/xxx/yyy/ddd/eee/fff/file1.txt
While editing, we realise we want to open file2.txt which is in the same directory as file1.txt
I find it very annoying have to type :sp ~/xxx/yyy/.....
The other option is to close vim, navigate to the said directory and open the files, which too I find annoying.
There is solace - two solutions
1) Use the command :cd %:h in vim 6 to navigate vim to the particular directory the file that you are editing is placed in. Now you just have to do a :e file2.txt to open the other files.
2) I don't like that solution either because, I change my vim's path. What if I want to open a file from the original place I started vim. Add the following to your vimrc:
if has("unix")
map ,e :e
else
map ,e :e
endif
Now in command mode, press ",e", presto, the directory path gets filled in! You can continue to use :e for the original directory you started vim in.
Get a load of vimdiff!
I assume that being any *nix junkie, you would know what diff is used for. But plain diff sucks - it is not very clear as to which files had what in them. One first executes
Try vimdiff instead - the color coding of differences is very nice,(especially when vim folds all the code that is common).
Alternately, go for the gui - gvimdiff.
Usage(there is just one step here):
$gvimdiff file1 file2
Here is another goodie - you can edit file1 or file2 when they are opened in gvimdiff. Thus, you can make one file look like another while viewing the differences - how cool is that?
Lets make it more better, eh?
Assume you are editing file1 using vim, and now you want to do a diff with file2
All what you need is to type the following commands within vim!
:sp file2
:windo diffthis
Try vimdiff instead - the color coding of differences is very nice,(especially when vim folds all the code that is common).
Alternately, go for the gui - gvimdiff.
Usage(there is just one step here):
$gvimdiff file1 file2
Here is another goodie - you can edit file1 or file2 when they are opened in gvimdiff. Thus, you can make one file look like another while viewing the differences - how cool is that?
Lets make it more better, eh?
Assume you are editing file1 using vim, and now you want to do a diff with file2
All what you need is to type the following commands within vim!
:sp file2
:windo diffthis
Monday, September 25, 2006
Workaround for globbing or pattern matching on http with Wget
Don't you love wget? The fact that you don't need a browser to save a file.......hmmm....niiiice.
You might have noticed that you can do something like
$wget ftp://ftpserver.com/*.pdf
and it retrieves all *.pdf files for you
However, (you must have expected a catch - there always is) you cannot do the same with http.
i.e.
$wget http://httpserver.com/*.pdf
will give you an error!
This is because http retrieval does not support globbing! (What is globbing? - it is just using the *.pdf or any of the regexp kind of thingies [ ] )
What is your workaround? Use the command below:
$wget -r -l1 --no-parent -A.pdf http://httpserver.com/
-r -l1 means to retrieve recursively , with maximum depth of 1. -
-no-parent means that references to the parent directory are ignored
-A.pdf means to download only the gif files.
-A "*.pdf" would have worked too.
Happy globbing with wget on http servers too from today .... :)
You might have noticed that you can do something like
$wget ftp://ftpserver.com/*.pdf
and it retrieves all *.pdf files for you
However, (you must have expected a catch - there always is) you cannot do the same with http.
i.e.
$wget http://httpserver.com/*.pdf
will give you an error!
This is because http retrieval does not support globbing! (What is globbing? - it is just using the *.pdf or any of the regexp kind of thingies [ ] )
What is your workaround? Use the command below:
$wget -r -l1 --no-parent -A.pdf http://httpserver.com/
-r -l1 means to retrieve recursively , with maximum depth of 1. -
-no-parent means that references to the parent directory are ignored
-A.pdf means to download only the gif files.
-A "*.pdf" would have worked too.
Happy globbing with wget on http servers too from today .... :)
Friday, September 22, 2006
Make bash behave like vi!
If you are like me, you like vi and vim!
Don't you wish every editor in the world had a vi option?
Well, you have something for bash prompts!
To make bash prompt behave like vi, just do
set -o vi
at the prompt, or add the line to your .bashrc.
Now, the wonders of vi are usable at your bash prompt (type something, press ESC and now press 0, it should take you the first letter, now press $, it should take you to the end)...
vi ROCKS! Happy vi..er....happy vi-ing!
{And I take another step into the deep dark side of geekiness :( }
Don't you wish every editor in the world had a vi option?
Well, you have something for bash prompts!
To make bash prompt behave like vi, just do
set -o vi
at the prompt, or add the line to your .bashrc.
Now, the wonders of vi are usable at your bash prompt (type something, press ESC and now press 0, it should take you the first letter, now press $, it should take you to the end)...
vi ROCKS! Happy vi..er....happy vi-ing!
{And I take another step into the deep dark side of geekiness :( }
Thursday, September 21, 2006
Go back in time with Vim 7.0
In Vim 7.0, a feature has been included which allows a user to jump back or forward to any point of editing.
For example, I am editing a document and after a couple of minutes (say 10 min), I realise that I have made a mistake. I can easily take the document to a point 10 minutes back by using the command-
:earlier 10m
Or for that matter, move to a point 5 seconds ahead by using the command:
:later 5s
For example, I am editing a document and after a couple of minutes (say 10 min), I realise that I have made a mistake. I can easily take the document to a point 10 minutes back by using the command-
:earlier 10m
Or for that matter, move to a point 5 seconds ahead by using the command:
:later 5s
Friday, September 15, 2006
Changing aspect ratio in gnuplot
Have too many benchmarks or simulation points? Want to change the aspect ratio?
To change the size of the eps image, use "set size 1.0,2.0" (where 1.0 and 2.0 are multiplied by the default 5 inch width and 3.5 inch height)in gnuplot. use "set size" to restore defaults.
To change the size of the eps image, use "set size 1.0,2.0" (where 1.0 and 2.0 are multiplied by the default 5 inch width and 3.5 inch height)in gnuplot. use "set size" to restore defaults.
Wednesday, September 13, 2006
Space inside math environment in LaTeX
Inside the math environment($-$ ring a bell?), LaTeX ignores the spaces you type and puts in its own spacing that it thinks is best.
To cheat the system, use the following:
\; - a thick space
\: - a medium space
\, - a thin space
\! - a negative thin space
To cheat the system, use the following:
\; - a thick space
\: - a medium space
\, - a thin space
\! - a negative thin space
Converting windows text files to linux compatible text files and vice versa
Don't you hate it when the line breaks get screwed up when you open a windows text file in linux, or a linux text file in windows?
This is the solution:
To convert a Windows file to *nix, enter:
dos2unix winfile.txt unixfile.txt
To convert a *nix file to Windows, enter:
unix2dos unixfile.txt winfile.txt
This is the solution:
To convert a Windows file to *nix, enter:
dos2unix winfile.txt unixfile.txt
To convert a *nix file to Windows, enter:
unix2dos unixfile.txt winfile.txt
Thursday, September 07, 2006
See all available styles in gnuplot
Within the gnuplot window, type "test". It should bring up a plot showing all available colors and styles.
Monday, July 24, 2006
The very exuberant Ctags!
Do you program in vim? Have you heard of exuberant ctags? No, then download it to your machine immediately, if ctags is not already in your system http://ctags.sourceforge.net/
Trust me - this simple program can save hours of frustration.
If you have a directory called source and the directory and its subdirectories contain source code - type "ctags -R" . This creates a listing of which functions are in which files. Thus if you are editing a file, and find a function which is defined in another, all what you have to do is "Ctrl - ]" to jump to its definition. "Ctrl -T" will take you back. Now, if the definition is in the same file, then you might as well just type "gD"within vim to go to it. (This is a vim capability).
Some more useful stuff with vim and Ctags:
vim -t tag Start vim and position the cursor at the file and line where "tag" is defined.
:ta tag - Find a tag.
Ctrl-] - Find the tag under the cursor.
Ctrl-T - Return to previous location before jump to tag (not widely implemented).
Trust me - this simple program can save hours of frustration.
If you have a directory called source and the directory and its subdirectories contain source code - type "ctags -R" . This creates a listing of which functions are in which files. Thus if you are editing a file, and find a function which is defined in another, all what you have to do is "Ctrl - ]" to jump to its definition. "Ctrl -T" will take you back. Now, if the definition is in the same file, then you might as well just type "gD"within vim to go to it. (This is a vim capability).
Some more useful stuff with vim and Ctags:
vim -t tag Start vim and position the cursor at the file and line where "tag" is defined.
:ta tag - Find a tag.
Ctrl-] - Find the tag under the cursor.
Ctrl-T - Return to previous location before jump to tag (not widely implemented).
Thursday, July 20, 2006
Finding indices of multidimensional arrays in python
Python is great for a lot of things. Unfortunately, there is no easy direct way to find indices of multidimensional arrays.
Example - You have a list(or array) A[5][5]. It is represented as [ [1,1,1,1,1], [2,34,23,1,4]....[1,34,54,44.1]] in python.
If you want to find the minimum in the list and find indices of the list, you have to proceed as follows:
mintest = 100000 # Some large number
# Instead of '4' in the below for loop, you can use the length attribute of the array.
for iter in range(0,4):
min1 = min(A[iter])
if (mintest > min1):
row_index = citer
col_index = A[iter][:].index(min(A[iter]))
mintest = min1
print "Row, column indices of the minimum value %d in the array are %d,%d" % (mintest, row_index, col_index)
Example - You have a list(or array) A[5][5]. It is represented as [ [1,1,1,1,1], [2,34,23,1,4]....[1,34,54,44.1]] in python.
If you want to find the minimum in the list and find indices of the list, you have to proceed as follows:
mintest = 100000 # Some large number
# Instead of '4' in the below for loop, you can use the length attribute of the array.
for iter in range(0,4):
min1 = min(A[iter])
if (mintest > min1):
row_index = citer
col_index = A[iter][:].index(min(A[iter]))
mintest = min1
print "Row, column indices of the minimum value %d in the array are %d,%d" % (mintest, row_index, col_index)
Tuesday, July 18, 2006
Execute the "touch" command recursively
If you want to update the access time of a set of files, you can use
touch *
However, if you want to touch files and directories recursively, the touch command does not have a built in option. Instead use this command to achieve the same result:
If XXX is the dir within which you want to touch recursively, execute the foll. (Give the full path to XXX as needed)
find XXX | xargs touch
touch *
However, if you want to touch files and directories recursively, the touch command does not have a built in option. Instead use this command to achieve the same result:
If XXX is the dir within which you want to touch recursively, execute the foll. (Give the full path to XXX as needed)
find XXX | xargs touch
Sunday, July 16, 2006
Search as you go in vim
If you want to search for television, and you want the words to be highlighted as you type in "television" , the following command will help you
:set incsearch
Add the following line to your .vimrc or .gvimrc file and you are all set every time you vim!
set incsearch
:set incsearch
Add the following line to your .vimrc or .gvimrc file and you are all set every time you vim!
set incsearch
Friday, July 14, 2006
Grammar checker for latex
Love latex but miss word's grammar checking facility?
There is one (albeit simple) option - Queequeg, A Tiny English Grammar Checker (http://queequeg.sourceforge.net/index-e.html)
Follow the installation instructions given in their website.
In their steps they say "make dict WORDNET=/src/wordnet/dict".
For whatever reason this does not work if you want another directory. Just open the Makefile and set the directory you want WORDNET to point.
There is one (albeit simple) option - Queequeg, A Tiny English Grammar Checker (http://queequeg.sourceforge.net/index-e.html)
Follow the installation instructions given in their website.
In their steps they say "make dict WORDNET=/src/wordnet/dict".
For whatever reason this does not work if you want another directory. Just open the Makefile and set the directory you want WORDNET to point.
How to get a syntax usb-400 wireless card to work with any linux distro
You bought the cheapo wireless card. It works well enought with windows, but in *nix, there is a problem. You have scourged various websites with specifics for varioux linux distros, saw something about hotplug, yada, yada yada...nothing works.
The foll. will get you through in MOST linux distros (have tried it on simplymepis, ubuntu, redhat 9.0)
Obtain the linux-wlan driver for your card (http://www.linux-wlan.org/) and install it. However, you need to install the kernel headers (no, this is not recompiling the kernel) before installing linux-wlan.
In debian distros, it is as simple as knowing your kernel (uname -a should give you that), followed by an apt-get install kernel-header.... (choose the right header corresponding to uname -a)
Now, tar unzip, your linux-wlan drivers file, do a configure (and pray to God you have everything required in your system) , a make (while selling Satan your soul for being able to build) , and finally a make install. Do all this as root to make your life easier.
Good, it builds! What next?
First, in your router, turn off encryption (Disable WEP and make auth type to be "open system" - believe me this is needed as a first step. Will save you hassle.)
Create a small script called wlan_script_basic.sh in your home directory consisting of the following lines:
sudo rmmod prism2_usb
sudo modprobe prism2_usb prism2_doreset
sudo wlanctl-ng wlan0 lnxreq_ifstate ifstate=enable
sudo wlanctl-ng wlan0 lnxreq_autojoin ssid="XXX" authtype=opensystem
sudo dhclient wlan0
XXX = name of your access point/router
(Pray that you will donate all your hair while your wlan0 acquires a lease)
Great! internet works.
Now, to set up WEP.
Enable WEP in your router, set a key (I am assuming it is 12345678, a 64-bit hex key), and select shared key as your system.
Now, write a new script containing the following:
sudo rmmod prism2_usb
sudo modprobe prism2_usb prism2_doreset
sudo wlanctl-ng wlan0 lnxreq_ifstate ifstate=enable
sudo wlanctl-ng wlan0 lnxreq_hostwep decrypt=true encrypt=true
sudo wlanctl-ng wlan0 dot11req_mibset mibattribute=dot11PrivacyInvoked=true
sudo wlanctl-ng wlan0 dot11req_mibset mibattribute=dot11WEPDefaultKeyID=0
sudo wlanctl-ng wlan0 dot11req_mibset mibattribute=dot11WEPDefaultKey0=""
sudo wlanctl-ng wlan0 lnxreq_autojoin ssid="XXX" authtype=sharedkey
sudo dhclient wlan0
Did it work?
Yes? Great, you are all set!
No? Spend 15 bux and get a wireless card that works with your distro. It will save you countless hours of hacking.
The foll. will get you through in MOST linux distros (have tried it on simplymepis, ubuntu, redhat 9.0)
Obtain the linux-wlan driver for your card (http://www.linux-wlan.org/) and install it. However, you need to install the kernel headers (no, this is not recompiling the kernel) before installing linux-wlan.
In debian distros, it is as simple as knowing your kernel (uname -a should give you that), followed by an apt-get install kernel-header.... (choose the right header corresponding to uname -a)
Now, tar unzip, your linux-wlan drivers file, do a configure (and pray to God you have everything required in your system) , a make (while selling Satan your soul for being able to build) , and finally a make install. Do all this as root to make your life easier.
Good, it builds! What next?
First, in your router, turn off encryption (Disable WEP and make auth type to be "open system" - believe me this is needed as a first step. Will save you hassle.)
Create a small script called wlan_script_basic.sh in your home directory consisting of the following lines:
sudo rmmod prism2_usb
sudo modprobe prism2_usb prism2_doreset
sudo wlanctl-ng wlan0 lnxreq_ifstate ifstate=enable
sudo wlanctl-ng wlan0 lnxreq_autojoin ssid="XXX" authtype=opensystem
sudo dhclient wlan0
XXX = name of your access point/router
(Pray that you will donate all your hair while your wlan0 acquires a lease)
Great! internet works.
Now, to set up WEP.
Enable WEP in your router, set a key (I am assuming it is 12345678, a 64-bit hex key), and select shared key as your system.
Now, write a new script containing the following:
sudo rmmod prism2_usb
sudo modprobe prism2_usb prism2_doreset
sudo wlanctl-ng wlan0 lnxreq_ifstate ifstate=enable
sudo wlanctl-ng wlan0 lnxreq_hostwep decrypt=true encrypt=true
sudo wlanctl-ng wlan0 dot11req_mibset mibattribute=dot11PrivacyInvoked=true
sudo wlanctl-ng wlan0 dot11req_mibset mibattribute=dot11WEPDefaultKeyID=0
sudo wlanctl-ng wlan0 dot11req_mibset mibattribute=dot11WEPDefaultKey0="
sudo wlanctl-ng wlan0 lnxreq_autojoin ssid="XXX" authtype=sharedkey
sudo dhclient wlan0
Did it work?
Yes? Great, you are all set!
No? Spend 15 bux and get a wireless card that works with your distro. It will save you countless hours of hacking.
Thursday, July 13, 2006
Delete lines matching a pattern in vim
I have only recently started using the powerful :g
Syntax :[range]:g//[cmd]
Some examples of its usage:
Delete all lines matching a pattern
:g//d
Delete all blank lines
:g/^\s*$/d
I also found this tip in the vim website, which contains a lot more examples:
http://www.vim.org/tips/tip.php?tip_id=227
Syntax :[range]:g/
Some examples of its usage:
Delete all lines matching a pattern
:g/
Delete all blank lines
:g/^\s*$/d
I also found this tip in the vim website, which contains a lot more examples:
http://www.vim.org/tips/tip.php?tip_id=227
Search and replace part of an expression in gvim
Assume that you want to add a double asterisk (**) to every line in a document.
e.g. you want to replace
hello, this is a line
this is another line
this is a third line
with
hello, this is a line**
this is another line**
this is a third line**
There are many ways to doing this, but one of the more general ways of doing this with regular expressions (which can be easily extended for other tasks) is
:%s/\(^.*\)/\1**
An extension: What if you want to introduce a line break before the word line?
Use \r
:%s/\(^.*\) \(line\*\*\)/\1\r\2/g should do it for you
As you notice \1 contains the match within the first parentheses. If there were multiple parentheses, the contents can be accessed using \1, \2 etc.
e.g. you want to replace
hello, this is a line
this is another line
this is a third line
with
hello, this is a line**
this is another line**
this is a third line**
There are many ways to doing this, but one of the more general ways of doing this with regular expressions (which can be easily extended for other tasks) is
:%s/\(^.*\)/\1**
An extension: What if you want to introduce a line break before the word line?
Use \r
:%s/\(^.*\) \(line\*\*\)/\1\r\2/g should do it for you
As you notice \1 contains the match within the first parentheses. If there were multiple parentheses, the contents can be accessed using \1, \2 etc.
Wednesday, July 12, 2006
Floating point division in python
Add the following line to your python 2.4 code, if you want to do FP division. Otherwise, python will only do integer division!
from __future__ import division # Otherwise python will not do FP division
from __future__ import division # Otherwise python will not do FP division
Tuesday, July 11, 2006
Latex tip - to make pages look nicer
Don't you hate it when you get a doc with 5.5 pages?
When you want to force material over to the next page, e.g., when you want to balance the last page by moving references, you can use \vfill\eject between references to move more over to column two and produce a more balanced last page. (This command is great for forcing material over to the next page.)
When you want to force material over to the next page, e.g., when you want to balance the last page by moving references, you can use \vfill\eject between references to move more over to column two and produce a more balanced last page. (This command is great for forcing material over to the next page.)
Cool gvim trick for marking
You know how you edit some code at line 10, then move to line 30, and forget where you were originally (line 10)? There is a gvim command for taking care of this. You can use markers. In line 10, you can (in command mode) type ma to mark the position with identifier 'a', and now after editing line 30, you can type 'a to move back to line 10 (marker a). Markers are also useful for deleting lines between two markers and so on.
But, it so happens if you create too many markers, you will forget that marker 'a' is actually line 10. More problems!
The solution - Ctrl-i and Ctrl-o can be used in gvim to move around the last places you edited. Thus, saving you from marking everyplace you edited.
Of course markers are still needed, when you want to delete lines between two markers, or search and replace between them.
e.g.
d'a - delete from current position to mark a
:'a,'b d -delete all lines between markers a and b
:'a,'b s/ef/cd -you know what this means
But, it so happens if you create too many markers, you will forget that marker 'a' is actually line 10. More problems!
The solution - Ctrl-i and Ctrl-o can be used in gvim to move around the last places you edited. Thus, saving you from marking everyplace you edited.
Of course markers are still needed, when you want to delete lines between two markers, or search and replace between them.
e.g.
d'a - delete from current position to mark a
:'a,'b d -delete all lines between markers a and b
:'a,'b s/ef/cd -you know what this means
The ~ symbol in latex
The ~ symbol. I thought, it was the trick for adding spaces within math expressions
i.e. for anything enclosed in $.
e.g.
$a = a + b$ --> a=a+b
$a~=~a~+~b$ --> a = a + b
But, actually what it does it ties the symbols together. So, for example if you give Figure~\ref{fig:world}, what it ensures is the terms Figure and the reference number remain always on the same line. Thus it will always be printed as
"Figure X"
"and not as Figure
X"
But, if you just used a hard space between Figure and \ref, the latter might just happen!
i.e. for anything enclosed in $.
e.g.
$a = a + b$ --> a=a+b
$a~=~a~+~b$ --> a = a + b
But, actually what it does it ties the symbols together. So, for example if you give Figure~\ref{fig:world}, what it ensures is the terms Figure and the reference number remain always on the same line. Thus it will always be printed as
"Figure X"
"and not as Figure
X"
But, if you just used a hard space between Figure and \ref, the latter might just happen!
Subscribe to:
Posts (Atom)