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) (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" http://server/path/to/repository/
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 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

Upgrading to Apache 2.4 will prevent WebDAV listing of directories containing index files

I recently upgraded Apache from 2.2 to 2.4 and among all the expected changes that had to be made to the existing sites-available config files, I encountered an unexpected issue with the WebDAV sites.

I could connect to the sites via DAV but weirdly enough I could not open some directories with them. I would get a “405 Method Not Allowed error”.

It turns out that if a collection in a WebDAV-enabled area contains an index.html (or whatever filename is specified in DirectoryIndex – index.php, default.html, etc.) then it becomes impossible to use WebDAV methods on that collection. See bug report.

In order to fix this, you need to disable directory indexing for the WebDAV site(s).

If you still want to have directory indexing when serving regular http requests, I recommend having WebDAV configured on a different port.

I normally have development sites, server reqular requests on port 80 and have the WebDAV configured on port 443.

So, in your sites-available/site.conf file, in the corresponding VirtualHost declaration add DirectoryIndex disabled to the Directory declaration, like so:

    <Directory /path/to/my/webdav/dir>
                    Options Indexes FollowSymLinks MultiViews
                    AllowOverride all
                    Require all granted

                    DirectoryIndex disabled

Here is an example config file:

DavLockDB /webdav/DavLock/DavLock

	ServerAdmin webmaster@localhost
	DocumentRoot /var/www/

	Alias /web /path/to/my/webdav/dir

	<Directory /path/to/my/webdav/dir>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride None
		Require all granted



    DocumentRoot /var/www/

	Alias /web /path/to/my/webdav/dir

	<Directory /path/to/my/webdav/dir>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride None
		Require all granted

		DirectoryIndex disabled

	<Location /web>
		DAV On
		AuthType Digest
		AuthName "the_auth_name"
		AuthUserFile /the/digest.dav
		Require valid-user

		php_value engine off 
		RewriteEngine off	

    SSLEngine on
    SSLOptions +StrictRequire

    SSLCertificateFile /etc/ssl/certs/
    SSLCertificateKeyFile /etc/ssl/private/
    SSLCACertificateFile /etc/ssl/certs/

Then just reload Apache and you will no longer have that issue:

sudo service apache2 reload

Tags: , ,

Wednesday, July 22nd, 2015 Apache, Linux, Ubuntu No Comments

Force all HTTP traffic to HTTPS

If you have SSL installed and configured on your site, there is a little need to continue serving http traffic over port 80. Performance is no longer a big issue and now Google would reward with better ranking sites that serve all content over https.

It is very easy to achieve that on an Apache server.

1. Make sure that you have enabled mod_rewrite
2. Add the following to your .conf file for the site:

<IfModule mod_rewrite.c>
	RewriteEngine On
	RewriteCond %{HTTPS} off
	RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

The above code goes in the VirtualHost defininition for port 80. Make sure that you also have a VirtualHost definition for port 443.

In order for this to take affect, don’t forget to:

sudo service apache2 reload
Friday, June 12th, 2015 Apache, Linux, Ubuntu No Comments




May 2016
« Apr