Funky Monkey Software | Development, Applications and Chimps

CAT | Development Work

The last few weeks have been pretty nice for me since I've had lots of lectures and not much else to do. Unfortunately, I've just been hit in the face with a bucketload of assignments and I've really got my work cut out! I've already had 7 assignments announced, 2 of which I've completed, and one of which I'm half way through.

I'm currently working on my AI assignment in which I have to use Bayesian Logic/Fuzzy Logic/Both to calculate whether or not to insure someone given their driving profile. I've found some really interesting stuff while I've been doing this, I've also found that almost all of the literature to do with these topics is aimed really high and not very accessible to the likes of me. I'm hoping, once I've got my head around all this stuff, I'll be able to release a working version of my car insurance system online for you to see.

This next week is the last week of uni before easter. After that, I'm off to buy a car, look at houses and do all sorts of fun things that I can't do at the moment.

I'll write again soon,

James

· · · · · · ·

My friend FlabbyRabbit (over at HackThis) recommended that I start blogging about my software projects so that I can help other people with their projects and have something to look back on when everything is finished. For this reason, I've decided to start writing about ADM (my Android Download Manager) as I develop it, documenting my trials and tribulations as I go along.

So What's going on in the world of Android and downloading at the moment? Well, ADM still doesn't really do much in all honesty. Currently, you can add URLs to the database and ADM will check them for you to see if they are online (provided the relevant downloader plugin is installed).

I've had quite a lot of trouble getting the threaded parts of the application to talk to each other in a meaningful way. The need for threads in an application that does a lot of networking is fairly obvious. The user doesn't want to be sat there waiting for something to happen for hours with no progress dialog. Users want results. Therefore, I've put in a system that goes off, downloads the data and then returns it to the GUI thread while the GUI sits with a progress bar, waiting patiently for some useful input.

Unfortunately, my first attempts at this were met with a rather nasty looking exception "CalledFromWrongThreadException". This basically states that a secondary thread is not allowed to alter a view that was created by a primary thread. That is, if Thread A creates a layout and Thread B goes off and does some work, Thread B is not allowed to update the layout directly.

"So how can we get around this?" You might ask. Well Google have kindly provided a nice answer for you: Handlers. Handlers can be used as a 'proxy' between the two threads, passing information from B back to A. Therefore I can simply implement a handler within my first thread with the following code:

    // Define the Handler that receives
    // messages from the thread and
    // update the progress
final Handler handler = new Handler() {
public void handleMessage(Message msg) {
//progress has been made, update the thread GUI
            updateGUI();

}
};

Then, the second thread (thread B) can just call:

Message msg = mHandler.obtainMessage();
msg.arg1 = total;
threadA.handler.sendMessage(msg);

So there you have it. I'll be posting some screenshots of ADM soonish :)

· · · · ·

Feb/11

14

Android and ADM

The last few weeks have been incredibly busy with a huge number of activities going on, including revision for exams and Work Week. Now that I finally have some free time, I decided to have a quick look into the development of Android applications using my Scroll. I noticed that there is currently a lack of JDownloader-esque apps for Android and when I'm up on the uni campus with only my Android, I'd like to be able to download stuff on masse using the University's stupidly fast connection. For these reasons, ADM was  born

ADM (pronounced 'Adam') or Android Download Manager, is going to be a fully fledged download core system complete with link parser/checker functionality and a file hosting crawler that searches places like Rapidshare and Hotfile for relevant downloads that may interest the user. I may also build in un-rar functionality too. I've started working on it and have some early designs and stuff, but nothing too exciting.

I'll post more info when I have something exciting to show you. Unfortunately, my WordPress Script seems to hate me and is not letting me upload images or anything at the moment!

· · · · · · · ·

Feb/11

4

Coding Week

This week has been one of the most intense weeks of my University career so far! I've had so very much to do in so little time and as I write, I'm basically falling asleep.

As part of our degree this year, we had to write a small Java application for organising car shares in and around the university town using a PostgreSQL database. We've been maintaining the code in Subversion and running lots of JUnit tests on it to make sure everything works nicely. As part of the project, I've learned a lot of stuff, especially on Postgres databases and Java, but also on how to work with and manage a team during a large IT project.

