Pages

Tuesday, April 13, 2010

Simple script to get the exchange rate.

Some time ago I made a small script to find out the exchange rate.
I have not used it much and today I came across it.
Who needs something, here's how it looks:
from xml.dom import minidom as dom
import urllib
def fetchPage(url):
a = urllib.urlopen(url)
return ''.join(a.readlines())

def extract(page):
a = dom.parseString(page)
item2 = a.getElementsByTagName('SendingDate')[0].firstChild.wholeText
print "DATA ",item2
item = a.getElementsByTagName('Cube')
for i in item:
if i.hasChildNodes() == True:
e = i.getElementsByTagName('Rate')[10].firstChild.wholeText
d = i.getElementsByTagName('Rate')[26].firstChild.wholeText
print "EURO  ",e
print "DOLAR ",d

if __name__=='__main__':
page = fetchPage("http://www.bnro.ro/nbrfxrates.xml")
extract(page)

That's all.

Parsing files and rename ...

Sometimes you have to rename files.
This can be tiring when we do it manually.
Command "sed" may be helpful in this case.
I'll take a simple example. I will create a working directory called "work."
We have to create files with the command:
for (( i=1; i<10; i++ )); do echo data$i > data[$i]x[$i].txt;done

The result should be :
$ ls
data[1]x[1].txt  data[3]x[3].txt  data[5]x[5].txt  data[7]x[7].txt  data[9]x[9].txt
data[2]x[2].txt  data[4]x[4].txt  data[6]x[6].txt  data[8]x[8].txt

Try these commands to parse and rename files:
$ for i in  *[]x[]*; do mv -v "$i" "$(echo $i | sed 's/[]x[]//')"; done
`data[1]x[1].txt' -> `data1]x[1].txt'
`data[2]x[2].txt' -> `data2]x[2].txt'
`data[3]x[3].txt' -> `data3]x[3].txt'
`data[4]x[4].txt' -> `data4]x[4].txt'
`data[5]x[5].txt' -> `data5]x[5].txt'
`data[6]x[6].txt' -> `data6]x[6].txt'
`data[7]x[7].txt' -> `data7]x[7].txt'
`data[8]x[8].txt' -> `data8]x[8].txt'
`data[9]x[9].txt' -> `data9]x[9].txt'
[work@test work]$ for i in  *[]x[]*; do mv -v "$i" "$(echo $i | sed 's/[]x[]//')"; done
`data1]x[1].txt' -> `data1x[1].txt'
`data2]x[2].txt' -> `data2x[2].txt'
`data3]x[3].txt' -> `data3x[3].txt'
`data4]x[4].txt' -> `data4x[4].txt'
`data5]x[5].txt' -> `data5x[5].txt'
`data6]x[6].txt' -> `data6x[6].txt'
`data7]x[7].txt' -> `data7x[7].txt'
`data8]x[8].txt' -> `data8x[8].txt'
`data9]x[9].txt' -> `data9x[9].txt'
[work@test work]$ for i in  *[]x[]*; do mv -v "$i" "$(echo $i | sed 's/[]x[]//')"; done
`data1x[1].txt' -> `data1[1].txt'
`data2x[2].txt' -> `data2[2].txt'
`data3x[3].txt' -> `data3[3].txt'
`data4x[4].txt' -> `data4[4].txt'
`data5x[5].txt' -> `data5[5].txt'
`data6x[6].txt' -> `data6[6].txt'
`data7x[7].txt' -> `data7[7].txt'
`data8x[8].txt' -> `data8[8].txt'
`data9x[9].txt' -> `data9[9].txt'
[work@test work]$ for i in  *[]x[]*; do mv -v "$i" "$(echo $i | sed 's/[]x[]//')"; done
`data1[1].txt' -> `data11].txt'
`data2[2].txt' -> `data22].txt'
`data3[3].txt' -> `data33].txt'
`data4[4].txt' -> `data44].txt'
`data5[5].txt' -> `data55].txt'
`data6[6].txt' -> `data66].txt'
`data7[7].txt' -> `data77].txt'
`data8[8].txt' -> `data88].txt'
`data9[9].txt' -> `data99].txt'
[work@test work]$ for i in  *[]x[]*; do mv -v "$i" "$(echo $i | sed 's/[]x[]//')"; done
`data11].txt' -> `data11.txt'
`data22].txt' -> `data22.txt'
`data33].txt' -> `data33.txt'
`data44].txt' -> `data44.txt'
`data55].txt' -> `data55.txt'
`data66].txt' -> `data66.txt'
`data77].txt' -> `data77.txt'
`data88].txt' -> `data88.txt'
`data99].txt' -> `data99.txt'

