Posts Tagged ‘job’

How to limit a field with javascript-prototype and display the counter

Wednesday, December 3rd, 2008

For job purposes I had to learn a lot of JavaScript, including AJAX related stuffs. Like every lazy (but intelligent) developer, I looked around for frameworks that could help me doing my work. I knew that prototype existed, but I never looked at it because of lack of interest. Well it's great, it's really great! Nowadays everybody should use frameworks, as their abstraction permits a rapid development without worrying about things like platform compatibility, in our case browsers. Prototype also has a very nice and clean syntax that overtakes functions not compatible with every browser.

In this post I'm going to report a very nice function I implemented for limiting Form input fields, like textarea and input of type text. You have to call it via onkeyup and onkeydown events. The function accepts 3 parameters: field, limit and counterDesired.
The first is the field object, you should use the keyword this for a value.
The second parameter is a limit value, the number of characters that the field should contain at maximum.
The third parameter is optional, false as default. It permits to add a visual counter after the field, like the one you see on YouTube, for example. You can either tell to the function to add the counter for you (put inside a <span> block) or to put it inside another block you've already defined. In the second case, the block must have an id of the form 'fieldID_counter'

This is the compact version, see below for some examples and the expanded, explained version:

<script type="text/javascript">
// < ![CDATA[
function limit_text(field, limit, counterDesired) {
    if (counterDesired == null)
        counterDesired = false;
    var length = $F(field).length;
    if (length > limit)
        $(field).value = $(field).value.substring(0, limit);
    if (counterDesired) {
        if ($($(field).id + '_counter')) {
            $($(field).id + '_counter').update($F(field).length + " / " + limit);
        } else {
            var counterText = new Element('span', {'id': $(field).id + '_counter'});
            counterText.update($F(field).length + " / " + limit);
            $(field).insert({'after': counterText});
        }
    }
}
// ]]>
</script>
 

(more...)

  • Share/Save/Bookmark

Fedora 10, thank you very much! (macbook review and fixes)

Saturday, November 29th, 2008

I've never been a big fan of rpm-based Gnu/Linux distributions, since I've always preferred the stability of Debian and Debian based distros, with their great dpkg system.
The problem with Debian on Macbooks is that I do not see both the stability and performance anymore, as I have to use Lenny/Sid. Etch is too old and I don't have the time (*sic*) to play with it to make it work well. Lenny should be next to be released but I don't feel the very famous stability AND lightness of Debian distributions on this release, like I was accustomed in the past years. Is this because I own a Macbook? Maybe, but a Macbook Santa Rosa is nothing more than an Intel-powered notebook with some strange input devices and a strange non-bios system :-)

Regarding Ubuntu, I believe that this distribution has become naff and really slow. See this Slashdot discussion on this topic.

Yesterday I stumbled to Scientechie review of Fedora 10, which convinced me to try it out.
The software shipped with Fedora 10 is aligned with the one provided with the other distributions: Gnome 2.24.0, kernel 2.6.27.5, NetworkManager 0.7.0 (svn) and so on. Read the release notes for more information.

Fedora 10 really surprises me, as it is the first Gnu/Linux distribution in many, many years that makes me feel again the great stability and performance of the Penguin. Therefore I'm writing this review that is also a how-to, as it contains some fixes for Fedora 10 and Macbooks.

(more...)

  • Share/Save/Bookmark

Testing Ubuntu 8.10 (Intrepid Ibex) beta on a Macbook (updated!)

Friday, October 3rd, 2008

It's a very long time since I abandoned Ubuntu, 1 year and 9 months being precise, although I continued to use Ubuntu derived distros.
I decided today to give Ubuntu 8.10 beta a try. Obviously, every time I decide to try a Gnu/Linux distribution it happens that a new release comes out: I downloaded Alpha 6 yesterday, I fell into problems with it and a apt-get update && apt-get dist-upgrade brought me Ubuntu 8.10 beta, correcting some of them :-)
(more...)

  • Share/Save/Bookmark

Announcing BD-incollo Project

Wednesday, September 24th, 2008

As I promised, I would like to announce the start of a new BD-thing! I'm currently learning Django because of job needing and because of fun. The best way to learn a new language (even if a framework) is to apply it for solving a problem.
That's why I decided to start BD-incollo!
BD-incollo will be a kind of pastebin clone written in Django. Totally free. Free meant as free software. You may download the sourcecode and use it by your own.
Ok, what's difficult with this? I'm planning to release a decent usable version in less than a week.
This means, I want to release the sourcecode on Sunday, 2008-09-28 and also to launch the service on Monday, 2008-09-29.

I believe in Django and I know it will be possible to make it!

  • Share/Save/Bookmark

BD-shell 1.0.0 RC2 is out! Processes in background are dangerous

Saturday, September 13th, 2008

Release Candidate 2 for my C shell is out. This is a real release candidate, code is frozen and hopefully this one does not have serious bugs like RC1. As you may know, RC1 has been retired because of a bug causing a segmentation fault when launching short commands in background. Let's see why this happened. The following schema summarizes what happens when a program in background is launched:

Schema for BD-shell, anatomy of process handling

Schema for BD-shell, anatomy of process handling


As you see, there is a non-synchronous function that is called when the child exits, the SIGCHLD handler.
What if the background command is very short, like ls? It may happen that SIGCHLD is thrown before the job object creation. Bdsh RC1 did not manage this case, and crashed. RC2 fixes this and does not have relevant bugs according to my definition of 1.0.0 release.

Finally, go and grab the code!

  • Share/Save/Bookmark

BD-theme 0.8. The Experiment

Thursday, August 21st, 2008

As I promised more than 2 months ago, I've just released the sourcecode of the wordpress theme on my blog. BD-theme 0.8 is a set of experiments that will bring me to the final release, I cannot promise that it will work perfectly on every browser, but it will almost do the job. Meanwhile, I'm working since 7 days to the next release, 0.9, that should bring to the blog a final layout.
UPDATE 2008-08-22: The theme you're actually seeing in the blog is what will become BD-theme 0.9. I'm testing it.

  • Share/Save/Bookmark