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
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 (-;
Eclipse WTP Tomcat and JBoss adapters have a certain bug that I’ve encountered recently, and due to conditions it occurred in it took almost a detective work to figure out.
I added a video below with all the details and a little demo – just for fun.
Long story short, the bug occurs on starting the server (be it Tomcat or JBoss) from Eclipse. When starting it Eclipse WTP Server Adapter starts a thread called PingThread that tries to connect to the server. If connection is OK, server is considered to be “Started”. Otherwise it’s shown as “Starting”, and if there’s a startup timeout configured, after the time of timeout passes server gets killed.
A couple of times in my life of java programmer I used a trick to put some code ending with “return false;” within Eclipse’s conditional breakpoints just for sake of having that code executed each time JVM goes over the breakpoint, but without the actual suspension of the thread. Or well, suspending would happen anyway, but Eclipse will resume thread automatically after executing the code due to “return false” in the end which would indicate “false” for breakpoint condition value to the Eclipse. As a result program will continue to execute, and no suspending that would require manual resuming (or any interaction) would happen.
The simplest example of the case when one can need that would be logging some variable value of which changes in a loop, and you want to know it’s last value before something happens in the system (say exception occurs). Nothing simpler than just putting a breakpoint to a next line after variable assignment, and setting “System.out.println(theVariable); return false” as a breakpoint condition.
The question that bugged me though was wether I can do it in more controller way. For example from Groovy Shell, which is currently my favourite tool for quickly running several lines of ad-hoc Java code, i.e. for scripting using Java (previously I used BeanShell for that). And it turned out that one can do that fairly easy using JPDA/JDI.
Sometimes it is necessary to obtain a content of the portlet programmatically in hooked JSPs, but the APIs do not make it clear at all how to accomplish that.
There are some suggestions on the web on how this can be achieved, but the code seems to be somewhat complex, which makes it a problem to use in hooked JSPs.
For hooks there is a simpler method, but it relies on being executed in hooked JSPs by referring to some classes in portal-impl.jar:
Couldn’t find a pic where standard tuned guitar frets would be displayed as black+white piano keys. So I’ve coded a little script/app for that using Codea (IDE+runtime for coding for iPad using Lua):
This is 7-string (electric) guitar in Standard tuning (i.e. just like 6-string + 1 additional string for lower notes), ’cause I have a 7-string one – so I needed that additional string too.
Yep, it also produces sounds when keys/frets are touched (with multitouch). Codea is fun.
%~dp0\groovysh "Eval.me(new File(\"%1\").text);"
Or is there a better way to run groovysh with script file as parameter?