Thursday, December 30, 2010

Set a selected item for select tag in HTML, web design

In this example Green will be the selected item(pay attention to where the selected statement is placed) :


<select name="colors">



<option selected>Green</option>



Wednesday, December 29, 2010

Configuration about PHP server, HOWTO

If you are wondering about the configuration of the PHP server you have, you can simply make a PHP file with following command :




and simply place the file in the localhost folder and browse it in an Internet Browser. You would simply have all the information you need. The result will be something like the picture down here(Take from Wiki)

Start X from shell, Ubuntu

First method, Use init script
sudo /etc/init.d/gdm start
sudo /etc/init.d/kdm start

Second method, type startx command :

If nothing works, type xinit to star X server without KDE:

Now start kde with following :

Tuesday, December 28, 2010

add a user to Ubuntu from Shell/terminal

useradd -m -s /bin/bash userName
passwd userName
cd /home
ls -l
mkdir scheiber ----> if it already does not exist
chmod 0700 scheiber
chown -R scheiber:scheiber scheiber

Switch between X login and shell, Ubuntu

Use the Ctrl-Alt-F1 shortcut keys to switch to the first console.

To switch back to Desktop mode, use the Ctrl-Alt-F7 shortcut keys.

Monday, December 27, 2010

How to Group your Radio Buttons

First add your Radio Buttons to the panel and then select all radio buttons you want to group and set their buttonGroup property (choose the group name from the combo box).

How to add tabbed panel to Java Frame in Netbeans

Select tabbed pane, right click on it and then go to Add From Palette, and selecting another Panel(not tabbed panel again) from there to add another tab.

For renaming the tab righ click on it and choose Edit Text.
To change the tabs order you can simply right click on the panel and click on Change Order and then re-order the tabs order as you wish.

Saturday, December 25, 2010

AVG detects Chrome as a Trojan threat

The AVG 8.5 seems to have problem. Either update to AVG 9.0 or 2011 free versions (this error is mainly being observed in AVG 8.5) OR revert back virus definition of Avg to previous state.
Revert update to previous version : 
Tools -> Advance setting -> Update 
and use the Manage to revert ! After that try installing it !

Tuesday, December 14, 2010

Live Writer, a Multi weblog solution

You got several websites and you want to publish something with not much differences in all of them. Then Live Writer is the right tool for you. It lets you add different weblogs(from Wordpress, blogger, etc) and update them with couple of clicks. There are other solutions that can publish one post(exactly the same thing) on several weblogs, but they lack some WYSIWYG feature or they simply do not work with some of your weblogs(Wordpress in my case). I can recommend this MS tool for bloggers

Download Live Writer from here.

List of people available in one IRC chat channel

  • List of people available in one IRC chat channel
  • Gives the real name of the given nickname/username
    /who nickname

Thursday, November 11, 2010

Net use command in CMD

If you want to map a network drive from command prompt(cmd), you can write the following command :

net use (partition letter): \\server_name\share_name
Example : net use y: \\test_server\test_share

Wednesday, November 10, 2010

Link(permalink) pages in wordpress to an external link

You want to redirect pages in your wordpress to an external link ? Now there is a plugin which let you do it :-) The good thing about this ability is that you can re-direct the menu items in your website to external links which was something that Wordpress always lacked.

The plugin name is "Page Liks To". You can download it from here, or simply search the name from your Wordpress control panel. The instruction is as follows :

  1. Upload the page-links-to folder to your /wp-content/plugins/ directory
  2. Activate the “Page Links To” plugin in your WordPress administration interface
  3. Create (or edit) a page or a post to have a title of your choosing (leave the content blank)
  4. Down below, in the advanced section, find the Page Links To widget and add a URL of your choosing
  5. Optionally check the boxes to enable link opening in a new browser window, or 302 Moved Temporarily redirects
  6. Save the post or page

Done! Now that post or page will point to the URL that you choose

Source :

Monday, November 08, 2010

Forward inline, Thunderbird

If the message you want to forward does not appear as inline in the message you are forwarding, then you need to change the following in Thunderbird Options :

Tools > Options > Composition > General tab, switch "As Attachment" to "Inline".

Friday, October 22, 2010

Upgrade to Ubuntu 10.10 from Desktop version of Ubuntu 10.04

