Posts

Showing posts from February, 2016

How to enable root SSH login in amazon EC2 instance

Image
In amazon EC2 instances, by default SSH login is done using keys. And the root login is disabled for security reasons. But times come when we have to enable remote SSH login as root. My situation came when I was doing xstream installation. I had to enter my root ssh details in their dashboard to initiate the installation.  So, here I am going to show, what I did to enable root login using password in amazon EC2. The steps below were done in Ubuntu 14.04 64-bit. First lets enable login using password, to do this, change the line in /etc/ssh/sshd_config PasswordAuthentication no to PasswordAuthentication yes

How to download a file in Android

Image
Today in this post, I am going to share the code that I use in my android applications to support downloading of file. There are many ways you can use to download a file. For example you can use Async task and read the file stream to save it in device storage, you could also use a Service to download the file. But in my example I will show you the code that uses DownloadManager class.

Image loading in Android

Image
To load an image in android requires you to read the stream into a bitmap and which then can be used to display the image. But this cannot be done in the main UI thread so you will have to use Async task. This requires you to write a lot of code. Besides you have to handle memory and disk caching mechanism. An easy and quick way is to use the Picasso Library. Picasso is a powerful image downloading and caching library for Android. Picasso can be included in your project by adding the following line to your project's gradle file: compile 'com.squareup.picasso:picasso:(latest version)' You can check the available versions at : https://github.com/square/picasso A simple example to load an image into an imageview is : Picasso.with(context) .load("http://i.imgur.com/DvpvklR.png") .into(imageView); It also allows image transformation to better fit into layouts and reduce memory size. An example to do this is : Picasso.with(context) .load("h