Drawing lots online

As a member of Toastmasters club I sometimes lead so-called Table-Topics in which I need to give participants tasks from a list of tasks – randomly, without repeats (unique task per participant).

I’ve used a free iPhone app in which I could configure the texts of tasks and which returned a random result on shaking phone. But I wasn’t satisfied with it. First of all it had a fixed amount of item slots so I had to leave blanks for non-used slots, and often got blank instead of a result. And I was getting results that were already used – repeats – so I had to shake more and more until I got valid result. The number of slots was big enough though, but still it was also theoretically possible to have a need for more tasks than the slots in the app. So 3 downsides in total.

So I spent several hours to quickly code my own solution – in HTML+JS+CSS, so I could use it on desktop and on mobile easily.

Here it is: http://mvmn.ho.ua/lot.html?items=one;;two;;three…

It’s all single file HTML+JS+CSS, no external libs are used, so it can be cached locally and used offline. All the data (list of items to choose from) is going into URL. This imposes a limit on total text length unfortunately, but for me that’s not a problem – hopefully won’t be a problem for you either. Otherwise storing data in URL only makes it very convenient – again, you can use it offline, and there’s no need for a server-side storage, which makes it all work faster.

I also tried to make UI touch-friendly, and tested it on my good old iPhone 4.

The source code is on GitHub: https://github.com/mvmn/lot

A couple of screenshots from iPhone: Continue reading

Screen area to Animated GIF

Recently I’ve discovered that there is a plethora of platform-specific utilities that can repeatedly capture region of the screen and then save the resulting images as an animated GIF. To me this sounds like a perfect task for JVM, since JVM includes support for screen capturing and creating animated GIF images, and all this comes with cross-platformness.

Thus I took the time to implement such utility. And here it is:
Executable JAR of first complete release can be downloaded here:

Let’s start with the demo right away!
(UPD: see demo on Raspberry Pi at the end of the post)

Here is the GIF that shows the utility in action. This gif was produced by second instance of the utility capturing the screen part where the demoed instance was displayed. Nice, huh? I ran screen capturing while I ran screen capturing so I could capture screen while I capture screen (-;

Continue reading

Reinventing the wheel – custom Dates API

I’ve started on the re-implementation of command-line java calendar tool in order to provide support for relative dates and other features, and while working on it I got a bit carried away with implementation of what turned out to be no less that custom dates API+implementation.

It’s pretty basic, and was done more as an exercise than for any particular need, but still I believe some interesting concepts can be looked up from it.

Though not yet complete, the code of JCCal was already committed to GitHub: https://github.com/mvmn/jccal . The dates API+impl classes can be looked up there already (in package x.mvmn.util.dates). Please also check the README there for general explanations.

I won’t be doing much explanation here, since it would mostly be copy-pasting of the readme for general things, and copypasting of actual code for the details. As someone said, “The truth is in the code” – so I encourage anyone who is interested to actually look up the code.

Liferay 6 CP portlets for site admins + sources

As mentioned in previous post, I’ve been planning to make a little Control Panel portlet for Liferay 6 that would allow site admin to tell on which pages particular portlets are.

Today I’ve written two portlets for this. One allows you to see which groups and pages you have, and check portlets are on those pages.
Another – see what portlets you have, and check on what pages do you have instances of those portlets.

Little warning:
Portlets are pretty fresh, so there’s a chance something might fail or not work quite right.
Also the code is not very efficient, yet I haven’t got any OutOfMemory exceptions during the whole day of writing and checking, so in general they should be fine (-:

Without further due, here’s the download link. Sources are contained inside WAR file.

Portlets are written for Liferay 6.0.6 Community Edition (using corresponding plugins SDK), and should also work just fine on Enterprise Edition (though I haven’t checked yet, I’m pretty sure they will).

WAR is compiled for Java 6, some occasional @Override-s are present in code – remove them and recompile if you need it for Java 5. I might as well change it to Java 5 version a bit later…

AppleScript fun: iTunes/Cog current music in Skype status

Skype Current Music
AppleScript is Power! AppleScript is Fun! AppleScript will take care of putting my current music from iTunes and/or (most important) Cog to my Skype status.
Yes, there are tons of programs that will do it for iTunes, but not for Cog. This script will do it for both, and you can have both running at same time – if iTunes is running but isn’t playing, Cog status will be posted. Cool, huh? (-:

The code is based on the snippets provided by some good people in these posts:

Thanks people!

Note: code updated on Tuesday 26-th of October – now your custom status message will be shown before music. Music will always be added after it (even if tracks change and music info is already in mood message it will be handled properly).
Updated on 30-th of October! Support for titles of streams added (webradios etc).
Updated on 9-th of January 2011: fixed bug with iTunes track title being periodically replaced with Cog track title in case both apps are running but iTunes is currently playing. Updated screenshots.

Continue reading

Maudlin of the Copyleft Audiophile

One of the problems with music “piracy”, often named by copyright advocates, is that musicians themselves won’t have money to pay for studio time and other recording related services. I’ve been thinking about this from the copyleft point of view, and had an idea of “record pre-order”: the fans that ask for new album pay for it before the creation/recording starts. If in alleged time the sum is enough to do recording, the process starts. Otherwise everyone gets back his money and all the participants go home with nothing.
I didn’t really think it is possible in practice, because this kind of scheme requires decent level of “audiophile culture” from fans and decent organization from band/artist. On the other hand – who knows, maybe it already works for some bands. Anyway, since I’m not the quickest person on this planet, someone probably had already tried it.

Recently I’ve learned that the great Maudlin of the Well band, which has disbanded some time ago, reformed and released a new album. Great news!
But even more pleasant and surprising was that the album is officially available for free download (including lossless formats) because it’s recording was completely paid of fan pre-pays/donations (but still you may donate to the musicians themselves to reward them for their time and effort). So there is at least one completely working example of the above mentioned idea in practice.