Writing Python Scripts on Android Mobile

I found a cool app on Google Play recently, QPython 3 which allows you to write Python scripts and run it under a console on your Android mobile phone. I tried typing using the built in keyboard, but if you’re a coder like me and need to type fast you can still connect a USB or Bluetooth Keyboard to your mobile phone.

wpid-tempFileForShare.jpg

In the console window you can still enter your code and run it on the fly or you can choose to write your script in their text editor called QEdit from the menu.

wpid-tempFileForShare.jpg Console Screen.

wpid-tempFileForShare.jpgQEdit – Text Editor

 

Writing a Simple Linux Daemon Program

I have decided to write a watcher daemon to watch a specified folder for any newly created files or folders. I did some googling and found that it was very simple to create a daemon program in Linux.

First you will need to create your source file and include the following header file:

#include <unistd.h>

In the main function you need to call daemon() like this:

int main()
{
    if (daemon(0,0) == -1)
         err(1, NULL);
    while(1)
    {
         Do something here....
    }
}

In the while loop you can put your own code to perform a specific task. 

To run the daemon when your system boots up edit the file /etc/init.d/rc.local and add the following line at the end of the file:

/usr/sbin/yourdaemon

note: make sure the you copied the file to /usr/sbin or else the file can not be found when the system is booting up.

The daemon function parameters, I have specifice 0 for the first paramter to use the root “/” folder instead of the working folder and the second parameter I have done the same which will redirect all standard input, output and errors to /dev/null.

Detailed information on how to use the daemon function can be found here.

My New Samsung Galaxy S Android Mobile Phone

image

My Optus mobile contract has finished, and it was time to upgrade to a new phone. I was tossing between the Apple iPhone 4 and the Samsung Galaxy S. But I decided to go with Samsung because it has a bigger screen, very sharp graphics, YouTube loading time is faster compare to my Apple iPhone 3G; no restrictions not like the iPhone where you need to jailbreak to run apps that is not available on the Apple Appstore.

I am still going to keep my Apple iPhone for development, and now it’s time to start learn and develop on the Android platform.

Shares