Pages

2009-01-05

Making a screencast from Ubuntu 8.10

(Hopefully I'll get back to this post with more details later. Bug me if I've left out something important.) I've been planning to make a couple of Norwegian Linux screencasts for some time, and yesterday night i sat for several hours to try to figure out the best way to do it. After figuring out most details I guess there is enough stuff interesting details to make a new blog post.

First attempts: Istanbul and Byzanz

Istanbul looked very promising, but after a couple of failed attempts (flickering in output video) I gave up. Byzanz seemed so limited that I didn't care to even test it.

Next attempt: vnc2swf

Back in September (according to timestamps on the recorded files) I tried vnc2swf, and got impressed by the ease of use and the size of the recordings. So I decided to give it another try. The reason why I didn't just use it in the first place this time was because of a gut feeling that there was some tricky detail I had to figure out. I was correct. Getting started is easy enough (here is a recipe that helped me getting started: Creating training movies with VNC2SWF. It describes the whole process, including how to record just a piece of your desktop.) Problem was just that the resulting file sizes quickly reached above 2 MB for just a few seconds of recording the terminal. Trying to find a solution to this problem I sat until 2 am in the morning before I went to bed, adjusting settings, using the edit program that comes with pyvnc2swf and trying different versions of pyvnc2swf. I also switched off desktop effects and tried to record from KDE. A funny detail I noticed was that recordings from my terminal window seemed to be bigger than recordings of nautilus. Today I found the solution: I just switched off the transparent background in gnome-terminal, and the video sizes was back to acceptable values. Inspired by the success of turning of the transparent background in the terminal, I went back to istanbul to see if the recordings would flicker less when I'd turned off transparency on the terminal background. Disappointment: I didn't. Then I clicked a checkbox saying "record 3D", and suddenly the recordings where OK. Summary: I now have two working solutions for recording desktop screencasts. :)

More information

Here are some more details that might be interesting if you want to record screencasts under Ubuntu Intrepid:
  • Resizing a window so it fits into your screencast: http://stackoverflow.com/questions/288512/resizing-a-window-to-a-set-size-in-linux.
  • The pick feature in x11vnc mentioned at Creating training movies with VNC2SWF is nice, but for some reason it doesn't include window decorations. Luckily x11vnc allows you to specify exactly what piece of the screen you want to record with the clip argument, e.g: -clip 640x480+600+400 .
  • pyvnc2swf documentation mentions pymedia. There's no package for it under Ubuntu 8.10 (Intrepid Ibex), but here's a howto that describes the process (I didn't find g++-3.4 in the repositories, and I had to use libmp3lame-dev instead of liblame-dev. Then, when I tried to compile it, I got an error, but I just continued to install it using checkinstall, and it seemed to work fine anyway.) Oh, yes, here is the howto pymedia on Ubuntu Hardy Heron.
  • Edit 2009-01-05: I was searching for a place to download recordwin.sh, until I discovered that it was included in the tar.gz together with the rest of the stuff.

2008-12-25

firesymfony - using firebug with symfony

Found a Firefox add on for symfony development while I was downloading firebug today. Haven't tried it yet, but might give it a try next time I'm working on one a symfony project.

2008-12-22

Three guys "switching to Windows"

(This post is heavily updated and is now just a list of links.)

  1. Howto switch from Linux to Windows - a users experience
  2. Switching to Windows: Not as easy as you think
  3. Is MS Windows ready for the desktop?
  4. http://www.mailinglistarchive.com/ubuntu-users@lists.ubuntu.com/msg90388.html
  5. http://climbing-the-hill.blogspot.com/2009/06/why-windows-is-not-yet-ready-for.html (added 2009-06-13)
  6. http://basementcoders.com/?p=245 (added 2009-06-23)

You may like this articles or not, but, after having used Windows since 1995, I feel qualified to say that these post are not just funny, they are also informational and most of all they represent a refreshing change. :)

Also, if you know more articles like these, please add them below. Also add them to delicious with the keywords getthefacts windows whywindowsisnotready, vote them up digg or whatever you want and help spread the word :)

Do you have a good one? Leave a comment!

Hacking the rich:pickList using jQuery

Another post about the JSF 1.2 upgrade.

Short description of the problem:

We had hacked together a custom pick list from before. After upgrading to newest JSF and newest RichFaces, we could use a standard pick list, except that the standard pickList didn't support any means of showing details about the selected item.

We could of course tried to subclass the RichFaces pick list component, but then we would be stuck with maintaining it. So instead we decided to just throw in a quick jQuery script. Of course, it would also be a good opportunity to learn a little more jQuery. (Yes, I've just started learning jQuery, so if you think you've got a better way to solve the problem, please leave a comment.)

Getting an event when somebody selects a cell

<ui:define name="perPageJavaScript">
<script>
jQuery(document).ready(function(){
                jQuery(".rich-picklist-source-cell").click(function () {
                               updateFooBar(jQuery(this).text());
                });
    });</script>
</ui:define>

Using the event to update a part of the page

<a4j:form>
    <a4j:jsFunction name="updateFooBar"
        reRender="fooBarTbl,fooBarBazTbl">
    <a4j:actionparam name="param1" 
        assignTo="#{fooBarBean.selectedFoo}" />
    </a4j:jsFunction>
