cURL o Wget?

15 Aug

¿Cómo saber cuál de estas dos herramientas de línea de comandos es mejor?. Dado que cumplen funciones similares, me parece que lo mejor es enumerar algunas de sus características más importantes.

Características comunes
La principal función de ambas es descargar contenido vía protocolos FTP, HTTP y HTTPS utilizando sintaxis de URL.
Ambos están desarrollados con codigo abierto y software libre.
Continue reading

Hyper-V – Recovering VHD’s and AVHD’s

05 Aug

Anybody who has had to deal with a catastrophic recovery process knows the pains involved with retrieving data. In particular cases like mine, I needed to recover data which was locked away in virtual hard disks and in snapshots. I was unable to boot the original o/s for that disk since it was corrupted, only option was mounting each disk in a separate virtual machine and extracting what I could.

I’m not all to familiar with Hyper-V (I use Virtualbox mostly), so it was a “fun” learning experience for me. I found that Hyper-V lets you mount individual snapshots like disks, but you need to have an intact snapshot chain to do so. Also, in the latest version of Hyper-V, your vhd’s and avhd’s can not be in a compressed filesystem.. which sadly, I had to decompress (took many, many hours).

So long story short, If you ever need to switch back to a snapshot, it’s just a matter of switching the mounted hard drive image to the snapshot file. I found that this was very convenient until I dealt with a snapshot that seemed to be corrupted, thus corrupting the whole chain. I could not find any working/free tools out there for avhd recovery. Bunch of data recovery services, but they sound way too expensive. If anyone knows of any reliable tools, please comment.

Html Emails with Zend_Mail and Zend_View

30 Jul

When write web applications, eventually you will need to send emails, Zend Framework have a good implementation that can be used stand alone or as a full framework called Zend_Mail, his usage is very straight forward:

// assuming that you included your Zend_Mail library
 
// instance the class
$mail = new Zend_Mail("utf-8");
 
// add a recipient
$mail->addTo("your_recipient@somemail.com");
 
// mail content as html
$mail->setBodyHtml("<h1>Hello world</h1>");
 
// from email
$mail->setFrom("yourself@somemail.com");
 
// your subject
$mail->setSubject("Say Hello");
 
// send the email
$mail->send();

With the last example You can send mails but will be difficult to provide variables or even use common layouts in the mails, to solve that, you can use html templates like Smarty, or Zend_View, we are going to use the last one.

To use Zend_View as a HTML template, we need to create a instance (and require the library depending of your setup), define your view templates path, assign your variables and your extra configuration (partials, layouts, includes) and finally render the template to be the body of Zend_Mail.

// remember to include your Zend_View Library
 
// instance the class
$html = new Zend_View();
 
// path of your view templates path
$html->setScriptPath('/some/view/path/');
 
// clear all defined variables before, you can avoid this
$html->clearVars();
 
// add a variable
$html->someName = "Edder";
 
// render the template that you already create it
$bodyHtml = $html->render("your-template.phtml");
 
// assuming that you already have the $mail
$html->setBodyHtml($bodyHtml);
 
// send the email
$html->send();

The template used on the last example to be our email body is the following:

<h1>Hello: <?php echo $this->someName ?></h1>

For more information about using Zend_Mail and/or Zend_View refer to the official documentation.

jQuery Dual Listbox

22 Jul

Last week looking for a list box that allows to select multiple items I found a very useful jQuery plugin called Dual Listbox. As the author describes it, it allows us “to have two <select> elements, and be able to easily transfer <option> elements between them…”

This is the list of the features:

Ability to either move items from one list to another or copy items from one list to another
List filtering, including a display of how many items are showing out of the total
Moving a list of selected items from one list to the other with a button.
Moving all items from one list to another with a button.
Moving single items by double-clicking on them.

All you have to do is and give the elements the control ids. After that, a simple javascript statement takes care of everything else.

