Archive for May, 2010

Add Tweet with C++/Qt4

Tuesday, May 25th, 2010

Qt logoThis is a code from my Twitter client for how to send a Http request from C++/Qt4 to add your status message…

It used the QNetworkAccessManager class instead of the deprecated QHttp.

#include <QtCore>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>

void main(int argc, char ** argv)
{
    QString unescaped = "<My status update!>";
    QString data = "status=" + QUrl::toPercentEncoding(unescaped.toLatin1());
    QString auth = "<Username>" + ":" + "<Password>";
    QString encryptedAuth = auth.toAscii().toBase64();
    QNetworkAccessManager* manager = new QNetworkAccessManager(this);
    QNetworkRequest request;
    QNetworkReply *reply;
    request.setUrl(QUrl("http://twitter.com/statuses/update.xml"));
    request.setRawHeader(QByteArray("Host"), "twitter.com");
    request.setRawHeader(QByteArray("Content-Type"), "application/x-www-form-urlencoded");
    request.setRawHeader(QByteArray("User-Agent"), "Mozilla");
    request.setRawHeader(QByteArray("Authorization"), "Basic " + encryptedAuth.toAscii());
    QByteArray postData(data.toLatin1(), data.length());
    reply = manager->post(request, postData);
}

Google Showing off HTML5

Friday, May 21st, 2010

Today I opened my favorite web browser Chrome and then suddently I heard the Pac-man theme melody and there it was, a pac-man game as the Google logo written in HTML5 to celebrate Pacman’s 30th birthday. I also noticed a nice virtuel keypad as shown in the screenshot down the page, but only in the Norwegian google site (google.no).

I guess this is to show the world the power of HTML5 and that the developement are highly in progress :)

googlepacman

Hit insert coin, and you will get Ms. Pac-man which you control with the asdf buttons :)

Free Up Some Ubuntu Space!

Wednesday, May 19th, 2010

cleaning up ubuntuHaving trouble cleaning up space for your Ubuntu installation?
I only have a 4GB SSD drive on my Lenovo S10e netbook, so I have the problem myself. Here are some handy tips for you!

Remove files not needed

sudo apt-get autoremove

Remove all stored archives in the cache

Basically it clears up the ‘/var/cache/apt/archives/’ and ‘/var/cache/apt/archives/partial’ folders

sudo apt-get clean

Remove package files that can no longer be downloaded

sudo apt-get autoclean

Remove locale data

This will remove unneeded locale files and localized man pages.

sudo apt-get install localepurge

Run it:

localepurge

A window will pop up. There choose your language. I use English, therefor I chose “en”.
Ignore the capitalized ones.

Remove orphaned packages

It shows you which packages that have no other packages depending on them.

sudo apt-get install deborphan

Run it:

sudo deborphan | xargs sudo apt-get -y remove --purge

Cleaning up log files

sudo find /var/log -type f -exec rm {} \;

Cleaning up doc files (use only when desperate use of space)

sudo rm -rf /usr/share/doc/*

Remove Linux kernels not in use

Check what kernel you are using:

uname -r

Goto System->Administration->Synaptic Package Manager

Search for “Linux” and mark all Linux header/kernel files which you are not currently using for complete removal. Then hit ‘apply’.

Not Enough Space to Upgrade Ubuntu

Wednesday, May 19th, 2010

I have just a small 4GB SSD drive with my Ubuntu installation on it, and when I was going to upgrade to Ubuntu 10.04 (Lucid), I had to free up some space. Instead of removing all programs that I had installed, I googled and found something neat.
Ubuntu logo
New packages are downloaded to ‘/var/cache/apt/archives’ and by creating a link to another place with more space you will “trick” the upgrader.

I have also a 150GB drive which I have my home folder located in, so I created a folder there to take the heavy upgrading.

sudo su
cd /var/cache/apt
mv archives archives-original
mkdir -p archives/partial
mkdir -p /home/<username>/temp/archives
ln -s /home/<username>/temp archives
upgrade-manager

Restore to default:

rm archives
mv archives-original archives
rm -r /home/<username>/temp

Source:
http://www.webupd8.org/2009/11/how-to-upgrade-to-ubuntu-1004-lucid.html