jython graphing

src : O'Reilly

Taken from the link above, I tried to build a standalone jar of the cool-looking graph app using jythonc command as such:
jythonc -j Chart.jar -d -a Chart.py

the creation seemed ok, but when I opened it (double-clicked), nothing happens. A quick
java -jar Chart.jar

reveals the problem
java.lang.NoClassDefFoundError: org/python/parser/ast/VisitorBase

duh..

Luckily my trusted 7zip is to the rescue (and the mailing-list is incomprehensible to me -_-).
0. extract jython.jar
1. locate /ast
2. open Chart.jar with 7zip File Manager
3. copy /ast into Chart.jar:/org/python/parser
4. done

p/s: Its a hack, i know LOL

jython JFileChooser

#! /usr/bin/jython

>>> import javax.swing as swing
>>> chooser = swing.JFileChooser()
>>> val = chooser.showOpenDialog(None);
>>> chooser.selectedFile.name
'youtube-dl.py'
>>> chooser.currentDirectory
C:\Documents and Settings\xxx\My Documents

adapted from Java 5.0 API

python easy introduction

------
print 'hello world'

------
for name in ('peter', 'paul', 'mary'):
print name

------
# This is a Python comment. \n is a newline
name = raw_input('What is your name?\n')
print 'Hi', name

------
parentRabbits, babyRabbits = (1, 1)
while babyRabbits < 100:
print 'This generation has %d rabbits' %
babyRabbits
parentRabbits, babyRabbits = (babyRabbits,
parentRabbits + babyRabbits)

------
# def defines a method in Python
def tax(itemCharge, taxRate = 0.05):
return itemCharge * taxRate
print '%.2f' % tax(11.35)
print '%.2f' % tax(40.00, 0.08)

------
import re
for test_string in [ '555-1212', 'ILL-EGAL']:
if re.match('\d\d\d-\d\d\d\d$', test_string):
print test_string, 'is a valid US local
phone number'
else:
print test_string, 'rejected'

------
prices = {'apple': 0.40, 'banana': 0.50}
myPurchase = {
'apple': 1,
'banana': 6}
groceryBill = sum([prices[fruit] *
myPurchase[fruit]
for fruit in myPurchase])
print 'I owe the grocer $%.2f' % groceryBill

------
class ShoppingCart:
def __init__(self): self.items = []
def buy(self, item): self.items.append(item)
def boughtItems(self): return self.items
myCart = ShoppingCart()
myCart.buy('apple')
myCart.buy('banana')
print myCart.boughtItems()

------
# indent your Python code to put into an email
import glob
pythonFiles = glob.glob('*.py')
pythonFiles.sort()
for fn in pythonFiles:
print ' ------'
for line in open(fn):
print ' ' + line.rstrip()
print

------
import time
now = time.localtime()
hour = now.tm_hour
if hour < 8: print 'sleeping'
elif hour < 9: print 'commuting'
elif hour < 17: print 'working'
elif hour < 18: print 'commuting'
elif hour < 20: print 'eating'
elif hour < 22: print 'resting'
else: print 'sleeping'

Mandriva 2007.0

For about a month, I've been using Mandriva 2007 (found the CD lying around :lol:) and it is quite OK for me because it can play my movies and mp3s out-of-the-box, so to say..

Previously I've tried opensuse 10.3 and ubuntu 7.10, and it somewhat disappointing because it couldn't play any avi / mp3 (understandably tho)

Anyway, after i lost my XP after a freak accident (formatting it), I tried to install it back, but to no avail, hence Mandriva to the rescue.

After successfully load the LiveCD, I decided to install it and it manage to detect all the standard peripheral on my v3010, except for the Ricoh 5-in-1 card reader (useless anyway as it cannot read my k750i's MS Pro card) and the geforce go 6150 graphics card.

Couldn't try the wireless, but it showed up in the hardware configuration, so i guess it's ok.

All is warm and fuzzy (while watching atlantis + numb3rs + criminal minds), until i tried installing apache tomcat. A quick google returns pain in installing it, and my lack of internet frustrates me even more, as i certainly cannot download all the dependencies manually, although i've thought of detecting the dependencies and download them using python :lol:

So my XP is back (thanks to Wan), but i still have the itch to try mandriva 2008 (found the cd on the linux mag, RM20), but that can be done later, when I install it onto a pen/usb-drive, which is still not bought yet :lol: then reboot my laptop from the yet-to-be-mine USB drive (about rm80)

tata..

Linkin Park - Leave Out All the Rest

I dreamed I was missing
You were so scared
But no one would listen
Cause no one else cared

After my dreaming
I woke with this fear
What am I leaving
When I'm done here

So if you're asking me
I want you to know

[Chorus]
When my time comes
Forget the wrong that I've done
Help me leave behind some
Reasons to be missed

And don't resent me
And when you're feeling empty
Keep me in your memory

Leave out all the rest
Leave out all the rest
[End Chorus]

Don't be afraid
I've taken my beating
I've shared what I made

I'm strong on the surface
Not all the way through
I've never been perfect
But neither have you

So if you're asking me
I want you to know

[Chorus]
When my time comes
Forget the wrong that I've done
Help me leave behind some
Reasons to be missed

Don't resent me
And when you're feeling empty
Keep me in your memory

Leave out all the rest
Leave out all the rest
[End Chorus]

Forgetting
All the hurt inside
You've learned to hide so well

Pretending
Someone else can come and save me from myself
I can't be who you are

[Chorus]
When my time comes
Forget the wrong that I've done
Help me leave behind some
Reasons to be missed

Don't resent me
And when you're feeling empty
Keep me in your memory

Leave out all the rest
Leave out all the rest

Forgetting
All the hurt inside
You've learned to hide so well

Pretending
Someone else can come and save me from myself
I can't be who you are
I can't be who you are

Linkin Park - In Pieces

Telling me to go
But hands beg me to stay
Your lips say that you love
Your eyes say that you hate

There's truth in your lies
Doubt in your faith
What you build you lay to waste
There's truth in your lies
Doubt in your faith
All I've gots what you didn't take

So I, I won't be the one
Be the one to leave this in pieces
And you, you will be alone
Alone with all your secrets and regrets
Don't lie

You promise me the sky

Then toss me like a stone
You wrap me in your arms
And chill me to the bone

There's truth in your lies
Doubt in your faith
All I've gots what you didn't take

So I, I won't be the one
Be the one to leave this in pieces
And you, you will be alone
Alone with all your secrets and regrets
Don't lie

So I, I wont be the one
Be the one to leave this in pieces
And you, you will be alone
Alone with all your secrets and regrets
Don't lie