I was dreading this week at first, but it's actually been really cool and I've made some really good new friends and learned a lot of new things. If working for IBM is anything like this week, I'm sure it'll be a hoot!

· · · · · · · · · ·

One of the most interesting modules that I've  been studying this semester has been Artificial Intelligence.

I've been shown how to do lots of very complex, intelligent things with computers including the use of Search Trees to find a solution to a complicated problem, how to use Genetic Algorithms and Genetic Programming to 'evolve' complex solutions and how to cluster data into groups and classify labelled data.

As a revision exercise (but also just to see if I could) I decided to try and cluster my music collection into genres using K-Means and Agglomerative Hierachical clustering. I originally planned to use the actual shape of the music (through wave form analysis) as my metric to find the distance between tracks. However, I simply don't have the mathematical expertise for this job. Therefore, I've been implementing the system using Last.FM metadata and comparing tags assigned to songs.

The biggest problem I've had so far is establishing some rules and some form of distance measure using the tagging system. However, after some lengthy googling, I came across this little gem of information. Essentially, it suggests assigning each possible tag a weight based on the frequency of its use. If a tag is used 5 times and the overall number of taggings (that is assignments of a word to a track, not the number of words themselves) is 100, then the tag's weight is 1/20.

With this system in place, its really easy to start building a picture of a song's 'weight' and matching tracks. The next part was the clustering of the tracks using a Hierarchical Agglomerative approach. This basically means, taking the Euclidean value of each cluster and merging it with its closest neighbor until there is only one big cluster left. Unfortunately, my python code really doesn't want to play ball, so I've written off to the python mailing list to see if any of them can solve it. But if you are interested in seeing the program I came up with, take a look at this python code.

I'm hoping to figure out why this isn't working myself, but any input would be very valuable to me.

"Dude!, She just called you useless!" "OH HELL NO!! Hold my Bachelor of Arts!"

· · · · · ·

Dec/10

26

Season’s greetings

So, as quickly as ever, it seems that Christmas has snook up on us yet again! The Christmas holiday period marks a highly anticipated break from student life for me and many of my student colleagues. It's also a great opportunity for me to start getting creative and using a lot of the knowledge I picked up during the uni semester to develop some new software packages.

Christmas also brought me a lovely new android tablet to play with, providing me with the perfect opportunity to have a go at writing some android apps. I'be harassment wonderful day today and a wonderful year in general (although I'll save all the reminiscing stuff for my new year's post).

All the best and lots of Yuletide cheer

James

· · · · ·

Jun/10

24

Predtr, The Lakes and Alton Towers

So, I've been mighty busy with my latest software project, PREDTR as of late. I'm afraid I'm keeping PREDTR quite hush hush at the moment, but all will be when it is released (for the most part under the GNU license and eventually available from predtr.funkymonkeysoftware.com. I'm hoping the project will be useful to someone, its certainly been interesting developing it and its keeping me on my feet in terms of Java too.

Today, me and my Dad's side of the family are heading up to the Lake District for a long weekend. My Dad and Grandparents are from Hoole and they've always been drawn to the North. We're off to see Kendal where my Grandad used to be the caretaker for the museum, and for a walk along Scout Scar. We'll be up there for a few days returning on Sunday. I will then be getting an early night in preparation for my trip the next day.

