Microsoft Visual studio Test Framework
Monday 7 September 2020
Unit test c#: Create Fake Httpcontext to bypass Null exception for User object
Accessing SMB share from Raspberry pi (or linux)
Install smbclient :
sudo apt update
sudo apt install smbclient
List the share items in the server:
smbclient -L host
for example: smbclient -L 192.168.0.30
you need to enter password.then you'll see the result like this:
Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.9.5-Debian]
Sharename Type Comment
--------- ---- -------
print$ Disk Printer Drivers
RaspberrypiShare Disk
IPC$ IPC IPC Service (Samba 4.9.5-Debian)
pi Disk Home Directories
Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.9.5-Debian]
Server Comment
--------- -------
RASPBERRYPI Samba 4.9.5-Debian
Workgroup Master
--------- -------
To browse Shared folder :
smbclient \\\\192.168.0.30\\RaspberrypiShare pa$$w0rd
Temperature/CPU/Memory info of Raspberry Pi in console
Open the console/terminal in the desktop or
Connect to the raspberry pi via ssh and type in the below commandFor temperature:
/opt/vc/bin/vcgencmd measure_temp
For CPU info:
cat /proc/cpuinfo
For Memory info:
cat /proc/meminfo
Add Python(or Java or anything) to Environment variables
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 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.
Ssh to linux machine without using password
To SSH connect to a linux machine, a raspberry pi in my example from a PC without using a username and password, you can set up SSH key-b...
-
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...