Friday, March 30, 2012

Thoughts on LAMP Development(Linux Apache MySQL PHP)

It's about two years since I started on the whole LAMP thing.  Well the circumstances were like this - I was working on a Linux based product and we wanted to develop a data collection software. Now the problem was we wanted a solution that was quick to develop. So we decided on developing a web application instead of desktop application. So we went forward and used LAMP to develop it and we were satisfied with the speed of development. A desktop application in C-GTK or Java would have taken lots of time and the team didn't have any significant expertise in both of them. Although we were fine with html and we got along with PHP just fine. The main part was easily accessible documentation and the ease of coding.

So we developed a solution that was basically a bunch of HTML forms with some PHP thrown in so that we could push the data to a MySQL database as well as call some other programs to perform some tasks using Shell Scripts. It wasn't an elegant solution but it got the work done. It also got PHP added to my profile.

Later I got to work on a few more projects concerning web development. And my expertise with PHP grew. But later I came to know that we can do just as much with PHP. For more functionality I need to use JavaScript. So I researched about various JavaScript libraries and finally settled on JQuery. That meant I need to learn what JQuery is and what it offers and how. So I grabbed a nice looking book by the title "JQuery Ninja" and after a month and a small project later I was pretty good with things.

JQuery allowed me to do many things that were not possible with PHP as well as some things that were not as much user friendly when done with plain HTML. Especially the AJAX functionality provided by JQuery become a necessity to me. It also helped me code complex pages with unprecedented ease. Remember till now I'm not anywhere near websites. What I'm working on are web applications where functionality matters most and looks are secondary. But then I got the opportunity to work on couple of websites and that changed the game altogether.

As with any website the focus is on looks and then the functionality. Often the goal is to combine looks and usability together to provide best experience. So I was burdened with even more work for making the thing look better. Sure having access to JQuery's UI functions and effects helps a bit, but I needed to tackle the theming problem and so I dug deeper into the world of web designing - how to theme a Web page, how to combine various elements with CSS to make it an awesome experience. Unfortunately I don't have any gifts with colors and pictures so I couldn't go as far as I would have liked. That sucks but then a Jack of all trades can handle just so many trades! :D

Well, I have come a long way when it comes to bare PHP development. Perhaps it's time for me to try a few frameworks. But they all seem so bloated to me since I have worked on bare PHP for so long. Hope some project comes along that makes me use some framework! Because I don't think otherwise I will be touching any!

p.s. I have tangled with Wordpress and Drupal. They both seem nice. Let's see if I can dig something that would actually need all their functionality!

Tuesday, March 13, 2012

On Kubuntu 12.04 Beta 1 [* UPDATED]


*** It's been some time since I installed Kubuntu 12.04 Beta 1 and I have been using it exclusively since. And much to my surprise I find myself using it more and more. There are many small improvements that you catch on only after some serious exploration. And until now I'm not feeling hopeless about kubuntu. So perhaps with this revision I can say that finally KDE has become enough usable that it doesn't push me away.
In it's own, this KDE is vast improvement to what I tested the last time - almost two years - and the snappy performance is really a pleasure. Now if I don't see those application crashes less often, I would move to this as my primary distro.
( I have seen only handful application/ system crashes on my current Ubuntu 10.10 Installation that is my primary OS. )

Review System:
Emachines E-727 with Pentium D 2.3GHz; 3GB RAM; 250GB HDD; Atheros WLAN; Intel Integrated Graphics 4500mHD.

I am one of those many who want to shift to Arch Linux but don't have the time and patience to get through a proper installation and the tinkering that's needed while setting up an Arch Linux installation. So I'm on the lookout for something else that won't break my neck while trying to figure things out.

It was a long time since I had my last trifle with Ubuntu's much less enamoured cousin Kubuntu. Just a few days ago I saw an announcement on Planet Ubuntu that beta 1 for the whole family is out. So I went ahead and downloaded Kubuntu 12.04 and installed it in virtual box.