On Monday, myself and a few of the Ludlow gang (as well as Luke and Nat from uni) are going up to Alton towers for the day. We managed to find some half price coupons (its £35 per person, who'd pay full price?) and will be checking out all the rollercoasters that can be squeezed into a single day.

I leave you on this note: "How many Bears could Bear Grylls Grill, if Bear Grylls could Grill Bears?"

· · · · · · · ·

Its been a while since I last had a go at using Haskell. We had to learn it as part of our first year course at University and it was a very eye-opening experience (as programming experiences go that is). Unfortunately, there's not much call for the use of Haskell in the real world, it appears to be one of those 'academia-only' oddities that the computing industry doesn't really care about. I think Haskell is a fantastic language that really makes the writer think about what needs to be done much more carefully than most mainstream procedural languages. The code is also much more efficient (more semantics per line) than many procedural languages too.

To start with, I was trying to figure out how to build a templating library that converts strings into code. For this, I needed a split function that takes a string and a deliminator and returns a list of strings. There are already lots of examples of how to write such a function for a single character deliminator available out there. For example, check out this four year old post from Julio Merino. This provided me with somewhere to start, but the problem of having to parse many characters to determine the location of a deliminator was not helped here. After a little bit of messing around, I figured this out for myself, and came out with the following.

--The split function takes a long string and a deliminater and breaks up the long string every time the deliminater is found
split :: String -> String -> [String]

--trying to split an empty string returns an empty string --what else did you expect fool?
split [] _ = [""]

split (c : cs) delim
	| shouldSplit cs delim = "" : (drop (length delim) (head rest) ) : tail rest
	| otherwise = (c : head rest) : tail rest
	where
	   rest = split cs delim
	   shouldSplit _ [] = True
	   shouldSplit [] _ = False
	   shouldSplit (c : cs) ( d : ds)
	     | c == d = shouldSplit cs ds
		 | otherwise = False

Feel free to use this anywhere you like. I don't mind whether you attribute it to me or not, as long as its useful to someone. Also, if any hardcore Haskellers want to leave improved code, feel free! I do love a bit of constructive criticism.

EDIT: Also, please note the lovely Haskell syntax highlighter plugin for SyntaxHighlighter: Evolved written by Alessandro Vermeulen

· · · · · ·

Jun/10

8

Code Generation using XML and XSLT

NERDY ARTICLE ALERT!

I'm currently working on RAPTR, my latest and deadliest weapon in the automatic coding war. I won't go into what it does until its all ready to go and I've deployed it, but the crux of it is that I'm generating lots of code for various languages using XML and XSLT. As a direct result of this, I've been learning quite a lot of interesting stuff about XML and how to write valid documents.

I've written no end of XML based programs in my time and they've, thus far, been relatively successful. However, I've never been that bothered about whether my documents are valid or not, they've been "well formed" and that's been enough for me. Today, I decided I'd take the plunge and learn how to write a proper DTD so that I can validate my documents and make sure that everything is completely by-the-book. I found a lovely little command-line utility called 'xmllint' which can be used to validate your documents on the fly and make sure that they comply to your DTDs. It comes as part of the LibXML2 utils pack which can be installed on Ubuntu as easily as:

"sudo apt-get install libxml2-utils"

The next part of my epic quest has been learning how to deal with XSL. This is traditionally used to turn XML documents into viewable HTML web pages. Its essentially a collection of rules that tell the parser how to transform bits of an XML document into something else. I've been using it to turn XML data I've stored into PHP scripts. Again, I got a lot of help from a little commandline utility called 'xsltproc'. This takes the 'stylesheet' or as I prefer to call it, the template, and an XML document and produces output exactly as the template describes it.

It amazes me how simple but effective all this stuff is. In just a few days,  RAPTR and its related tools are going to be up and running and saving me a hell of a lot of time.

· · · · · · ·

May/10

31

Too Many Natives spoils the broth…

So, its been a few weeks since I upgraded my African themed, Ubuntu to the newest version 10.04. I hadn't found any problems with the new OS and everything was running smoothly. Then, when I tried to do a bit of development using the Apache web server on my machine, I discovered that my PHP installation was broken, or at least wasn't responding in the way that I expected it to. I was getting a prompt in my web browser to 'Open' the PHP files which the server was sending me raw. I spent hours researching the problem and had very little luck. The Native Africans had obviously had a disagreement with the Native Americans during the upgrade process.

I had a bit of a brainwave and it occurred to me to check whether it mattered which PHP script I retrieved was stored. It turns out that PHP was working perfectly well when the script was stored in the main web directory (/var/www) but not when the scripts were stored in the UserDir. It turns out that there were a few new lines in one of the Apache configuration scripts that had disabled PHP in user directories. To resolve it, simply follow these instructions.

Open the file /etc/apache2/mods-enabled/php.conf in your favourite text editor as root. Then comment out the following lines:

<IfModule mod_userdir.c>
<Directory /home/*/public_html>
php_admin_value engine Off
</Directory>
</IfModule>

For some reason, these were added to turn the PHP processing engine off in all user directories. Not quite sure why, but a simple restart of the server with: sudo /etc/init.d/apache2 restart should fix things.

If you find that this still doesn't resolve things, try clearing your Browser cache (in firefox Tools->Clear Recent History).

· · · · · · · ·

Older posts >>

Theme Design by devolux.nh2.me