20 September 2018

Automatic Install nVidia drivers in Ubuntu

The first method is the easiest to perform and in most cases it is the recommended approach. First, detect the model of your nvidia graphic card and the recommended driver. To do so execute:
$ ubuntu-drivers devices
== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd00001180sv00001458sd0000353Cbc03sc00i00
vendor   : NVIDIA Corporation
model    : GK104 [GeForce GTX 680]
driver   : nvidia-304 - distro non-free
driver   : nvidia-340 - distro non-free
driver   : nvidia-384 - distro non-free recommended
driver   : xserver-xorg-video-nouveau - distro free builtin

== cpu-microcode.py ==
driver   : intel-microcode - distro free
If you agree with the recommendation feel free to use ubuntu-drivers command again to install all recommended drivers:
$ sudo ubuntu-drivers autoinstall
Once the installation is concluded, reboot your system and you are done.

19 September 2018

Start Android Studio in Ubuntu with root privileges

If you have to start Android Studio in Ubuntu with root privileges for regular updates, you should make these commands in terminal:

sudo ln -s /opt/android-studio/bin/studio.sh /usr/local/bin/studio
sudo chmod 777 /usr/local/bin/studio

If you have problem with sudo in Ubuntu you can setup root password with command:

sudo passwd root

Now you can start android studio from anywhere by entering command : studio

11 September 2018

Wordpress: Update default page layout for all posts

To update default page layout for all posts, we need to do it in database table wp_postmeta for all post_id's, with next command:

INSERT INTO wp_postmeta (post_id, meta_key, meta_value) SELECT ID, "mom_page_layout", "right-sidebar" FROM wp_posts WHERE post_type = "post" AND post_status = "publish"

After that, all published posts will have desired page layout.

This is also available for event pages, with command :

INSERT INTO wp_postmeta (post_id, meta_key, meta_value) SELECT ID, "mom_page_layout", "right-sidebar" FROM wp_posts WHERE post_type = "event" AND post_status = "publish"

06 September 2018

Relocate Android Studio SDK and Emulator files

If you want to relocate your Android Studio SDK and Emulator files to different folder or disc, than you have to setup these environment variables :

ANDROID_SDK_HOME                        - D:\Android
ANDROID_EMULATOR_HOME          - D:\Android\.android\
ANDROID_AVD_HOME                        - D:\Android\.android\avd\

After these setup variables, your Android Studio will use these folders.


04 September 2018

Android SQL Injection Vulnerability with exported=false

So here's the problem: when I add the widget to the homescreen, a SecurityException is immediately thrown inside the onDataSetChanged() method when I try to query the provider. This appears to be because the homescreen does not hold the permission to read my content provider.

Because of Google Play Developer Console witch refuse App Submission because of  SQL Injection Vulnerability with exported=false in AndroidManifest.xml, we need to leave that option to false.

While the context is actually correct, it is bound to the wrong process.

So we need to enclose our query in clearing Identiry Token in WidgetService.java:

// Revert back to our process' identity so we can work with our
// content provider
final long identityToken = Binder.clearCallingIdentity();

mCursor = cr.query(EntryColumns.ALL_ENTRIES_CONTENT_URI, new String[]{EntryColumns.TITLE, EntryColumns._ID, FeedData.FeedColumns.ICON}, selection.toString(), null, EntryColumns.DATE + Constants.DB_DESC);

// Restore the identity - not sure if it's needed since we're going
// to return right here, but it just *seems* cleaner
Binder.restoreCallingIdentity(identityToken);

This solves the problem, even without setting read/write permissions on the contentprovider, just using it with exported set to "false".