Intresting topic on SolidWorks about Simulation :
Wednesday, November 17, 2010
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
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 :
Done! Now that post or page will point to the URL that you choose
Source : http://txfx.net/wordpress-plugins/page-links-to/
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 :
- Upload the page-links-to folder to your /wp-content/plugins/ directory
- Activate the “Page Links To” plugin in your WordPress administration interface
- Create (or edit) a page or a post to have a title of your choosing (leave the content blank)
- Down below, in the advanced section, find the Page Links To widget and add a URL of your choosing
- Optionally check the boxes to enable link opening in a new browser window, or 302 Moved Temporarily redirects
- Save the post or page
Done! Now that post or page will point to the URL that you choose
Source : http://txfx.net/wordpress-plugins/page-links-to/
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".
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) :
Network Upgrade for Ubuntu Desktops (Recommended) :
- System -> Administration menu->Software Sources application
- Open Updates from the Software Sources application window
- Change the Release Upgrade drop down to "Normal Releases" and close the application
- Press Alt-F2 and type update-manager
- Click the Check button to check for new updates.
- If there are any updates to install, use the Install Updates button to install them, and press Check again after that is complete.
- A message will appear informing you of the availability of the new release.Click Upgrade.Follow the on-screen instructions.
Source : Ubuntu Community
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 :
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]
"""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:]
>>>> idx = 1
>>>> s1 = "pxthon"
>>>> s1[idx] = 'y'
> Traceback (most recent call last):
> File "
> 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'
# 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:
- Tackling the travelling salesman problem: prologue – gives some background on John’s plans
- Tackling the travelling salesman problem: introduction – defines the TSP and ‘NP-Hard’-ness, discusses how to represent the problem in Python and looks at some of the evolutionary-programming tools that will be used in the solution
- Tackling the travelling salesman problem: hill-climbing – John introduces the concept of a ‘fitness landscape’, how a hill-climbing algorithm can traverse the landscape and how to write the hill-climber with Python
Yield, Generators & Iterables, non separable concepts in Python
Iterables
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)
1
2
3
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)
0
1
4
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
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)
0
1
4
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
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)
0
1
4
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 :-)
Subscribe to:
Posts (Atom)