Archives for the ‘web’ Category

Swarm Intelligence in HTML5 Canvas

Swarm Intelligence - I wanted to visualize different ways of particles following each other for some time now but have never really gotten to the point of doing it until one day, I was browsing through lots of amazing things people have made using HTML5 Canvas. One of these things was Daniel Puhes Liquid Particles canvas thingy which immediately reminded me of my idea and I thought – why not try and do it using HTML5 canvas? I wanted to try canvas out a little bit anyway. So, I asked Daniel for permission to use his code as an “engine” for my idea and he was ok with that. Thanks Daniel! He also made some more pretty cool stuff so go and check that out if you want.

So I took his code, refactored it a fair bit, made it so that particles follow each other instead of following the mouse and that’s how Swarm Intelligence was born. I do know that this is not real AI but I don’t care, I just like to call it that way anyways. :)

At the moment there are three different algorithms that make particles follow each other:

  • swarm – each particle targets a random particle from the swarm and follows it for next 5000-10000 canvas refresh cycles. after that, it randomly finds a new one and follows it for next 5000-10000 refresh cycles and so on
  • tail – each particle targets a different random particle on each canvas refresh cycle and follows it for a single refresh cycle after which it targets a new random particle and then follows than one for a single refresh cycle and so on
  • lead – all particles follow the same (single) particle which moves randomly inside the canvas a bit faster than all the other particles

Algorithms change randomly over time but can also be changed manually by clicking  the left mouse button somewhere inside the canvas. I also introduced some chaos into the system so it wouldn’t stabilize itself over time. For example, every now and then some particles get randomly blown away from the swarm a little bit. Also, after some time all the particles will get blown away at the same time. I plan to add two or three more following algorithms when I get the time. One of them will be following the nearest particle but I will have to come up with one bad-ass algorithm to not kill the performance. Soon I guess. Or not. :D

Algorithm indicator in the top left corner of the canvas introduced some performance problems. Apparently, drawing text inside canvas is very, very poorly implemented in all browsers except Chromium. The problem I had was that I would redraw a line of text inside canvas on each refresh cycle (every 70ms) which slowed it down a fair bit if you tried to run it in anything else except Chromium. Redrawing the text on each cycle wasn’t really necessary since the text stays the same most of the time so what I did was – on top of the old canvas frame I added a new one which redraws text only when the following algorithm gets changed. That turned out to be a pretty good solution.

Nothing more to say about this small experiment I guess.. except – enjoy it! :)

GEdit FTP browsing / editing under KDE
(using GNOME bookmarks without Nautilus)

Problem with using GEdit (v2.30.4 in the moment of writing this post) for FTP browsing/editing under KDE (if you don’t have Nautilus installed in your KDE) is that since it is a GNOME app – you need a way to somehow manage your connections which is usualy done through Nautilus by using GNOME bookmarks (the ones you would create by going to Places -> Connect to Server) and at the moment there is no way to create this bookmarks from within GEdit.

Anyway, you can do the same thing by editing .gtk-bookmarks file located in your home folder even if you don’t have Nautilus installed. Here’s a few examples of what you can put inside:

1
2
3
4
5
ftp://username@domain/ bookmark_name
ftp://username@domain/:3322 bookmark_name
ftp://username%40domain@domain/ bookmark_name
ftp://username@domain/folder_path_option/ bookmark_name
sftp://username@domain/ bookmark_name

The first one is just a regular FTP login bookmark. The second one uses a different port than the default one. The third one is for usernames containing @ (like in the image below) which you have to replace with %40 to differentiate them from @ for domain association. The fourth one uses the folder_path_option like in picture below and the fifth one is for using sFTP. Of course, you can combine all this together depending on your needs…

Browsing/editing directly from GEdit is much faster than using Filezilla which prompts for uploading every time after you edit and save the file which is kinda annoying, or for example using Krusader which works well with FTP, but if you use sFTP – then it edits files localy instead of online so you have to save them as a new file and upload them again… You get the drift.

druydsong a day, keeps silence away!

Thank you Druyd =)

ReverbNation WordPress plugin not working

reverbnation

Ok, so you want to merge your bands Reverbnation profile with your wordpress website and you have installed the official WP plugin (v0.1 at the time) but it’s not working when you put the shortcode into a text widget? There are two possible reasons for this:

1. Your WP theme does not support executing shortcode from widgets – find a fix here.

2. ReverbNation server sources are commented out in reverbnation-widgets.php – find this file via FTP or through Dashboard and comment out ‘Development’ sources and enable the ‘Production’ ones. It should look like this:

1
2
3
4
define("RN_WIDGETS_CACHE_SERVER", 'http://cache.reverbnation.com');
define("RN_WIDGETS_WEB_SERVER", 'http://www.reverbnation.com');
define("RN_WIDGETS_AUDIOLIFE_CACHE_SERVER", 'http://cache.audiolife.com//');
define("RN_WIDGETS_AUDIOLIFE_WEB_SERVER", 'http://ws.audiolife.com/');

That should do it.

One more thing – you should probably use HTML source-code ReverbNation provides if you have an account there instead of this plugin because it’s much more versatile and provides you with more options to manipulate the appearance of ReverbNation widgets looks (v0.1).

have no fear, for duende is here!

duende

duende didgeridoo

With du & da (thank you!) waching over my shoulder, providing me with plenty of wishes and material to work with, we nailed it in due time using wordpress, customizing its bits, and driving it to its very edges. Honestly, I didn’t think wordpress could pull off something like duende (especialy navigation-wise), but there is always space to learn something new. ;)

I hope you enjoy duende as much as I enjoyed making it… =)