Power of Scroll Wheel

If the scroll wheel of the mouse was to be connected to a dynamo, i guess the we would have enough electricity to power space exploration for at least a decade 😛

On a more serious note, what if the scroll wheel could really recharge wireless mice (plural of mouse)? Wouldn’t that be awesome?

Getting nginx with PHP and MySQL

I managed to install nginx on my laptop. Apache used to eat a lots of my precious RAM previously. My laptop got a mere 3GB of it :-/. I hope nginx would make Web Development much more pleasing as well as allowing my laptop to do other stuffs as well.

Installing nginx is not as straight forward as installing the famous LAMP (Linux, Apache, MySQL and PHP). It requires quite some file configuration ninja skills. Following the tutorial found here.

It was kinda tricky to config the config file ‘/etc/nginx/sites-available/default’.

I was un-commenting everything in the curly braces after ‘location ~ \.php$’ like a dummy. nginx would fail to start. After doing

$ nginx -t

It told me:-
nginx: [emerg] “fastcgi_pass” directive is duplicate in /etc/nginx/sites-enabled/default:61
nginx: configuration file /etc/nginx/nginx.conf test failed

After scanning the file and showing some attention to what was going on, i noticed that i was supposed to un-comment only part for ‘With php5-fpm’ so as it appears like this


location ~ \.php$ {
# fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}

I was feeling too lazy to install phpMyAdmin for database administration. Thought of why not using the command line.

$ mysql -p

The mysql terminal opened.

CREATE DATABASE mybb;

And it worked. I could install the beta version of MyBB Forum software 1.8 😉

Control Raspberry Pi’s GPIO with REST (Qt, WebIOPi)

Abstract

To control the GPIO pins of my raspberry pi, I am using WebIOPi framework. You can thus have a web page to remotely control the GPIO from a laptop, mobile phone or anything web capable on ‘http://192.168.1.x:8000’ where x is the Raspberry Pi on your LAN. You get an interface like this:

snapshot10
But if you want to create a real application to control the GPIO, you gotta need some API.

WebIOPi REST API learnt from bash

WebIOPi provides a REST API. Here’s the API reference: https://code.google.com/p/webiopi/wiki/RESTAPI
I’m assuming you have already installed WebIOPi on your Raspberry Pi and the daemon is running.

1.Install curl on my laptop.
$ sudo apt-get install curl

2. Testing a few commands to see if work. (-u username:password)
2.1 Making GPIO 4 as OUT

HTTP GET /GPIO/(gpioNumber)/function
Returns “in” or “out”

$ curl -v -X POST -u webiopi:raspberry http://192.168.1.x:8000/GPIO/4/function/out

The web interface displays the change automatically.

snapshot11
2.2 Outputting voltage on GPIO 4

HTTP POST /GPIO/(gpioNumber)/value/(0 or 1)
Returns new value : 0 or 1

$ curl -v -X POST -u webiopi:raspberry http://192.168.1.x:8000/GPIO/4/value/1

snapshot12
However, including the above commands in your custom application as a system call is not so desirable because it needs curl to be installed on the target machine and has to be Linux/UNIX type.To make cross-platform apps which run on Linux, Windows and Android, I use Qt Framework.

Qt

To create the above call in Qt C++, it is done like this:

#include<QDebug>

#include<QNetworkAccessManager>
#include<QUrl>
#include<QNetworkRequest>
#include<QNetworkReply>

int main(int argc, char *argv[])
{
int no = 4; // GPIO number
int value = 1; // 1 or 0 for On and Off
   QNetworkAccessManager*manager=newQNetworkAccessManager(this);

   QUrl url("http://192.168.1.6:8000/GPIO/"+QString::number(no)
+"/value/"+QString::number(value));
   url.setUserName("webiopi");
   url.setPassword("raspberry");
   QNetworkReply *reply = manager->post(QNetworkRequest(url),"");
   qDebug() << reply->readAll();
}

You just need to change the URL each time for different functions ;)

Next, i’m gonna create a UI in QML to control the GPIO so as to be able to be used to make a remote controlled car. Stay tuned 🙂

Porn to be blocked by Mauritian Government?

According to some newspaper articles and blog posts [1], the government is planning to block porn websites. They say it is for the “security” of the population. They say such websites contain malware which can infect PCs. This blog post is not about whether porn is good or bad. It is about the government blocking websites of the so-called ´free´ Internet.

If the government can block porn websites today, it would be able to block any other website in the future which doesn’t support its propaganda and gets flagged as “negative websites”

Examples can be the “opposition” website, free press and later, maybe, even Facebook or Twitter.
Why not? Some countries do it already.

Ok. How do you think this law will be put the constitution?

1. The government will block access to pornography websites which poses as a security threat to the population.

Or

2. The government may block access to websites which poses as a security threat to the population such as pornography websites…

These two statements above may look the same to some people. But it is not. Read then again. They’re doing different things.

The discussion on porn can be a mere distraction. Parents, religious people would support the government the decision. But something else could be done at the end.

Conclusion

Everyone knows porn websites are “risky”. We don’t dictatorship methods to be tested on us.

GNOME 3.12

KDE 4.13 is powerful as hell. But it is just a generic or classic desktop that awaits for the user to customise it. GNOME on the other hand aims to provide the user with a workspace. A delightful experience!

GNOME is based on the GTK+ toolkit which i believe not to be the on bleeding edge of technology as Qt actually is with it’s innovating QML technology.

GNOME, says to me:

Hi you there, welcome! Let me hold your hand and walk you around. You want to hear some music? You want to start working? Just type in your command and i’ll do it for you 🙂

Here’s how the menu or dashboard looks like. Type any program or recently used files here:

snapshot5

Vertical space is very precious in modern 16/10 screens. GNOME knows that very well. It takes minimal amount of your screen and allows you to focus on what you have to do. Let’s compare reading a PDF in KDE 4.13 and GNOME 3.12

Reading PDF on Okular (KDE)

————–

Reading PDF on Document Viewer (GNOME)

Saw the difference is readable space?

GNOME is dedicated to offer you an experience as stated before. You’re listening to music while working. You press the next button on your keyboard, a non-intrusive notification appears at the bottom of the screen which disappears by itself after few seconds.

Screenshot from 2014-04-29 21:13:06

If you want to know more about the song, just put your cursor over it, it expands revealing more controls.

Screenshot from 2014-04-29 21:13:12

Click on it, the full music app shows up. Genius! Choose the song you want then close it. Continue working as if nothing happened.

rythmbox

Conclusion

Despite KDE apps like Dolphin, Okular and all have much much more feature and are more powerful, using GNOME apps at first seems such a great experience 🙂

In an ideal world,i’d like GNOME to be written with Qt Framework and QML. Or GNOME ‘Human Interaction’ team to take over KDE Plasma and make KDE rule the world. Or just forking existing KDE apps into GNOME. Do try GNOME 3.12 😀