</a4j:form>

the perPageJavaScript is just a way to insert a custom JavaScript into the header of one particular page.

Hope this helps someone. I guess I'm not the only one who needs this construct.

2008-12-20

Reduced size of my online pomodoro timer

Had forgotten to remove some pictures I used early in development of my online pomodoro timer. When I removed then, the size decreased from >1 MB to less than 100 KB :)

Hope this will reduce loading times significantly. If not, there is a feedback form on the third tab on the page. Feel free to report bugs or add feature suggestions.

2008-12-16

Upgrading a JSF 1.1 project to JSF 1.2

I've just upgraded a project from JSF 1.1 (MyFaces) with tomahawk to JSF 1.2 (Mojarra) with Facelets. Halfway through the process I realized it would be worth sharing, since I would have appreciated if somebody else had done that before me. (There is a description about how to make a new project with JSF 1.2 on http://forums.sun.com/thread.jspa?threadID=5156242, but I wanted to upgrade an old project.)

Facelets is XML

Because facelets are xml documents you need to change && in your expression language statements to &amp;&amp; (I found the tip here: http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=82&t=001835.)

Update 2008-12-23: If you're smart and read the documentation, you might also find out that you can just write and instead of both && and &amp;&amp;.

Also remember that xml comments are written as <!-- --> instead of <%-- --%>

We don't need the tomahawk taglib any more!

While I appreciate the effort that people has put into MyFaces/tomahawk, it also became a major hurdle in the process of upgrading the application. The reason is that it took very long time before the developers announced a JSF 1.2 compatible version, and by that time, I was already decided to get rid of that taglib.

We mainly used to use the tomahawk library for 4 different things:

t::updateActionListener

<t:updateActionListener value="#{fooBean.bar}" property="#{bazBean.bar}" /> can now be substituted with <f:setPropertyActionListener value="#{fooBean.bar}" target="#{bazBean.bar}" /> in the standard f: taglib.

t:dataList

t:dataList can be substituted with rich:dataList

forceId

The components in the tomahawk taglib has an attribute called forceId which overrides JSF's id generation, allowing you to specify the precise id you want for a tag.

There's no such things as a forceId attribute in any of the other taglibs we use, but luckily, with facelets you can now use plain html tags if that is what you want. Also, much of the reason for using forceId was for selenium testing. Later on, I learned that we could use xPaths with selenium to pin down a page element without resorting to the id. (If you decide to try, there is at least two different Firefox plugins that you can use to find the xpaths, and at least one of them is useable, I just can't remember the name.

The last reason for using tomahawk was either the sortable table or the fileUpload component. Luckily, both are easily available in the rich taglib.

http://www.google.com/search?complete=1&hl=en&q=Bean+or+property+class+javax.faces.model.SelectItem[]+for+managed+bean++cannot+be+found.+&btnG=Google+Search&aq=f&oq=

Using arrays in faces-config.xml doesn't work

At least not i mojarra. Here's my changes:

- public SelectItem[] getFooBarOptionList() {
+ public List getFooBarOptionList() {
      List optionList = new ArrayList(FooBazFooBarEnum.values().length);
      for (FooBazFooBarEnum fooBar : FooBazFooBarEnum.values()) {
          optionList.add( new SelectItem(fooBar.getValue(), fooBar.getValue()));
      }
-     return optionList.toArray(new SelectItem[optionList.size()]);
+     return optionList;
  }
  <managed-property>
-   <property-name>fooBarOptionList</property-name>
-   <property-class>
-    javax.faces.model.SelectItem[]
-   </property-class>
-   <value>#{fooBazDetailFilterBean.fooBarOptionList}</value>
-  </managed-property>


<managed-property>
+   <property-name>fooBarOptionList</property-name>
+   <property-class>java.util.List</property-class>
+   <value>#{fooBazDetailFilterBean.fooBarOptionList}</value>
+  </managed-property>

One last thing:

Here's some code to fetch whatever managed bean you need without injection. I don't suggest you should do anything like this, but if you have already done it, and need to upgrade to JSF 1.2, here is how:

From:

public static Object getBean(String beanName) {
    return getContext().getApplication().getVariableResolver().resolveVariable(getContext(), beanName);
}

To:

public static Object getBean(String beanName) {
    return getContext().getApplication().getELResolver().getValue(getContext().getELContext(), null, beanName);
}

Remember: use with caution, as the result may be hard to unit test.

2008-12-13

First usable result form my playing with JavaFX

I really like the pomodoro technique. So, while learning JavaFX, I made a software kitchen timer for use with the pomodoro technique.

The result can bee seen here: http://www.itlanddata.no/the-pomodoro-technique/. Click once to start, click again to stop.

I also used the opportunity to add a little jQuery goodness to the mix, allowing you to add to do's, urgent and unplanneds, sort and move elements from one list to the other.

Oh, and it's all done client side. There's no sign up form, your data is not stored on my server. You may even drag the applet out of the browser and into your desktop if you have a jre 1.6.10 or higher, so you don't even have to visit my page.