After installation of python in windows 10, python is not added to environment variable by default. If you want to use cmd for python, then python installed path must be configured in the environment variable.
Monday 7 September 2020
Add Python(or Java or anything) to Environment variables
Monday 17 August 2020
Add Azure Devops plugins in Android Studio for Git or TFVC Version control
By default, Android studio can not connect to the Azure devops source codes. To connect to the Azure devops, a plugins by Microsoft needs to be installed in the android studio. To install the plugin, follow the below steps:
1) Open a project in Android studio
2) go to File --> Setting
3) go to Plugins
4) Search for azure devops
5) Click Install
6) Restart the Android studio.
7) Menu->VCS->Checkout from Version Control -> Azure Devops Git
Create Azure SQL User and add a sql role
I wanted to add a new sql user "sqluser" in Azure SQL server to access a database "sanjeeb".
Steps to create a new SQL user.
1) Connect to the Azure sql server with existing user using Microsoft SQL Server Management studio
2) Open new query window under Master database
3) Run the below script
CREATE LOGIN [sqllogin] WITH PASSWORD = 'verystrongpassword#1'
Tuesday 11 August 2020
Scrollable readonly EditView in Kotlin
Scrollable readonly EditView in Kotlin
In the view xml file:
<EditTextandroid:id="@+id/etResult" android:layout_width="match_parent" android:layout_height="343dp" android:background="@color/backgroundColor" android:backgroundTint="#00000000" android:ems="10" android:enabled="true" android:fontFamily="sans-serif-condensed" android:gravity="start|top" android:hint="@string/blankfoldermessage" android:importantForAutofill="no" android:inputType="none" android:paddingTop="2dp" android:singleLine="false" tools:targetApi="o" />
in the kotlin file (init function):
etResult.keyListener = null
this will allow the edit text to be multiline, not editable but scrollable.
Wednesday 5 August 2020
Simple use of Timer in Kotlin
the code below will set the button to clickable after 30 sec:
btnOk.isClickable=false
Timer().schedule(timerTask { btnOk.isClickable=true }, 1000*30)
the above code runs in a separate thread,
so the UI is responsive while running this code.
Working with UI controls from Non main thread in Kotlin
import org.jetbrains.anko.uiThread
doAsync {
// Normal code inside Async thread
I=I+1
If(I=100){ uiThread { tvResult.setText =”I is now 100!!”
}
}
//More code
If(x==0){
uiThread { tvResult.setText =”there’s some problem!”
}
}
}
Permission request pop up in android
Request user to give permission to read external storage in Android - (Kotlin)
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { // Permission is not granted // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_EXTERNAL_STORAGE)) { } else { // No explanation needed, we can request the permission. ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE), READ_STORAGE_CODE); } } else { // Permission has already been granted}
NOTE: READ_STORAGE_CODE is just an int constant with fix value like 1001, or 2023
and is a variable in class level.
TFS -GIT CertGetCertificateChain trust error CERT_TRUST_IS_UNTRUSTED_ROOT
In the TFS_Build Server or App server(if build and app server is in the same machine) >
run the script from this url: https://blog.sanjeebojha.com.np/2019/06/git-ssl-certificate-problem-unable-to.html
Once this is done, you should get another problem:
Problem 2) CertGetCertificateChain trust error CERT_TRUST_IS_UNTRUSTED_ROOT
- Export the certificate public key to a file. The file is later required.
- Open the url "https://tfssite.company.com/tfs/projectcollection" in IE
- Click on the Lock icon in the browser address bar
- Select The Root level Certificate and Click View Certificate
- Copy the file to User folder
- Config Git to use trusted certificate using the crt file.
git config --global http.sslCAInfo c:\Users\svc_tfs17_app\ca-bundle.crt - Convert the \n (Unix) to \r\n (Windows) so that it can be displayed by notepad editor correctly.
- Use the unix2dos open source software to convert \n to \r\n, or other notepad editor to replace \n to \r\n.
- Copy the content of tfs.cer from step o to ca-bundle.crt at the bottom of the file.
Insert Identity Column in a table
identity
column in that table by using the following code:MSSQL Remove duplicate Rows
- Select the duplicate key values into a holding table. For example:
SELECT col1, col2, col3=count(*) INTO holdkey FROM t1 GROUP BY col1, col2 HAVING count(*) > 1
Select the duplicate rows into a holding table, eliminating duplicates in the process. For example: SELECT DISTINCT t1.* INTO holddups FROM t1, holdkey WHERE t1.col1 = holdkey.col1 AND t1.col2 = holdkey.col2
At this point, the holddups table should have unique PKs, however, this will not be the case if t1 had duplicate PKs, yet unique rows (as in the SSN example above). Verify that each key in holddups is unique, and that you do not have duplicate keys, yet unique rows. If so, you must stop here and reconcile which of the rows you wish to keep for a given duplicate key value. For example, the query: SELECT col1, col2, count(*) FROM holddups GROUP BY col1, col2 should return a count of 1 for each row. If yes, proceed to step 5 below. If no, you have duplicate keys, yet unique rows, and need to decide which rows to save. This will usually entail either discarding a row, or creating a new unique key value for this row. Take one of these two steps for each such duplicate PK in the holddups table.
Delete the duplicate rows from the original table. For example: DELETE t1 FROM t1, holdkey WHERE t1.col1 = holdkey.col1 AND t1.col2 = holdkey.col2
Put the unique rows back in the original table. For example: INSERT t1 SELECT * FROM holddups
Generate SQL script from entity framework using powershell/visual studio
to run the below command , start PowerShell in visual studio. Select the database project. In PowerShell: Script-Migration this command wi...
-
This solution Works for TFS 2010+ . Open Visual studio Command prompt and run the following script. tf workspace /delete /server:[Site:Port/...
-
for example, the login name is 'mysqluserlogin' 1) Enable the disabled login: ALTER LOGIN mysqluserlogin ENABLE ; 2) Change the lo...
-
By default, Android studio can not connect to the Azure devops source codes. To connect to the Azure devops, a plugins by Microsoft needs t...