How to convert *.docx files (Microsoft Office 2007) online for free

Sometimes you might have no choice except to open Microsoft Office 2007 (*.docx) files that you’ve just received in your email. The problem is, you do not have any other application that support Office 2007 format.

Here’s an easy way to (kinda) solve that problem, you can convert Microsoft Office 2007 files online, using Google Docs.

Google Docs Logo

The steps are easy, you need to login into your Google Docs account, then upload the Office 2007 files. After that, you can choose the “Download file as” option to convert the file to your favorite document format (typically OpenDocument or older *.doc Microsoft Office word document).

Bear in mind that the conversion is not 100% perfect and there will be parts of document that won’t look exactly as the original ones.

How to block ads and malware websites using /etc/hosts files in Ubuntu

Here’s an easy way to block annoying advertisement and malware sites using ‘/etc/hosts’ file.

First edit the /etc/hosts files using your favorite text editor :

sudo gedit /etc/hosts

Then, paste the list of ads/malware servers in the ‘hosts’ file. You can get the list from http://someonewhocares.org/hosts/ or by searching through Google.

Close the file, and Save. The change will take effect immediately after that. One of the side-effect from this modfication is that your web surfing experience would be significantly faster because your browser does not have to wait for the annoying advertisement to load.

How to Embed Web Browser in Python GTK application using pymozembed

Embedding web browser or a screen for parsing HTML is easy in PyGTK. You only need to import the pymozembed, and add a few lines of code in your pygtk library, and you are set to go.

Here’s a sample PyGTK application that embeds a web-browser as well as a “Back” button for demonstration purpose :

PyGTK + browser Screenshot
PyMozEmbed PyGTK+ Mypapit Demo

[python]
#!/usr/bin/python
#
# demo by mypapit (info@mypapit.net) – Sept 2009
# http://blog.mypapit.net/
#
import pygtk
pygtk.require(‘2.0’)
import gtk
import gtkmozembed

class PyMoz:

def delete_event(self,widget,data=None):
print(“Exit”)
return False

def destroy(self,widget,data=None):
gtk.main_quit()

def button_clicked(self,widget,data):
data.go_back()

def __init__(self):
#init mozembed
self.moz = gtkmozembed.MozEmbed()
#create a Vertical Box Container to whole the browser
#and the “Back Button”
box = gtk.VBox(False,0)

#create a basic GTK+ window
win = gtk.Window()
win.add(box)

#create and connect “Back” button, to add functionality
self.button = gtk.Button(“Back”)
self.button.connect(“clicked”,self.button_clicked,self.moz)

#include both back button and the browser in the vertical box
#and the GTK+ window
box.pack_start(self.button,False,False,0)
box.pack_start(self.moz,True,True,0)

#load the URL
self.moz.load_url(‘http://blog.mypapit.net/’)

#set the window title
title=self.moz.get_title()
win.set_title(“browser demo”)

#show all the stuffs on screen
win.show_all()

#connect the delete_event and destroy event to make sure
#the app quits when the window is closed
win.connect(“delete_event”,self.delete_event)
win.connect(“destroy”,self.destroy)

if __name__ == “__main__”:
PyMoz()
gtk.main()

[/python]

Download demo source code : pymoz.py

How to make my Ubuntu detect more than 4GB memory

There were a couple of people that I met recently complained to me that their Ubuntu only detects 3 gigs of RAM after they upgraded their machine to 4 GB RAM.

Actually the problem does not lie with Ubuntu or any operating system in particular, rather the problem is related to 32bit operating system which only can address maximum of 232 bytes of memory.

Some might argue that 32-bit should be enough to address 4GB RAM, but in reality some of those memory location are reserved for computer and application operation that only a fraction of it are addressable when you installed 4GB RAM on a 32bit operating system. Thus you would see that your computer would only have around 3.5 GB only.

The solution?

There are two solutions to remedy this problem :
i) Install a 64-bit (Ubuntu) operating system
ii) Compile/Install kernel with PAE features enabled

The (i) solution is obvious, just install a 64bit edition of Ubuntu to your computer, and your problem will be automatically solved! The downside is, you probably does not want to use a 64bit edition of Ubuntu yet for some obscure reason (the evil binary only drivers and blobs)

The (ii) solution requires you to install a kernel with Physical Address Extension (PAE) support enabled.

For you information, Ubuntu comes with pre-compiled linux kernel that has PAE enabled. What you need to do is to apt-get these 3 packages “linux-headers-server, linux-image-server and linux-server” and reboot your computer. This will enable you operating system to recognize the extra RAM installed inside your computer.

p/s : The best solution is to get a system that does not depend on binary blogs (hardware drivers, etc) and move to 64-bit operating system in order to enjoy the full potential of your computer.

Quick and Dirty Network File sharing with Python

Ever find yourself in need to share file over the network quickly, but find yourself lacking time to setup a proper NFS or samba share? Here’s a way to do this with the good old Python CLI.

  • First, go to the directory that you want to share, for example ~/Desktop
  • Then run this command "python -m SimpleHTTPServer"
  • You may access the folder from a remote computer using any webrowser using the url – http://192.168.1.20:8000, change the ip address accordingly
Simple HTTP Server
file sharing with python

You may find this technique offers limited options to share files, but its a real time saver!

How to Import export MySQL database from command line

This tip would be useful for those who are either making backup of their remote mysql database or moving their web hosting to their provider.

Here’s how to export mysql DB to SQL file using command-line utility :
mysqldump –user=username –password=1234 –databases your_database –opt –quote-names –complete-insert > example.sql

Here’s how to import the SQL back into mysql database :
mysql –user=username –password=1234 –databases your_database –host=mysql_server host

Don’t forget to add your ip address to the list of allowable host on the remote MySQL server!