Saturday, March 31, 2007
Wednesday, March 28, 2007
AlgoAnalysis UI
huuuu ... Siap a functional UI for AlgoAnalysis. Hasil kje 3 hari non stop ... ada la stop2 skit. The problem is, kalau display, semak lak rupanya ... positioning nodes nye random. So kdg2 overlap. Kalau tak overlap ngan node lain ... die overlap ngan edge. Skrg tgh pikir Algo utk organize display. Tgh consider triangulation. Kalau sesiapa ada pendapat ... bg tau aku ...
Labels: programming
Sunday, March 25, 2007
Python Power
A friend once had a problem with this code ... didn't know what was going on. Took ages to debug a simple problem and gave up ...
Its 18 lines long, a pain in the @$$ to debug, and frankly ... too much bull$#!t ...
1st step, bring your logic up a level and stop thinking like stupid one dimensional programmers, start thinking like a errrr.... a 'person'. 2nd step, keep it simple...
If you do these 2 steps right, you might get something like this ...
Its 5 lines long ... took 2 minutes to think of and write and it does exactly the same stuff that the previous one was supposed to do.
May his experience be a lesson to all ...
f = open('test.txt','r')
for line in f.read().split(','):
if i == 0:
z = line
print 'X1 = '+z
elif i == 1:
a = line
print 'a! = '+a
elif i == 2:
b = line
print 'b! = '+b
elif i == 3:
c = line
print 'c! = '+c
i = 0
i = i + 1
#training(x1, a, b, c)
Its 18 lines long, a pain in the @$$ to debug, and frankly ... too much bull$#!t ...
1st step, bring your logic up a level and stop thinking like stupid one dimensional programmers, start thinking like a errrr.... a 'person'. 2nd step, keep it simple...
If you do these 2 steps right, you might get something like this ...
f = open('test.txt','r')
linelist = f.readlines()
for line in linelist[1:]:
var=line.split(',')
print linelist[0].strip(),var[0],var[1],var[2]
Its 5 lines long ... took 2 minutes to think of and write and it does exactly the same stuff that the previous one was supposed to do.
May his experience be a lesson to all ...
Labels: programming
Thursday, March 15, 2007
MROAD beta version 0.0.2 revision 15
Bangun tidur, bkn gosok gigi, bkn mandi, terus gi kat PC and sambung debug. Ini la hidup programmer. Br mlm smlm tgk member training, sedih je but nevermind. So far da isolate the problem. Dekat db ada data salah. So betulkan la ... tambah 1 line je kat gpsExtractNodes.py and da siap.
Siapa yg nak bende ni leh email aku ...
Requirements:
-Python 2.3++
-pysqlite2 module
I am considering making this a stand alone to eliminate these requirements...
Siapa yg nak bende ni leh email aku ...
Requirements:
-Python 2.3++
-pysqlite2 module
I am considering making this a stand alone to eliminate these requirements...
Labels: programming
M road beta
This is my new project, a path finding system for roads in KL, ingat nk release. Skali tgk byk lak bug. Errors in the core engine that are hard to isolate and fix. This bug is a result of inadequate testing during AGILE development. Imagine what it would have been if I used the Waterfall technique.
Sesiapa nk join, help a bit or leave some comments for suggestions, YM aku sentiasa ada...
ps : life really sucks when you're injured ...
Sesiapa nk join, help a bit or leave some comments for suggestions, YM aku sentiasa ada...
ps : life really sucks when you're injured ...
Labels: programming
Tuesday, March 13, 2007
The Amazing Ant
This AlgoAnalysis project is doing quite well, unlike my other projects. Stuff like J2ME, etc. Took a while to get that running. Sbb aku mmg tak nak install IDE.
Anyway, ni sebahagian drpd build file ant...
The beauty about this part is that it auto generates the API for the classes that you build according to the JAVA standard API.
All you have to do is add comments above each function as shown in the image below and build the project.
Labels: programming
Monday, March 12, 2007
AlgoAnalysis prototype version 0.0.1
Projek ni nak generate statistics for algorithm performance testing. Hence, the name 'AlgoAnalysis'. This is just a prototype but the random graph generator has been completed using python. This prototype tests if those classes can be called from a JAVA program which I have successfully demonstrated in the screenshot above as I use ANT to build my project.
Interaction antara JAVA ngan Python menggunakan JYTHON. Drawback nye is that JYTHON guna Python2.2 je. Tatau lak bile nak release one for 2.4 / 2.5. As a result, certain functions takde. Tapi there are ways around that.
Python leh interact ngan JAVA. Nak panggil JAVA class senang aje, tapi nak panggil Python nye class payah sikit. Kene buat an intermediary class and embed Python scripts in the JAVA program as if sending commands to the interpreter.
Python :
JAVA :
As a result the python scripts are translated and compiled into
JAVA classes like so:
Interaction antara JAVA ngan Python menggunakan JYTHON. Drawback nye is that JYTHON guna Python2.2 je. Tatau lak bile nak release one for 2.4 / 2.5. As a result, certain functions takde. Tapi there are ways around that.
Python leh interact ngan JAVA. Nak panggil JAVA class senang aje, tapi nak panggil Python nye class payah sikit. Kene buat an intermediary class and embed Python scripts in the JAVA program as if sending commands to the interpreter.
Python :
import random
class Graph:
def __init__(self):
self.nodeIDList = []
self.nodeEdgelistDict = {}
self.nodeEdgelistWeightDict = {}
self.allowLoops = 0
self.allowMultipleEdges = 0
self.directedGraphType = 1
self.edgeWeightUpperLimit = 10
self.edgeWeightLowerLimit = -10
def generateGraph(self,nodeTotal,edgeTotal):
# add nodes first and define edge list
for currNodeCount in range(nodeTotal):
nodeID = self.getNextUniqueID()
self.nodeIDList.append(nodeID)
self.nodeEdgelistDict[nodeID] = []
.
.
.
JAVA :
package AlgoAnalysis;
import org.python.util.PythonInterpreter;
import org.python.core.*;
public class Graph {
private String variableName = "";
private PythonInterpreter interp = new PythonInterpreter();
public Graph(String newVariableName) throws PyException {
this.variableName=newVariableName;
interp.exec("import graphGenerator, graphAnalysis");
interp.exec(variableName+" = graphGenerator.Graph()");
}
public void generateGraph(int nodeTotal,int edgeTotal){
interp.exec(variableName+".generateGraph("+nodeTotal+","+edgeTotal+")");
}
public void toFile(String filename){
interp.exec(variableName+".toFile(\""+filename+"\")");
}
.
.
.
As a result the python scripts are translated and compiled into
JAVA classes like so:
Labels: programming
Sunday, March 04, 2007
Prinsip hidup aku ...
Man is a pupil, Pain is his teacher.
-Alfred de Musset
It is not because things are difficult that we do not dare, It is because we do not dare that things are difficult.
-Seneque
The wise man asks himself the reason of his mistakes, the fool asks others.
-Chinese proverb
Life's battles don't always go to the Stronger or Faster man,but sooner or later the man who wins is the one who thinks he can.
-Bruce Lee
-Alfred de Musset
It is not because things are difficult that we do not dare, It is because we do not dare that things are difficult.
-Seneque
The wise man asks himself the reason of his mistakes, the fool asks others.
-Chinese proverb
Life's battles don't always go to the Stronger or Faster man,but sooner or later the man who wins is the one who thinks he can.
-Bruce Lee