Google Sign-in Developer Error

May 27, 2017 1 min.

Resolving google sign-in error: Status{statusCode=DEVELOPER_ERROR, resolution=null} Follow these steps: Go to play console: https://play.google.com/apps/publish/ Go to “Release Management” -> “App signing” Copy the SHA1 from “App signing certificate” -> “SHA-1 certificate fingerprint” Go to Firebase console: https://console.firebase.google.com Select project -> Project Settings -> Select App Click “Add Fingerprint” Paste the SHA1 copied in the previous steps.

Avoid NullPointerException on Primitive Wrapper Objects

Feb 22, 2017 5 min.

Using the primitive wrapper objects like Boolean, Integer or Long in operators may throw NullPointerException, if the value is null, because the primitive wrapper objects auto unboxed to primitive values when you use java operators like ‘==’ ‘>’ ‘<’, etc. e.g. private Boolean isDone() { return null; } private Long getMyLongValue() { return null; } public void someMethod() { // Throw NPE if (isDone()) { } // Throw NPE if (getMyLongValue() > 10) { } } This will throw NullPointerException if the method ‘isDone()’ or ‘getMyLongValue()’ returns null.

Ubuntu Sync Internet Time

Jan 26, 2017 1 min.

Check NTP installed by following command $timedatectl status Output  Local time: Thu 2017-01-26 15:14:55 UTC Universal time: Thu 2017-01-26 15:14:55 UTC Timezone: Etc/UTC (UTC, +0000) NTP enabled: yes NTP synchronized: no RTC in local TZ: no DST active: n/a If NTP synchronized ‘no’ then install NTP using the following command sudo apt install ntp Start/Restart NTP sudo service ntp restart Reference: https://help.ubuntu.com/lts/serverguide/NTP.html

Tomcat log backup

Jan 25, 2017 2 min.

Following script can be used to archive the log files in tomcat log directory. This script… Archives all the files in logs directory to bkup directory Deletes all the files older than ‘n’ days in bkup directory #!/bin/bash arch_logs() { for file_pattern; do i=1 for log_file in $(find $file_pattern | sort -r); do test $i -eq 1 && ((i=i+1)) && continue; sudo gzip "$log_file" sudo mv *.gz .

Android Emulator Startup Issues

Jan 12, 2017 2 min.

KVM Permission Issue Error Dialog: KVM is required to run this AVD /dev/kvm device: permission denied. Grant current user access to /dev/kvm Do the following: # Check whether the user is root and group is kvm grep kvm /etc/group # if user is root and group is kvm then skip this step sudo apt install qemu-kvm # Check again grep kvm /etc/group # Add your current user to kvm group sudo adduser $USER kvm Lib Driver Error If you get the following error while starting the emulator

Oracle Milliseconds to Date

Nov 28, 2016 1 min.

Seconds to Date: SELECT to_timestamp('1970-01-01','yyyy-mm-dd') + numtodsinterval(<<seconds>>, 'SECOND') FROM dual; e.g. SELECT to_timestamp('1970-01-01','yyyy-mm-dd') + numtodsinterval(1480340561, 'SECOND') FROM dual; Milliseconds to Date: Just divide the millseconds my 1000 so it will become seconds and apply the same query as above. SELECT to_timestamp('1970-01-01','yyyy-mm-dd') + numtodsinterval(<<milliseconds>>/1000, 'SECOND') FROM dual; e.g. SELECT to_timestamp('1970-01-01','yyyy-mm-dd') + numtodsinterval(1480340490930/1000, 'SECOND') FROM dual;

Access GIT Using SSH Key

May 12, 2016 1 min.

Create SSH Key Create a SSH (private/public) key using the following command ssh-keygen -t rsa -C "somerefname" The above command asks for phase phrase and either enter the pass phrase or press enter for no pass phrase. The above command generates following two files in your «home»/.ssh directory id_rsa id_rsa.pub Login to your GIT hosting server (e.g. github.com or bitbucket.org) and import the public key into your profile.

Oracle: Statistics Update

Mar 30, 2016 1 min.

Get Last statistics Update SELECT table_name, last_analyzed, sample_size, num_rows sample_pct FROM dba_tables WHERE owner = 'your_schema_name_here' ORDER BY last_analyzed; Note: last_analyzed column shows the last analyzed date sample_size and sample_pct should be same (or difference should be very less) Statistics Update (for schema) execute DBMS_STATS.GATHER_SCHEMA_STATS( OWNNAME=> 'your_schema_name_here', ESTIMATE_PERCENT => DBMS_STATS.AUTO_SAMPLE_SIZE, METHOD_OPT=> 'FOR ALL INDEXED COLUMNS', DEGREE => 8, CASCADE=> TRUE ); Statistics Update (for table) EXEC DBMS_STATS.GATHER_TABLE_STATS( 'your_schema_name_here', 'your_table_name_here', estimate_percent=>'', method_opt => 'for all indexed columns size auto', DEGREE => 8, CASCADE => TRUE );

Oracle: Get list of connected users

Mar 30, 2016 1 min.

Following query returns the list of users who are currently connected to the Oracle database SELECT username, osuser, terminal, utl_inaddr.get_host_address(terminal) ip_address FROM system.v$session WHERE username is not null ORDER BY username, osuser;

Java random integer in min and max range

Mar 4, 2016 1 min.

Following sample code returns a random integer within the give min and max range (both inclusive) import java.util.Random; public class RandomRange { // Declare as class variable so that it is not re-seeded every call private static Random random = new Random(); /** * Returns a psuedo-random number between Min and Max (both inclusive) * @param min Minimim value * @param max Maximim value. Must be greater than min. * @return Integer between min and max (both inclusive) * @see java.