Wednesday, November 9, 2011

Amazing Free Software

Dia: open source software to create process diagrams and flowcharts.


AVG Anti-virus: AVG (compared to Norton) is a real good alternative which is free and does not tax the system as much as Norton does. The latest version of AVG also comes with several new features such as Anti- spyware, Anti-rootkit and more.

CCleaner: A cleaning robot for the computer, which is smart enough to know which places to look for unwanted files (e.g. temporary files) and traces. CCleaner can also cleanup several applications along cleaning temporary and unwanted files created by Windows.

Recuva: To recover deleted files, Recuva is one of the best free and reliable alternative that is available today.

Miro: Allows to convert PC into a Internet TV and watch any Internet video channels. YouTube videos and almost any type of files including HD videos can also be played.

Audacity: One of the best free tools available for audio editing and recording for several operating systems. Live audio recording, tapes conversion into digital recordings, cut, copy, splice or mix sounds together and more can be done.

Notepad++: Not just a mere notepad replacement, but allows modification of several file types and supports additional features like auto complete.

Handbrake: A DVD Ripper that rips DVD files and convert them to MPEG-4 format for Mac OS, Linux and Windows.

Foxit PDF Reader: Best alternative to the Adobe PDF reader.

7Zip: Best open source software to manage several types of archives.

xPlorer2 Lite: Very handy utility when it comes to managing files in Windows. The tabbed interface saves you lot of times and hassles simplifying the task of managing files.

Launchy: Open Source software for Windows similar to QuickSilver.

Windows Live Writer: Offline Blog Writer. Manage multiple weblogs and post to them with ease, save drafts online and offline, edit images, etc.

Monday, July 25, 2011

Python Module Not Found

Ways to debug when a python code can't find a module:

Open a terminal and start python. Enter:

from imp import *
find_module(module)


See if the path name corresponds with where your module was supposed to be installed or if the path name directs to a __init__.py file


For Example, we were trying to install pyfacebook and our code won't load the module.


find_module(module) was resulting in the following output:
(<open file 'facebook.py', mode 'U' at 0xb752d4f0>, 'facebook.py', ('.py', 'U', 1))


However, the module was installed at (found using a find command):
/usr/lib/python2.7/site-packages/pyfacebook-1.0a2-py2.7.egg


Clearly, when the code was calling from facebook import *, the code was unable to locate __init__.py file and was crashing. To solve the problem, move the files to /usr/lib/python2.7/site-packages/ and see if a further run of find_module points to the required directory.

Friday, July 8, 2011

python sequence float vs int

Python has a nifty little way to generate a sequence of numbers:

sequence = range(0, 10, 1)

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

However, this doesn't work when the step value is float. For that purpose, use numpy's arange function:

import numpy as np
sequence = np.arange(0,1,0.1)

array([ 0. ,  0.1,  0.2,  0.3,  0.4,  0.5,  0.6,  0.7,  0.8,  0.9])

For more interesting ways, including using generators, check: http://stackoverflow.com/questions/477486/python-decimal-range-step-value

Thursday, July 7, 2011

Python Non-ASCII character '\xc3'

During a python script execution, if you get the following error:

SyntaxError: Non-ASCII character '\xc3' in file text2term_topia.py on line 21, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

Add the following statement right at the begining, before all import statements.

# -*- coding: utf-8 -*-

Similar approach for errors with the term '\xe2'.



Friday, June 24, 2011

Transfer files using ssh

'scp' command to copy files and directories to the server: 

scp your_file_name login@remoteserver.com:path to copy files, 
and scp –r your_directory_name login@remoteserver.com:path to copy entire directories.

grep character count

Use grep to count the frequency of a character in a file:

grep o 'character' filename | wc -l

Wednesday, June 22, 2011

Difference between continue and pass in python

Pass is a "do-nothing" statement. Best used with a if-else or try-except condition

Continue means "jump to start of loop", ignoring rest of the statements in the loop

Code Output

for r in [1,2,3]:
   print(r)
   continue
   print(r,"\tagain")

1
2
3

for r in [1,2,3]:
   print(r)
   pass
   print(r,"again")



1
(1, 'again')
2
(2, 'again')
3
(3, 'again')



for r in [1,2,3]:
   if r%2!=0:
      print(r)
   else:
      pass


1
3


for r in [1,2,3]:
   if r%2==0:
      continue
   print(r)


Bad coding practice according to me but nevertheless this is possible.


1
3

Allow wget to overwrite files

Default behavior of wget is to make new files if files of same name are downloaded again, appended with a counter.

wget filename > filename
wget filename > filename.1
wget filename > filename.2

To overwrite the existing file with the new downloads without creating new files, the answer is:

On GNU Wget 1.12 built on linux-gnu:

Use wget -N filename