dropbox-servicemenu-kde
I just wrote a KDE service menu wrapper around the Dropbox python CLI. For more information please go here.
On another note, if you haven’t tried Dropbox I advise that you give it a go by clicking here
I just wrote a KDE service menu wrapper around the Dropbox python CLI. For more information please go here.
On another note, if you haven’t tried Dropbox I advise that you give it a go by clicking here
A few weeks ago I wrote a post which introduced the BOLD Project. Well, a lot has happened since then and this post gives an overview of the translation system which I am building.
The translator is split into three parts:
The Preprocessor
The preprocessor is called as soon as an image is inserted into the repository. The preprocessor works by first segmenting the Bushman words in the dictionary. It does this by exploiting the known fact that every Bushman word on a page is underlined by a solid black line. Once the Bushman words have been segmented, specific features are extracted from them and these features are stored in inverted files. Once the features have been extracted then the orifinal image, the segmented words and the inverted files are all stored in the repository.
The User Input
The user who is accessing the Bleek & Lloyd notebooks uses a tool to select a specific word on a page which then becomes known as the key. The same features which were extracted from each word in the preprocessor are extracted from the key. These features along with the key image will be used later for matching.
The Matcher
The matcher starts by taking the features belonging to the key and finding images with the same features in the inverted files. For each feature match, the score of the image which matched increases. At the end of all the feature comparisons, the images with the highest scores are returned. At this stage there may be some images with the same or similar scores, so to resolve this clash the matcher performs a more intensive comparison between the key and the images with the highest score. Based on the result of this comparison, the most likely match is returned.
So that’s how the BOLD Translator works. Ultimately it is a framework which means that it will be designed such that anyone can adapt it and make use of it by plugging their own algorithms into each of the specific parts. In the next day or two I will blog about the actual work that has been done on the system up to now as well as show some of the results that the translator returns at this point.
HOWTO get a NetBeans JTable to automatically expand when it runs out of space. That is, add new rows whenever needed.
Step 1:
Create a normal JTable in NetBeans
Step 2:
Add a PropertyChangeEvent handler to the table via the inspector window.
Right click jTable1 -> Events -> PropertyChange -> propertyChange
This should take you to the source.
Step 3:
Add the following to the PropertyChangeEvent handler:
private void jTable1PropertyChange(java.beans.PropertyChangeEvent evt) {
int last = jTable1.getRowCount(); //count the number of rows already in the table
if (jTable1.getValueAt(last-1,0) == null){ //check if there’s anything in the first column of last row
//first column of last row is empty, so do nothing
}else{ //last row was not empty
Object o[][] = new Object[jTable1.getRowCount()+1][jTable1.getColumnCount()]; //create a new 2D object with size the same as the table+1
for (int i = 0; i < jTable1.getRowCount(); i++){ //loop through the rows
for (int j = 0; j < jTable1.getColumnCount(); j++){ //loop through the columns
o[i][j] = jTable1.getValueAt(i,j); //populate the new Object with values from the table
}
}for (int k = 0; k < jTable1.getColumnCount(); k++){
o[jTable1.getRowCount()][k] = null; //add a null row to the new object
}//set the tables new model with “o” as the first parameter – o is the new object
jTable1.setModel(new javax.swing.table.DefaultTableModel(
o, new String [] {
“Firstname”, “Surname”, “Birthday”
}
)//Create the rest of the table model – copied from generated code
{
Class[] types = new Class [] {
java.lang.String.class, java.lang.String.class, java.lang.String.class
};public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
});
}
}
And that’s it – your table should now automatically expand when necessary.
The same logic can be applied to deleting rows when they’re not needed.
Below is an complete program which shows automatic table expansion in action. It can be downloaded, compiled and executed independently.
Source: TableExpandGUI.java
I had the problem of needing to populate a MySQL table with dates between openingDate and closingDate, using Java and JDBC Connector/J.
Well, after a while I figured out how to do it and thought I’d share it with you.
Step 1: See how many dates will need to be entered
ResultSet rs = statement.executeQuery(”SELECT DATEDIFF(’2007-07-01′, ‘2006-07-01′);”);
rs.next();
int days = rs.getInt(1);
The MySQL DATEDIFF query calculates the value of date1 – date2, in this case (2007-07-01 – 2006-07-01) which evaluates to 365.
The days variable takes the value of the first column returned by the ResultSet object, which is the result of the DATEDIFF query.
Step 2: Insert the days into the database
for (int i = 0; i <= days; i++){
int j = statement.executeUpdate(“INSERT INTO MyTable VALUES (’2006-07-01′ + INTERVAL ” + i + ” DAY);”);
}
This statement will need to be customized to suit your table but essentially what it does is takes the first date specified, and add 1 day for each count in the day variable.
At the end you have a table filled with dates!
Aaron Siego, president of KDE e.V recently made a post titled “Getting into KDE hacking” which reminded me of the reason I started this blog in the first place – to detail my journey into the world of KDE hacking.
Truth is though, that I haven’t posted anything related to KDE hacking since I started this blog, mainly because I haven’t had the time to do any of the great free software things I plan to do. Anyway, Aaron highlight 6 steps to getting involved in KDE hacking, and so far I’ve completed the first one which is learning Qt4. So not all is lost, I am one step closer to developing free software for the desktop environment which I have grown to love over the years (more on that another time).
Learning a new language is never an easy thing – especially if the new language is a programming language. In the past my approach has been to start learning a language, work on it for a a couple of days till I feel competent at it, and then forget about it.
The problem with that approach is that three months down the line when I want to write an application in that language I’ve already forgotten it – as was my case with COBOL and Python.
For the last year or so I’ve been coding in c++ though never really got involved in any large projects, resulting in something similar to my COBOL and Python woes…I keep forgetting the semantics and syntax of the language!
However, for about the last two months I’ve been working on a project in c++ almost every day, and the result – familiarity! It’s led me to conclude that the best way to learn a programming language and become fluent in it (so to speak) is to work with it every day on large project which encompasses all aspects of that language…but you knew that anyway, didn’t you!
A couple of months ago I had the idea to start up a site, openwarriors.org, which I would use to highlight “individuals committed to open source.” So I went ahead and registered the domain, uploaded a placeholder index page (which is still there) and waited for the right time to get started on the project.
Now that I’m on a seven week holiday I have the time to get started on my openwarriors.org project. However last night I started doubting the project, the reason being that if it becomes successful I won’t be able to sustain it, one because of the bandwidth costs and two because of the time that I’d need to put into it.
Since I’ve really been getting into open source hacking in recent times I decided to make my ventures into it’s world the focus of openwarriors.org and thus (for now) scrapping the original idea. So, I’ve started this blog on iblog.co.za and named it openwarriors.org. In this blog I will detail my experiences with open source hacking, primarily focusing on KDE and specifically KDE4. And thus I announce my holiday project: in order to get a good feeling for Qt and KDE4 development I’m going to develop a KDE4 Financial Calculator. For this project I’ll detail my setting up of KDE4 for development, the resources I use to learn how to create KDE4 applications and any other interesting things I might run into while experimenting.
However KDE won’t be the only focus of this blog, anything which I find interesting relating to open source software will be posted here, so keep a look out…
Recent Comments