The installation went without a hitch and just within 15 Minutes I was installing my favourite software. As I wanted to preview the stuff I just installed VLC and remastersys and few other tools and rolled a Custom ISO. Then was the testing time and trying to feel my way around the system.

Well, one thing I have to say - the system is faster. The installation was much faster than before - 10.10 was the last version that I tried my hands at. The system's idle Ram Usage was also lower at around 300MB; while back then it used to reach 400MB easily. I disabled the effects and nepomuk and strigi and few more services ad the RAM usage was down to 250MB which is very respectable. The Desktop remains almost unchanged although it feels slightly more responsive and applications are bit more responsive.

The Dev's have spent some quality time in Activities; but as I am not a hardcore user I skipped them altogether. Applications wise Ocular was way faster than before. I didn't like Amarok and still doesn't like it. The interface is a bloat and even after spending about an hour on it I couldn't get it look any better or easier to use. Well, I needed some alternative here. I like Clementine so I marked it down for installation. Same went with Dragon Player; it's not as ugly but still it can't match the simplicity of Totem. Anyway I was replacing it with VLC so that's not a problem.

Another problem is Midori; it's just not upto the task. I used it for a browsing session of an hour and it crashed thrice. Thankfully they have provided Firefox Installer.

On Office front, latest LibreOffice helps and it's getting better with every revision. No grudges here! :D
I am not an online junkie (was actually; alas, no more! ) so I didn't use KOpete and stuff. The included game of KPatience is good for some pastime.

I didn't like the notifications and the hardware indicator popping out every time I plugged in something. Closing these pesky messages is a super pain in the backside. So I disabled them from the System Tray. The Desktops were not much problem - there were two provided and I needed to look up the keyboard shortcuts for them. I wish the keyboard shortcuts would be same between different desktops for same tasks. But nevertheless they get the job done.

The system settings are as usual full of many configurable options and I still feel like KDE should cut these. Also the design of the dialogues can be cleaner. They still feel crowded with things, many of whom are hardly used. Although the System Settings cover a vast area and I think there's only a few things that are missing here but still better them not added here to make an even greater mess.

I didn't have much issue on system stability; only a few of the apps crashed and that didn't even make the system feel any slower. Kubuntu just chugged along happily and for that I have to give credit to the KDE Devs and Kubuntu team for their efforts.

Now the only thing I want is a decent working theme that doesn't look as uninspiring as the current silver-gray. The black theme for desktop looks great; I just hope we get it for the whole system.

Well, later I went back to Virtual Box; removed the stuff I didn't want and installed the stuff I wanted. After getting a custom ISO done using remastersys I installed it to the above mentioned hardware and the system performed as expected. So I think I can use it as my Backup Distro while I decide between going Ubuntu Unity/ Anything else with Gnome 3/ Linux Mint with MGSE.

Monday, March 12, 2012

[QT] CREATE AN ODT FILE



