Pundit Sungkur et al. refuse to return our stolen beach.

Last time, they said they’ll do everything to abide by the law [ ref ] despite having violated it at first. But now they are waiting for the law to abide to their plan [ ref ]. They are waiting.

This government is a joke. “Petit copains” can piss on the laws and regulations. Government don’t care. But what they do, install speed cameras that fine the general population Rs 2000 if they go at 80.1 km/h. This is them saying they’re just doing their duty by applying “The Law”!

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.