Tuesday, August 3, 2010

Integrate Vim and IPython in Windows

Ipython and Vim is a great combination that make an IDE for Python.



By default, the IPython will use Windows default editor (Notepad), when %edit command is invoked.

To make Vim as the default editor, please follow the following steps:


Step 1.
Open file ipythonrc.ini which is located at “C:Usersyour username_ipython” in Windows 7 with any editor.


Step 2.
Search for line “editor 0”.


Step 3.
Replace that line to
editor vim
for Vim, or,
editor gvim –f
if  you prefer to use gVim.


Step 4.
Restart IPython and type %edit to start Vim.

Sunday, July 25, 2010

WordPress: Add Facebook Like Button using functions.php

The Facebook Like button lets a user share contents with friends on Facebook. When the user clicks the Facebook Like button, a story appears in the user's friends' News Feed, with a link back to the original website.

[caption id="" align="alignnone" caption="Facebook Like Button"][/caption]

Append this code snippet to functions.php file in theme or child theme folder to add the Facebook Like Button.
function add_fb($content) {
$fb = ''; // display only on single page.
if (is_single()) {
$fb = '<iframe src="http://www.facebook.com/plugins/like.php?href=';
$fb .= urlencode(get_permalink(get_the_ID()));
$fb .= '&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;';
$fb .= 'action=like&amp;colorscheme=light"';
$fb .= ' style="border:none; overflow:hidden; width:450px; ';
$fb .= 'height:60px"></iframe>';
}

// display before the content.
return $fb . $content;

// display after the content.
// return $content . $fb;
}

add_filter('the_content', 'add_fb');

Please visit http://developers.facebook.com/docs/reference/plugins/like for more information on how to customize the Like Button.

Tuesday, June 15, 2010

Nokia 5800: How to delete an email account

To delete an email account from Nokia 5800 is easy.

These are the steps:

  1. Go to Menu > Messaging.

  2. Options > Settings > Email > Mailboxes.

  3. Highlight the email account to delete.

  4. Options > Delete > Yes.

Monday, May 10, 2010

Windows 7 Computer Management failed to start by right clicking Computer

Windows 7 Computer Management could be started by right clicking Computer, and choose Manage.
However, sometimes this method just do not work.
Perform these steps to solve the problem:
  1. Launch the Registry Editor.Press Windows key > Type regedit >  Press Enter > Click on Yes.
  2. Browse to
    HKEY_CLASSES_ROOTCLSID{20D04FE0-3AEA-1069-A2D8-08002B30309D}shell Managecommand
  3. Replace the default string value to
    "%SystemRoot%System32mmc.exe" "%SystemRoot%system32compmgmt.msc" /s
  4. Close Registry Editor.
You should now be able to right click Computer and choose Manage, to launch Computer Management.

Thursday, April 1, 2010

Python: Swapping the keys and values of a dictionary

A function to swap the keys and immutable values of a dictionary.
def swap_dict(a_dict):
    return {val:key for key, val in a_dict.items()}
Example of usage:
>>> print(swap_dict({1: 'a', 2: 'b', 3: 'c'}))
{'a': 1, 'c': 3, 'b': 2}

Tuesday, February 16, 2010

Windows XP: How to create a password for the invisible administratoraccount

Windows XP create an administrator account by default which is invisible. This administrator account is not password protected. How to protect this account with a password?

Steps to password protect the administrator account.

Step 1.
If you are currently logged on to your computer, click Start, and then click Log Off.



Step 2.
On the “Welcome screen”, press CTRL+ALT+DEL twice on your keyboard by holding down both the CTRL and ALT keys and then pressing DELETE.

Step 3.
The “Log On to Windows” dialog box appears. In the “User name” box, type “Administrator”. Leave the “Password” box blank if you have not assigned a password. Click OK.


Step 4.

Open the entry “User Accounts” in the control panel. Click on the icon “Administrator” and select “Create a password”.

Step 5.

In the following dialog, specify a password for the “Administrator” account. Click “Create Password”.


It is important to create a strong but easily memorable password. A strong password should includes a combination of letters (small and capitals), numbers and special characters, and at least eight characters long.