/*
 **************     CREATING A ODT FILE              ****************
 **************     INCLUDE THE NECESSARY FILES     ********/
{
    ...
    // Text Document Object to hold formatted document
    QTextDocument *m_document = new QTextDocument();

    // Cursor for traversing the document
    QTextCursor m_cursor = QTextCursor(m_document);

    // TextTableFormat object for table formatting
    QTextTableFormat tableFormat;
    tableFormat.setAlignment(Qt::AlignCenter);
    tableFormat.setCellPadding(5);
    tableFormat.setCellSpacing(50);
    tableFormat.setHeaderRowCount(0);
    tableFormat.setBorderStyle( QTextFrameFormat::BorderStyle_Solid);
    tableFormat.setWidth(QTextLength(QTextLength::PercentageLength, 60));

    // Create table to hold the text and it's easy to format

    QTextTable *m_table= m_cursor.insertTable(10,3,tableFormat);
    m_table->mergeCells(0,0,1,2);
    m_table->mergeCells(1,0,1,2);

    //Lets Insert the text and Pictures
    m_cursor.insertText(QObject::tr("Welcome to Point Element\n"));

    m_cursor.movePosition(QTextCursor::NextRow);

    // Insert Photo
    QImage photo("/home/user/myphoto.jpg");
    photo =photo.scaledToHeight(300,Qt::SmoothTransformation);
    photo =photo.scaledToWidth(100,Qt::SmoothTransformation);
    m_cursor.insertImage(photo,"Photo");
    m_cursor.movePosition(QTextCursor::NextRow);

    m_cursor.insertText(QObject::tr("User Name:"));
    m_cursor.movePosition(QTextCursor::NextCell);
    m_cursor.insertText(QObject::tr(ui->LE_name->text().toAscii()));
    //m_cursor.insertText(QObject::tr("Anay"));
    m_cursor.movePosition(QTextCursor::NextRow);
    m_cursor.insertText(QObject::tr("Age:"));
    m_cursor.movePosition(QTextCursor::NextCell);
    m_cursor.insertText(QObject::tr(ui->LE_age->text().toAscii()));
    //m_cursor.insertText(QObject::tr("45"));
    m_cursor.movePosition(QTextCursor::NextRow);
    m_cursor.insertText(QObject::tr("Gender:"));
    m_cursor.movePosition(QTextCursor::NextCell);
    m_cursor.insertText(QObject::tr(ui->CMB_gender->currentText().toAscii()));
    //m_cursor.insertText(QObject::tr("MALE:"));
    m_cursor.movePosition(QTextCursor::NextRow);
    m_cursor.insertText(QObject::tr("Employer Name:"));
    m_cursor.movePosition(QTextCursor::NextCell);
    m_cursor.insertText(QObject::tr(ui->LE_cname->text().toAscii()));
    //m_cursor.insertText(QObject::tr("Aniket"));

    //Leave 3-4 empty lines and then add signature
    m_cursor.movePosition(QTextCursor::NextRow,QTextCursor::MoveAnchor, 4);

    m_cursor.insertText(QObject::tr("Sign"));
    m_cursor.movePosition(QTextCursor::NextCell);
    m_cursor.insertText(QObject::tr("___________________________"));

    // FILE NAME
    QString docfilename = ui->LE_name->text();
    docfilename.append(".odt");
    docfilename.prepend("/home/user/");

    // Write the Document to the file on Disk
    QTextDocumentWriter writer;
    writer.setFormat("odf");
    writer.setFileName(docfilename.toAscii());
    writer.write(m_document);

/************************   DONE   ****************************/

}

Wednesday, March 7, 2012

Painting, odt and pdf

Recently I had the pleasure to get my hands dirty with Qt. Basically I wanted to print some stuff and get the application working in couple of days. (Yeah, you know how things are usually - we want it now, we don't care if this is eleventh hour or not! - and then the part you are messing with is usually something nobody has tried to do before and see if it's actually doable or just a godly proclamation).
Anyway, I got started, got a form and validated the input and somehow found out some code to write it to an  odt file too. Now here comes the dealbreaker - we want it to be formatted just so and so, and we (again) don't care which hour it is! Right, so I use our dear friend, beholder of finding obscure things from the haystack called Internet i.e. google and after some (furious) searching found out that what I am trying to do is not done before and there's couple of percent chance that I may be able to do it. I like any chance than zero percent so I dug in my heels and dived deeper. A few frustrated hours later I was back at the document with no formatting, almost all links in google exhausted, and cursing Qt's stuffed up support of handling ODF and the general lack of quality tutorials.
I am not one to leave it at that though, so I said fine, can they have pdf and use it, and the answer was yes. So once again I went through all the above paragraph and finally ended up getting a pdf ready. It was not without pains though. I had to mess up the layout by manually adjusting things and then there was the file redirection where the function to disable immediate printing was missing. I had to set printer name to something invalid so that the app would just put things inside the pdf. And last but not least I was stuck for two and half hours at the printer object problem where it had to be initialised at start but then I had an idea about using a pointer for that and it was solved. And so after some further tweaking, I had the application ready.
Testing it was another hell though, and I don't want to depress you more about the often looked over dark parts of everyday software.