You want to upgradet to latest Ubuntu version(10.10) and you don't get it in your update menu(upgrade to Ubuntu 10.10), then you need to read the following :

Network Upgrade for Ubuntu Desktops (Recommended) :

  1. System -> Administration menu->Software Sources application
  2. Open Updates from the Software Sources application window
  3. Change the Release Upgrade drop down to "Normal Releases" and close the application
  4. Press Alt-F2 and type update-manager
  5. Click the Check button to check for new updates.
  6. If there are any updates to install, use the Install Updates button to install them, and press Check again after that is complete.
  7. A message will appear informing you of the availability of the new release.Click Upgrade.Follow the on-screen instructions.

Thursday, October 21, 2010

Can't find equal sign on Android keyboard

Nope, you are not blind. They managed to hide it on the 3rd page of your keyboard !!! Press the "?123"(12# in some keyboards) Symbol on the bottom Left(right in some local keyboards). Then Press "ALT"(my Norwegian local keyboard ALT button was "1/2") on the Left-hand side to bring up a new variety of symbols including the equal sign.

Tuesday, October 19, 2010

How to find an element in a List and return the index, Python

Check if value exist in a list, L ?
if value in L:
            print "list contains", value
Returns the index, where value exist in List, L :

i = L.index(value)

Array of classes in Python

b = [bullet() for x in range(50)]

Reverse a string, Python

def reverseString(s):
   """Reverses a string given to it."""
   return s[::-1]

Python string manipulation problem

In python string are immutable so if you want to just change a character in a string you get following error :

>>>> idx = 1
>>>> s1 = "pxthon"
>>>> s1[idx] = 'y'

> Traceback (most recent call last):
> File "", line 1, in ?
> TypeError: object does not support item assignment

But you can always go for a way out which is not pretty and can lead to some problems if you are not careful, but works :

s1 = s1[0:idx] + 'y' + s1[idx+1:]

How to append a dictionary in Python

groups = {'IRISH' : 'green', 'AMERICAN' : 'blue'}
# if you want to later add a new one, i.e., 'ITALIAN' : 'orange'

groups['ITALIAN'] = 'orange'

Python for Java Programmers

If you are a Java programmer and need to learn python, try this link. It is pretty useful.

random function python

random.sample(100,2) -> returns 2 random numbers in range of 100 ...

Python tutorials, video

To learn more about Python you can visit ShowMeDo’s list of Python videoswhich contains 94 Python tutorials including almost 2-hours worth of tuition in the Python Newbies on XP series.

TSP & Python

Montgomery (ShowMeDo author) has started a very nice blog series on Solving the classic Travelling Salesman Problem (TSP) with Python.

So far there are 3 posts in the series:

Yield, Generators & Iterables, non separable concepts in Python


To understand what yield does, you must understand what generators are. And before generators come iterables. When you create a list, you can read its items one by one, and it's called iteration :
>>> mylist = [1, 2, 3]
>>> for i in mylist :
...    print(i)
Mylist is an iterable. When you use a comprehension list, you create a list, and so an iterable :
>>> mylist = [x*x for x in range(3)]
>>> for i in mylist :
...    print(i)
Everything you can use "for... in..." on is an iterable : lists, strings, files... These iterables are handy because you can read them as much as you wish, but you store all the values in memory and it's not always what you want when you have a lot of values.


Generators are iterables, but you can only read them once. It's because they do not store all the values in memory, they generate the values on the fly :
>>> mygenerator = (x*x for x in range(3))
>>> for i in mygenerator :
...    print(i)
It just the same except you used () instead of []. BUT, you can not perform for i in mygenerator a second time since generators can only be used once: they calculate 0, then forget about it and calculate 1 and ends calculating 4, one by one.


Yield is a keyword that is used like return, except the function will return a generator.
>>> def createGenerator() :
...    mylist = range(3)
...    for i in mylist :
...        yield i*i...
>>> mygenerator = createGenerator() # create a generator
>>> print(mygenerator) # mygenerator is an object !
<generator object createGenerator at 0xb7555c34>
>>> for i in mygenerator:
...     print(i)
Here it's a useless example, but it's handy when you know your function will return a huge set of values that you will only need to read once.
To master yield, you must understand that when you call the function, the code you have written in the function body does not run. The function only returns the generator object, this is bit tricky :-)