Using ArrayList to load spinner in Android (Java)

AND.png

I had an ArrayList of objects, and i need to set it as my spinner’s adapter. In your class CityModel, override the toString() method in it and return the name of the city.

public void initSpinners(View view){
        Spinner spinnerSource = (Spinner) view.findViewById(R.id.spinner_From);
        ArrayAdapter<CityModel> adapter =
                new ArrayAdapter<CityModel>(this.getActivity(), android.R.layout.simple_spinner_dropdown_item, cities);
        adapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
        spinnerSource.setAdapter(adapter);
        Spinner spinnerDestination = (Spinner) view.findViewById(R.id.spinner_To);
        spinnerDestination.setAdapter(adapter);
    }

 

 

   @Override
    public String toString() {
        return cityName;
    }

 

Updating Kotlin version in Gradle inside Android Studio

To update to the latest version of the Kotlin in any existing project, check the latest version number for Kotlin from Settings -> Plugins -> Install JetBrains plugin -> Search ‘Kotlin’ and check for any updates or if latest is already installed, just note the version number and then open Build.Gradle (Project) file and enter the Kotlin version and click on sync. The project should be up and running with the latest Kotlin version for Android Development

23

1

4.png

Resolving “Package not available for R version” issues

The default version of “install.packages” somehow stopped working for me after i upgraded my to the latest R version(3.4.2) in my Development environment. In the latest R (3.2.3) there is a bug, preventing it some times from finding correct package. The workaround is to set repository manually:

1.Error

Somehow for me install.packages() did not work. So i used the below code as a workaround and this should work for almost any versions of R. See below code snippet and screenshot for sample

install.packages("sas7bdat", dependencies=TRUE, repos='http://cran.rstudio.com/')

3.success

 

“Loading required package: rJava” in R

Many times when i start my R environment which is setup in VisualStudio 2017, i tend to get this error below.

error

The error tells us that there is no entry in the Registry that tells R where Java is located. It is most likely that Java was not installed (or that the registry is corrupt). This error is often resolved by installing a Java version (i.e. 64-bit Java or 32-bit Java) that fits to the type of R version that you are using (i.e. 64-bit R or 32-bit R). This problem can easily effect Windows 7 users, since they might have installed a version of Java that is different than the version of R they are using.

You can pick the exact version of Java you wish to install from this link. If you might (for some reason) work on both versions of R, you can install both version of Java (Installing the “Java Runtime Environment” is probably good enough for your needs).

Other possible solutions is trying to re-install rJava.

If that doesn’t work, you could also manually set the directory of your Java location by setting it before loading the library:

error

 

Hope this helps!

 

Import .BAK file to Azure SQL Database

When you need to import a sql database file (.bak) from an archive in a local folder or from a file share ,  you can import the database schema and data from a BACPAC file. A BACPAC file is a ZIP file with an extension of .BACPAC containing the metadata and data from a SQL Server database. A BACPAC file can be imported to Azure and can be used as a standard SQL database in Cloud. Import using the Azure portal only supports importing a BACPAC file.

Below are the steps to follow:

  1. Create a BACPAC file
  2. Import the .BACPAC file into Azure

Above steps will create your local database into Azure cloud environment. We will go through the above steps in detail below.

Create a BACPAC file:

Right click on the database and select Tasks –> Export Data-tier Application as below.

img_3

Click Next

img_4

Provide a valid path and a desired filename for the .bacpac file.

img_5

Click finishimg_6

Export Database operation will be started

img_7

You will see below screen on successful completion of exporting the database into a bacpac filebacpac_success

File will be as below.

bacpac_file

Import .BACPAC file into Azure

img_1.11.21.3

1.4

 

The database has now been successfully uploaded into Azure from a local storage.

Query to find largest objects in a SQL Server database

SELECT 
    t.NAME AS TableName,
    i.name as indexName,
    sum(p.rows) as RowCounts,
    sum(a.total_pages) as TotalPages, 
    sum(a.used_pages) as UsedPages, 
    sum(a.data_pages) as DataPages,
    (sum(a.total_pages) * 8) / 1024 as TotalSpaceMB, 
    (sum(a.used_pages) * 8) / 1024 as UsedSpaceMB, 
    (sum(a.data_pages) * 8) / 1024 as DataSpaceMB
FROM 
    sys.tables t
INNER JOIN      
    sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN 
    sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
INNER JOIN 
    sys.allocation_units a ON p.partition_id = a.container_id
WHERE 
    t.NAME NOT LIKE 'dt%' AND
    i.OBJECT_ID > 255 AND   
    i.index_id <= 1
GROUP BY 
    t.NAME, i.object_id, i.index_id, i.name 
ORDER BY 
    object_name(i.object_id) 

Reporting Services Permissions on SQL Server – SSRS

User ‘Domain\User’ does not have required permissions. Verify that sufficient permissions have been granted and Windows User Account Control (UAC) restrictions have been addressed.

SSRS - Copy.png

When opening the Report Manager in my Chrome browser i faced this issue recently. After some checking i found that the inbuilt user was not having permissions for SSRS. The set-up program only gives access to Builtin\Administrators. As a workaround, to gain access for Builtin\Users , you need to right click you browser link and choose Run as administrator.

To fix this issue do the below steps:

  1. Run internet explorer as Administrator
  2. Open the report Manager URL, this time you should get in
  3. Go to site settings in the top right
  4. Click Security then New Role Assignment
  5. Enter your domain\username and select System Administrator, click ok
  6. Add other users as necessary
  7. Click home, Folder Settings, then New Role Assignment
  8. Enter your domain\username and select Content Manager, click ok
  9. Add other users as necessary
  10. Re-open internet explorer (non-admin) and recheck the url.

SSRS.png