Misc

A Cool Join Us Page

Few days back, I was reading the book ‘Scope and Closures‘. I wanted to try an example in the page. I am used to running JS in Chrome developer console. My Chrome had Pinterest opened in it. When I opened the developer console, I found this message

♥ web? –> joinUs()

I got the clue, and ran joinUs() in the console. It redirected me to their careers page. That was an interesting way to attract developers to your startup.

Standard
Misc

Interview Questions

These are a list of few interview questions I was asked during different occasions.
  1. What is the difference between interface and abstract class?
  2. How to create a Java class which can have only one object?
  3. Is it possible to access the cookie of any other domain?
  4. Is there any restriction in number of connections from a single web page?
  5. What is a kernel?
  6. What are thread-safe methods?
  7. What is deadlock and when does one arrive?
  8. Explain Pigeon hole principal.
  9. Given n integers of size 8-bits, write a program to find the minimum difference between them.
  10. Given a binary tree with values in its nodes, write a program to sum the values of nodes within height k.
  11. How to use grep command to search files which contains the string ‘cat’ in its file name?
  12. What is the purpose of explain command in MySql?
  13. Is it possible to start a new Activity using Intents during start-up?
  14. What is the service used to load other services during booting of the Android device?
  15. What is the algorithm behind Java’s GC?
  16. Why is HTTP stateless?
  17. How do you implement chaining of methods as in jQuery?
Standard
Android

Using SSH from Android

SSH is a protocol used to run commands securely in a remote machine. In my dissertation I needed to invoke latex commands in a remote machine the user mentions from an Android app. I explain the steps below to connect to a remote machine through SSH from an Android app. We will be using SSHJ API to do this. SSHJ is an open source Java implementation of the SSH protocol.

The steps involved in using the SSH protocol are as follows

  1. Include the library files in the build path.
    • Download the latest version of the SSHJ library from https://github.com/shikhar/sshj/downloads
    • Extract the zip file and copy the “sshj-0.8.1.jar” into the libs directory of your android project.
    • Include the dependencies of the SSHJ library also in the build path.
      • SLF4J – logging library. (slf4j-api-1.6.99.jar, slf4j-simple-1.6.99.jar)
      • Bounty Castle – Security library. (bcpkix-jdk15on-147.jar, bcprov-jdk15on-147.jar)
      • JZlib – Compression library. ()
    • Include the above mentioned jar files also into the lib folder of the Android project.
  2. To use username and password authentication use a NullHostKeyVerifier like the below one.
import java.security.PublicKey;

import net.schmizz.sshj.transport.verification.HostKeyVerifier;

public class NullHostKeyVerifier implements HostKeyVerifier {

/*
* This method is used to bypass HostKeyVerification.
* It returns true for whatever the input is.
*
*/
@Override
public boolean verify(String arg0, int arg1, PublicKey arg2) {
return true;
}
}
  1. Then use the below code to connect to a remote machine and to execute a command in a remote machine and to get the output of the command in the remote machine.
// creates new SSH client
final SSHClient ssh = new SSHClient(new AndroidConfig());
Command cmd = null;

// Adds a nullHostKeyVerifier
ssh.addHostKeyVerifier(new NullHostKeyVerifier());

// default port number
int pn = 22;

// connect to the machine
try {
ssh.connect(ipaddress, pn);
} catch (IOException e) {
Log.e(TAG, e.getMessage(), e);
}

// Authenticate with the password entered
ssh.authPassword(username, password);

// start a new session
final Session session = ssh.startSession();

// runs the commands in the remote machine
cmd = session.exec("ls");

// reads the output of the command
result = IOUtils.readFully(cmd.getInputStream()).toString();

I have excluded the try catch from the code.
Note: Line number 2 is the difference in using the code from a Java application and from the Android application.

Enhanced by Zemanta
Standard
Misc

FOSS vs Open Source

When I was preparing to move to England to do my higher studies, I googled for the local user communities and joined the Leicester Linux User Group. There were a lot of interesting discussions going on there. One particular day there was a mail saying “Richard Stallman”, the so called “Father of Open Source” was visiting Leicester to give a speech in De-Mont Fort Univeristy.

 

I was so interested in it. I along with my another friend were in the hall much before Richard visited the hall. Richard was a simple man with a different ideology. He spoke about FOSS movement and how it differed from Open Source movement of Linus Torvaldus. That was the first time I ever knew there was a difference between the both movements.

Richard started his speech by mentioning that not to post photos and videos of the sessions in Facebook. He said tagging peoples photos can be used as a way of surveillance. Found it true. So what I did. Deleted all the photos I uploaded on facebook. He asked whatever content of the session that is to be published in the internet must be creative commons attributed. Then he started preaching his philosophy about Free and Open Source Software movement.

 

Richard Stallman

Richard Stallman

From what Richard mentioned I would make that Linus and Open Source movement guys are more pragmatic and Richard is more philosophical. Richard was against using the closed source NVidia driver in Ubuntu, whereas Linus or Open Source movement is open to use closed source applications as a part of the application.

Richard then spoke how iPod and Kindle doesn’t allow users to use the devices with freedom. I was able to get his point when I tried to sync music into my newly bought iPod from my Ubuntu box. It seriously sucks.

At the end of the session, he started speaking about Emacs. Which I didn’t even understand a bit. I rarely use emacs and never knew what he was saying about.

At the question session someone asked him about Google. He said he enjoys few products of the Google and hates few products for its privacy policy.

At the end of the session he gave away few stickers and I left the hall with a different perspective of Open Source and the FOSS philosophy.

I should thank the Leicester LUG and the De-Mont Fort guys. The session was awesome.

Enhanced by Zemanta
Standard
Misc

How I translated Wallch to Tamil

Wallch is a Ubuntu app which allows your desktop wallpaper to change automatically.

There was an invitation to translate it into any language of your choice here 

I just wanted to give a shot. So translated the app into Tamil and have mailed the developers and am waiting for a reply.

It’s simple to translate any app into other languages if planned well. This app uses Qt linguist to translate the app. I used google translate from English to Tamil.

Enhanced by Zemanta
Standard
Misc

Chennai Bus Routes

Few weeks back, I started learning Android programming. My MSc dissertation is to develop an Android app for Latex. I don’t know much Android programming. So I started exploring it. Randomly I came across Phonegap. When I was exploring it a bit I felt it would be easy to convert an existing webapp into android native app with phonegap. To try that I took an existing website BusRoutes.in

 

I worked on the app for 3 days and the end product is here. I used Phonegap and Jquery Mobile. The major issue I feel with the app is it takes much time to load the auto-complete. I have also released the code in github.

Chennai Bus Routes

Chennai Bus Routes

So by the end of three days I fulfilled one of my long desires to host an app in Android market. Did it at last. It is as of now used by more than 100+ users.

App statistics

App statistics

I will be working to add more features when I get some free time.

You can get the app from this link


Get it on Google Play

 Please leave as comments if you need any more features.

 

Enhanced by Zemanta
Standard