Snippets code from my daily experience

August 22, 2007

How to create youtube good quality video-tutorials

Filed under: divx,video,youtube — dafi @ 6:24 pm

I’ve tried to create short video tutorials using screen capture softwares.
These tutorials uploaded on youtube was ugly to watch 😦
Soon I realized it was difficult to obtain good quality movies without some trick.

Finally I found simple rules to obtain good videos:

  • Video dimensions must be 320×240 pixels so youtube doesn’t need to resize it
  • Use a good compression algorithm like DIVX
  • Use panning so the captured area automatically scrolls following the mouse cursor movements

The (free) software used is CamStudio and the encoder is DIVX.

CamStudio configuration:

  • Fixed Region with dimension set to 320×240
  • Autopan enabled and autopan speed set to max value
  • “Video Options quality” set to 60 and “key frames every” set at 30 frames

Now tutorials are good enough, take a look yourself 😉

August 20, 2007

Script to tag SVN projects

Filed under: svn — dafi @ 6:01 pm

I always forget to tag versions on SVN, the command is simple but my mind isn’t unable to hold this information 😉

I hope to help myself with this simple bash script and I hope to remember I’ve already written it.
The script is very very very stupid; it takes two arguments the project name to save and the version number to use to tag the project then performs the svn cp command

svn_version_tagger.sh table2clipboard 0.0.2.4

The script is here

August 18, 2007

Put in clipboard same content in multiple formats using XUL.

Copy plain text in clipboard can be obtained using code shown below.



Components.classes["@mozilla.org/widget/clipboardhelper;1"]

    .getService(Components.interfaces.nsIClipboardHelper)

    .copyString("<font color=’#FF0000′>Hello world</font>");

Using this approach you can easily copy HTML text but… it remains plain text!
So if you copy the string <font color=’#FF0000′>Hello world</font> inside OpenOffice Calc (or Microsoft Word) you don’t see the text “Hello world” in red but the plain HTML tag.

Copy data (not necessary text) using a specific format requires nsITransferable‘s use.
You specify the mime type and if destination application (where you paste the data) is able to understand the format the correct result appears.

The code below insert real HTML data into clipboard and when you paste for example in OpenOffice you see the colored text.



var textHtml = "<font color='#FF0000'>Hello world</font>";

var xferable = Components.classes["@mozilla.org/widget/transferable;1"]

    .createInstance(Components.interfaces.nsITransferable);

xferable.addDataFlavor("text/html");

var htmlstring = Components.classes["@mozilla.org/supports-string;1"]

    .createInstance(Components.interfaces.nsISupportsString);

htmlstring.data = textHtml;

xferable.setTransferData("text/html", htmlstring, textHtml.length * 2);

var clipboard = Components.classes["@mozilla.org/widget/clipboard;1"]

    .getService(Components.interfaces.nsIClipboard);

clipboard.setData(xferable, null,

        Components.interfaces.nsIClipboard.kGlobalClipboard);

Consider you want be able to choose if text must be pasted like HTML or plain text, for example because some application can’t handle stylished code.
Consider a plain text editor, it handles text not colorful HTML so you need the ability to paste based on destination application.
It’s easy! You only need to add a new flavor to the code shown above



var plainText = "Hello world in plain";

xferable.addDataFlavor("text/unicode");

var unicodestring = Components.classes["@mozilla.org/supports-string;1"]

    .createInstance(Components.interfaces.nsISupportsString);

unicodestring.data = plainText;

xferable.setTransferData("text/unicode", unicodestring, plainText.length * 2);

Now text editors receive the string “Hello world in plain” without any formatting and rich editors receive a colored “Hello world”.
Rich editors like OpenOffice Calc or Writer allow user to choose how to paste using the “Paste special” function.
You can choose to paste the same data in different format or different data per different format.

Table2Clipboard uses two flavors, you can take a look at its source code here.

Create a free website or blog at WordPress.com.