The Android SDK Manager fails to fetch the platform and tools list from Google

If you get the following error message when launching the Android SDK Manager:

Failed to fetch URL https://dl.google.com/android/repository/addons_list-2.xml, reason: File not found

most likely the owner/permissions are not set correctly for the ~/.android directory.

This error message is very confusing and it took me while to find the issue.

In my case the owner of this directory and all the files and directories in it was root.

There are numerous “solutions” given to this in many forums. Most of them recommend launching Android Studio as root. That is definitely the wrong approach. It will get rid of the error, since you will no longer be faced with permissions issues, but running Android Studio as root is a vary bad idea.

Instead, you should change the owner of the ~/.android directory to your user id.

So, find the .android directory (most likely it is in your home directory). Then change the ownership recursively to your user:


cd ~
sudo chown -R myuser: .android/

You should be now good to go.

Tags: , , ,

Find out what DNS requests are made in real time via command line

Since all DNS requests are over port 53, we can use the raw tcpdump utility and just look at the packets on that port:

tcpdump -vvv -s 0 -l -n port 53

Someone took the extra step to write a php script to massage that data, so that it is easier to read as well as focusing on those queries that either do not resolve or take a long time to resolve:

http://jontai.me/blog/2011/11/monitoring-dns-queries-with-tcpdump/

Tags: , , ,

Tuesday, May 10th, 2016 IT Security, Linux, Networking, Ubuntu No Comments

Android Studio- What files and directories to exclude when importing into Subversion (or Git)

List of directories and files to be excluded when importing into a version control (relative to the root of the project):

.gradle (directory)
build (directory)
local.properties (file)
app/build (directory)
.idea/libraries (directory)
.idea/gradle.xml (file)
.idea/workspace.xml (file)

There are a couple of different ways to have the above directories and files not present in the version control:

1. Exclude them from the initial import
2. Delete them after the import


svn delete -m "Delete .gradle dir" http://server/path/to/repository/.gradle
svn delete -m "Delete build dir" http://server/path/to/repository/build
svn delete -m "Delete app/build dir" http://server/path/to/repository/app/build
svn delete -m "Delete local.properties" http://server/path/to/repository/local.properties
svn delete -m "Delete .idea/libraries dir" http://server/path/to/repository/.idea/libraries
svn delete -m "Delete gradle.xml" http://server/path/to/repository/.idea/gradle.xml
svn delete -m "Delete workspace.xml" http://server/path/to/repository/.idea/workspace.xml

Now that we have gone through that, the version control does not have these directories and files, but locally, the project on your computer has these (if not they will be automatically generated when you first open the project in Android Studio or you build the project).

That means that we need to delete them from svn locally and tell svn locally to ignore them:


svn ps svn:ignore '.gradle local.properties build' .
svn ps svn:ignore build app
svn ps svn:ignore 'libraries gradle.xml workspace.xml' .idea

Tags: , , , ,

Friday, April 22nd, 2016 Android, Android Studio, Java, Programming No Comments

Set up a MySQL user dedicated to backups

It is not a good idea to use the root MySQL account to do backups.

So, let’s create a user dedicated exclusively to doing backups.

Log on to MySQL as root:

mysql -u root -p

Then create the new user and grant it the necessary permissions:


CREATE USER 'backup_user_name'@'localhost' IDENTIFIED BY 'my_pass';
GRANT SELECT, SHOW VIEW, RELOAD, EVENT, TRIGGER, LOCK TABLES ON *.* TO 'backup_user_name'@'localhost';

Now that we are all set up, you can do backups with that new dedicated user:

mysqldump -u backup_user_name -pmy_pass db_name | gzip > /home/ddarazha/backups/ninelets/ninelets_`date '+%Y%m%d'`.sql.gz

Tags: , ,

Tuesday, January 19th, 2016 IT Security, Linux, MySQL, SQL, Ubuntu No Comments

Batch scale images to a particular size

First install imagemagick:

sudo apt-get install imagemagick

Then CD into the directory containing the images and make a new directory that will hold all the re-sized images. In this case I called it resized:

mkdir resized

Then run the command (from the directory holding the original images):

find . -iname \*.jpg -exec convert -verbose -quality 80 -resize 1600x1200 "{}" "resized/{}" \;

The above command will find (recursively) all the jpg files in the current directory and all directories in it, then it will execute the covert command on each image and finally store the scaled image in the resized directory. You can adjust the size parameters, file extensions and target directory as you desire.

Tags: , ,

Thursday, November 19th, 2015 Linux, Ubuntu No Comments

Search

 

Archive

June 2016
M T W T F S S
« May    
 12345
6789101112
13141516171819
20212223242526
27282930  

Other