Code

Code

Get referrer using GA (google analytics script)

ga(function(tracker) { console.log(tracker.get('referrer')); });

Starting mysql using chkconfig

chkconfig --add mysqld chkconfig mysqld on

Scheduled Annotation for JAVA

// second, minute, hour, day, month, weekday @Scheduled(cron = "*/10 * * * * *") public void do {}

Short UID using JavaScript

function generateUID() { var firstPart = (Math.random() * 46656) | 0; var secondPart = (Math.random() * 46656) | 0; firstPart = ...

Hiding the Navigation Bar in Android

View decorView = getWindow().getDecorView(); int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCR...

Shipping Multiple APKs in Android

armeabiv-v7a: Version 7 or higher of the ARM processor. Most Android phones released from 2011-15 are using this. arm64-v8a: 64-bit ARM pr...

Change drawer icon back to back arrow in Android

<item name="drawerArrowStyle">@style/DrawerArrowStyle</item> <style name="DrawerArrowStyle" parent="...

How to use "sec:authorize" for checking multiple Roles?

<sec:authorize access="hasAnyRole('ROLE_A', 'ROLE_B')"> text </sec:authorize>

Show dependencies for gradle

./gradlew dependencies or (for android) ./gradlew app:dependencies Output sample: testRuntime - Runtime dependencies for source set...

Android statusbar icons to black.

<item name="android:windowLightStatusBar">true</item> http://stackoverflow.com/a/26637752/1015731

0.1 + 0.2 == 0.3 Is it wrong?

0.1 + 0.2 == 0.3 -> false 0.01 + 0.02 == 0.03 -> true 0.1 + 0.2 -> 0.30000000000000004 http://stackoverflow.com/questions/58800...

Add finish loading listener for WebView on Android

mWebView.setWebViewClient(new WebViewClient() { public void onPageFinished(WebView view, String url) { // do your stuff here ...

Handling Orientation Changes on Android Fragment

Fragment.setRetainInstance(true); Calling setRetainInstance(true) on a Fragment is similar to setting the android:configChanges flag on an...

Combining 2 Images in Android using Canvas (Side by Side)

http://www.jondev.net/articles/Combining_2_Images_in_Android_using_Canvas public Bitmap combineImages(Bitmap c, Bitmap s) { // can add a ...

Open a file in another app via using file Uri

Uri uri = FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".provider", file); String mime =...

FileUriExposedException on Android 7.0

Uri photoURI = FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".provider", createImageFile...

Get Download Directory in Android

Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);

SimpleDraweeView did not recycled in RecyclerView in Fresco Library

DraweeController draweeController = Fresco.newDraweeControllerBuilder()
 .setOldController(mImage.getController())
 .setUri(...

Realm for RecyclerView Adapter Example

RealmRecyclerViewAdapter can be used with RecyclerViews. See an example below link. https://github.com/realm/realm-android-adapters/blob/m...