Here’s a simple example of the HTML:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<div>
    <table>
        <tr>
            <td>
                Filter: <input type="text" id="box1Filter" /><button type="button" id="box1Clear">X</button><br />
                <select id="box1View" multiple="multiple" style="height:300px;width:300px;">
                    <option value="1">item one</option>
                    <option value="2">item two</option>
                    <option value="3">item three</option>
                    <option value="4">item four</option>
                    <option value="5">item five</option>
                </select><br/>
                <span id="box1Counter" class="countLabel"></span>
                <select id="box1Storage">
                </select>
            </td>
            <td>
                <button id="to2" type="button">&nbsp;>&nbsp;</button>
                <button id="allTo2" type="button">&nbsp;>>&nbsp;</button>
                <button id="allTo1" type="button">&nbsp;<<&nbsp;</button>
                <button id="to1" type="button">&nbsp;<&nbsp;</button>
            </td>
            <td>
                Filter: <input type="text" id="box2Filter" /><button type="button" id="box2Clear">X</button><br />
                <select id="box2View" multiple="multiple" style="height:300px;width:300px;">
                </select><br/>
                <span id="box2Counter" class="countLabel"></span>
                <select id="box2Storage">
                </select>
            </td>
        </tr>
    </table>
</div>

and the javascript part could be something like this:

1
2
3
$(document).ready(function(){
    $.configureBoxes();
});

The plugin can be configured by adding a JSON object as the options parameter. The list of the available options is here

You can find a demonstration of the plugin here

For more information please refer to the project’s home page

Acer TimelineX Review

15 Jul

I recently purchased a TimeLineX 5830TG-6402 and I have to say I’m a happy customer.. so far. Here’s a little review based on my experience.

Performance

I deal a lot with virtualization, and I had my doubts about the i5 (2nd gen), but I am running 2 Fedora 15 Linux virtual machines with 1GB RAM and a dedicated core for each and the laptop has no slowness what so ever. We’ll see soon how it reacts when importing massive databases. The host OS is stock Windows Home Premium 64b. I’m using the original 6GB RAM, but I may max it out to 8GB later on. With the two vms running + windows 7 + IDE development tools, I still have about 2GB of RAM free. Another upgrade I might consider is changing the 5400RPM hard drive to a 7200RPM although it’s not a huge priority for me — works fine as is. Haven’t played many games on it yet, but Borderlands seemed to run fairly smooth using all the max settings (will post actual FPS later when I have time to do more benchmarking).

One thing I found remarkable was how cool this laptop runs. GPU peaked around 42C while in Borderlands (with max settings), and runs idle around 38-39C. For contrast, on my PC, I have an ATI 4870 which runs around 60C Idle, and 85-90C in-game (note, my resolution is much higher on PC). Still finding a compatible CPU monitor to read its sensor information — will follow-up with updates later.

Aesthetics / Mobility

The outer shell, keyboard plate and palm rest of the laptop are aluminum, despite what one Amazon reviewer said. It’s a light and mobile laptop considering the size of the screen. The screen is crystal clear and easy on the eyes. Haven’t tried it outside on a sunny day yet.

I will say, that I am a person who appreciates a good keyboard since I spend hours a day typing. This Acer laptop keyboard is almost as nice to type on as my Razer BlackWidow Ultimate Mechanical. Of course, my jumbo BlackWidow is still far superior but it weighs about 6LBs by itself. I’m not a huge fan of laptops with number pads, but it doesn’t take up too much space in this laptop’s key layout.

Overall, I have to say, I’m impressed with the bang I’ve gotten for my $799 bucks and would recommend to people looking for a good laptop for work and play.

That Google Plus, Dropdown

10 Jul

Am checking this Google Plus, awesome stuff! As with anything new I see, I would like to know how it’s made and how it works.
I really like how they took care of drop down boxes, so I set out to see how I would go about making it.
Few things I noticed, they don’t use images for anything other than close button inside of tool-tip. Then they handled scroll-bars very nicely, at least on Chrome. (haven’t checked on FF). Lastly, simplicity and elegance of it.
Continue reading