Saturday 10 September 2016

Execute Commands at a Specific Time in Linux-"at"

The other day I was reading about Reliance Jio Offers. Most of their plans come with limited data, but during night times you get unlimited usage. The catch is that night time period is only three hours 2:00 am to 5:00 am.

Unless you are either nocturnal animal like an owl, or a bi-phasic / polyphasic sleeper this implies that you cannot use the unlimited night time benefit. While this might be the case for an average user but for expert users(people who read my blog :-P) this is no problem.

Guess what Linux offers multiple ways to solve this problem

  1. Cron : Read about this yourself. I will not be covering this in the current article. This is more suitable for recurring jobs.
  2. At: The at command this is more suitable for one time jobs. This will be covered in this article.
Android also offers this facility. You might need to have root access for this though. I have covered this in one of earlier articles about Tasker.

Ps: I have no knowledge about IOS, Windows , or Mac platform pertaining to this automation issue. So go figure it out yourselves, in case you are using one of these platforms, leave a comment below explaining how you did it. And I will create a new post for the same.

Wednesday 7 September 2016

Identify Mobile Operating System using Python and ADB


Q:Write a Python/Java/C+ program to verify the operating system name and version of Mobile devices.


Note: This program will only work for android devices. (Since Iphones do not have anything equivalent to adb. )No wonder android is the favorite platform when it comes to app development. Android market is also more developer friendly as compared to its ios counterpart.

Errors: In case you get an error about insufficient permission, either edit udev rules or borrow a phone from your friend, having a well known global manufacturer.

OS:Fedora 20 64 bit
Phone: Sony Xperia
Language: Python
Dependencies: Just adb package,No need for sdk
fedora:               <yum install adb>
ubuntu:              <apt-get install adb>

Friday 2 September 2016

Common Logical Errors in C and C++

Today I spent over two hours discovering this stupid mistake in my code.
a=a++;
Thus I came up with the idea to make a cheat-sheet for common programing mistakes. I hope this is useful to you during your practical exams preparations, debugging times and coding competitions. In case, I have not mentioned one of the mistakes that you make just leave a comment and I will add it.

Thursday 1 September 2016

Mondo DB with Java for processing Images


Q:Use MongoDB to process semi structured and unstructured data collections such as Rfid, images, blogs use python/Java MongoDB interface.

Testing Environment


Mongo DB version : 2.6.3
Network : switched LAN(Ethernet)
IDE: Eclipse (Java EE)
OS: Fedora 20 (64 bit )

Finding primes in a range of numbers

The fastest way(yet easy to understand and implement) to test a prime number is Rabin-Miller Prime Test. However, it suffers from two issues:
  • It is suitable for a single number
  • It may give false positives
When it comes to finding primes from 1 to say 10^6. This method is not suitable. Since this method doesn't use any previously generated information. So the program will end up testing each number.

Sieve Algorithm on the other hand, uses previously generated results and works faster when determining the primes in a range.

Here is a code snippet for the same