This is just a simple example ...

Tuesday, March 16, 2010

OpenGL and Python - Motion blur

What is glAccum? The OpenGL function - glAccum operate on the accumulation buffer.
This function provides support for many special effects.
Today I simulated the effect of motion blur with this function.
See the picture below:

Sunday, March 14, 2010

OpenGL and Python - Fog

Today I spent my time with something new - the OpenGL fog effect.
I made one simple fog effect using the last code source.
The result is this image:

Friday, February 12, 2010

"Santa Claus" on Google Map

I wrote on my blog python-catalin.blogspot.com about Google Map and Santa Claus:

I wrote a python module. I called it "geo" because it is a geographic module.
The funny stuff is when i use it with "Santa Claus".

>>> import geo
>>> geo.adress("Santa Claus")
{'status': '200', 'latitude': '32.1715776', 'longitude': '-82.3315138', 'accuracy': '4'}

So where is Santa Claus ?!
Google Maps API should be prepared to respond.
Tomorrow a child will know how to use the Python language.
Who knows ...

Tuesday, February 9, 2010

Paris Game AI Conference 2010

The first sessions of the Paris Game AI Conference 2010 was announced.
AI Conference brings together veteran game developers and artificial intelligence professionals.
Tickets are now available, but the price is from 47EUR to 97EUR.
They have now only 160 tickets.
gameaiconf.com

Friday, November 13, 2009

Christmas is coming.

I love Christmas. I like going shopping. I love snow.
Two days ago, inspired by this holiday I started to create an application.
Here's what came out.


As you can see is not wallpaper, is just a python script.

News: Go - a systems programming language

Do you hear about "Go"?
This is the logo :

...and this is the code:
package main
import "fmt"
func main() {
fmt.Printf("Hello, 世界\n")
}
One of the text comments I found is:
" this combines the style of Python, the syntax of vBasic, and the speed of C?"
For me is like "perl".
More from google developers :

Thursday, November 12, 2009

Fedora - OpenOffice Impress

Templates
It's the perfect solution for you. Why?
Sometimes we need to create complete presentation documents based on Fedora.
This template is for Fedora users:
Fedora Template.
Fedora Logo Template

Monday, November 9, 2009

First post on planet.fedorapeople.org

I tried to connect to planet.fedorapeople.org.
I asked several people but it's Monday and world works.
After several unsuccessful attempts and internet search, I started the setup.
Some of SELinux settings and this is the result.
However, some settings ssh should be underlined.
I mean ssh_config configuration file and some security settings.
It seems that I succeeded.

OOMouse - OpenOffice Mouse Gadget

What is OOMouse?

Is the first multi-button application mouse designed for a wide variety of software applications.
The OOMouse supports Windows, Linux, and Macintosh operating systems.


The features of the OOMouse include:


  • 18 programmable mouse buttons with double-click functionality

  • Three different button modes: Key, Keypress, and Macro

  • Analog Xbox 360-style joystick with optional 4, 8, and 16-key command modes

  • Clickable scroll wheel

  • 512k of flash memory
  • 63 on-mouse application profiles with hardware, software, and autoswitching capability
  • 1024-character macro support.

  • Open source support software for creating, managing, and customizing application profiles

  • Import and export of custom profiles in XML format

  • Optional audio notification of profile switching with customizable wave files

  • PDF export of profile button assignments

  • Adjustable resolution from 400 to 1,600 CPI

  • 20 default profiles for popular games and applications, including OpenOffice.org 3.1, Adobe Photoshop, the Gnu Image Manipulation Program, World of Warcraft, and the Call of Duty series.


Link :
openofficemouse.com

Wednesday, August 5, 2009

New software for childrens

I think this is a good software. Your child may use it to learn programming .
Is easy to use and useful to explain how working.
This is a official link : http://pythonturtle.com

Monday, February 9, 2009

PyGame

Pygame is a free set of Python modules.
Is portable and runs on every platform and operating system.
More about pygame documentation on www.pygame.org/docs/
Other links: pygame-catalin.blogspot.com