How to Import/Export live code template in android studio? - eclipse

In Eclipse there is simply option to import or export code template. I want to do same in android studio but there is not any direction option to do so.
I have create one template and now i want to apply it to all my other system so i need to export & import.
I have one option to do but i just want to know that is any other way to do.
Create your code template file in eclipse and export.
Exported file will be XML.
Now copy that XML file and move to ..//.AndroidStudio/config/templates
Restart Studio and Use it.
Can you please help me out.
Thanks for your time.

System-independent solution:
Go to File -> Export Settings, choose only Live templates, and export it to a file.
Then you can use File -> Import Settings and provide this file to import live templates.
(I haven't tested it myself so I'm not sure how exactly the Import Settings works. I don't know if it merges the settings with your current ones or swaps it entirely. Bare that in mind when trying...)
System-specific solutions:
Mac OS:
Go to /Users/<username>/Library/AndroidStudioX.X/templates/.
There's where user.xml file containing your Live Templates should be.
Linux:
The templates are saved inside ~/.AndroidStudioX.X/config/templates/Android.xml

Related

VSCode: how to structure a simple python package with few modules and tests, debugging and linting?

I'm having more trouble than I'd like to admit to structure a simple project in Python to develop using Visual Studio Code.
How should I structure in my file system a project that is a simple Python package with a few modules? Just a bunch of *.py files together. My requisites are:
I must be able to step debug it in vscode.
It has a bunch of unit tests using pytest.
I can select to debug a specific test from vscode tab and it must stop in breakpoints.
pylint must not show any false positives.
The test files must be in a different directory of the main module files.
I must be able to run all the tests from the console.
The module is executed inside a virtual environment using python standard lib module venv
The code will use type hints
I may use another linter, even another test framework.
Nothing fancy, but I'm really having trouble to get it right. I want to know:
How should I organize my subdirectory: a folder with the main files and a sibling folder with the tests? Or a subfolder with the code and a subsubfolder with the tests?
Which dirs must have a init.py file?
How the tests should import the files from the module? Should I use relative imports?
Should I create a pytest.ini file?
Should I create a .env file?
What's the content of my launch.json the debugger file config in vscode?
Common dir structure:
app
__init__.py
yourappcode.py
tests (pytest looks for this)
__init__.py
test_yourunittests.py
server.py if you have one
.env
.coveragerc
README.md
Pipfile
.gitignore
pyproject.toml if you want
.vscode (helpful)
launch.json
settings.json
Or you could do one better. Ignore my structure and look at the some of famous python projects github page. Like fastAPI, Flask, asgi, aiohttp are some that I can think of right now
Also:
I think absolute imports are easier to work with compared to relative imports, I could be wrong though
vscode is able to use pytest. Make sure you have a testing extension. Vscode has a built in one im pretty sure. You can configure it to pytest and specify your test dir. You can also run your test from command line. If youre at the root, just running ‘pytest’ will recognise your tests dir if it’s named that by default. Also your actual test files need to start with prefix test_ i think.
The launch.json doesn’t need to be anything special. When you click on the settings button next to play button in the debug panel. Vscode will ask what kind of app is it. I.e If its a flask app, select python then select flask and it will auto generate a settings file which you can tweak however you want in order to get your app to run. I.e maybe you want to expose a different port or the commands to run your app are different
It sounds to me like you just need to spend a bit of time configuring vscode to your specific python needs. For example, you can use a virtualenv and linting in whichever way you want. You just need to have a settings.json file in the .vscode folder in your repo where you specify your settings. Configurations to specify python virtualenv and linting methods can be found online

How to create a template out of my customized launch.json in vscode?

For my project, I have customized my launch.json file.
How can I save my own customized launch configuration as a template? Just like C++ (GDB/LLDB) template
So that I can re-use it easily every time I open a new folder(project).
I don't want to add it under global launch configuration. Adding it there would start showing up my launch configurations even for other kind of projects where this launch configuration is inappropriate.
I wanted to have the same behavior that is achieved for C++ (GDB/LLDB) template. How is that achieved?
Edit - I have raised an enhancement request VSCode GitHub-
https://github.com/microsoft/vscode/issues/109234
They are part of the debugger configuration in the language extension.
Way too much trouble to create an extension for this.
Just create a snippet for a .json file and use it while editing the .vscode/launch.json

How to install typings for Visual Studio Code in an offline development environment?

I'm using VisualStudio Code, and trying to enable IntelliSense. It seems to be dependent on typings. How can I install these offline? In PowerShell, running
typings search leaflet
returned an error (unsurprising, because I'm offline).
Unable to connect to "https://api.typings.org/search?query=leaflet"
Running that web query on an online computer resulted in a difficult to read JSON file. A further google search resulted in this likely candidate:
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/leaflet/index.d.ts
My question has three parts, and I'd appreciate pointers on any of these.
1) How can I figure out what typings I need?
2) Which files do I need to take to the offline computer? Do I just need the d.ts file?
2) Where should this file be installed so that VS Code can read it?
1) Simply put: if your Visual Studio Code is complaining about not being able to resolve something. Lets say I'm working with jQuery, I'm using $ a lot in my project and it's going to give me an error because it's not Typescript/JavaScript.
To resolve this, I create a JSON file to the root of my project called typings.json. It will look like this:
{
"resolution": "typings/",
"globalDependencies": {
"jquery": "github:DefinitelyTyped/DefinitelyTyped/jquery/index.d.ts"
}
}
Then in the Terminal tab (CTRL + SHIFT + <) execute the following command:
typings install
Now it will download the required typings and put the contents to root/typings/. You'll need to reference it in each file you're using (in this case) jQuery in by adding the following to the top of your TS file:
/// <reference path="./typings/globals/jquery/index.d.ts" />
You can also create a definition (.d.ts) file in the root/typings folder and add all the references there so you only have to reference that file.
2) After installing the typings in the previous step, you can copy the typings folder and put it on your offline computer. It's as easy as that. You don't need other files (not even the typings.json file, if you wish).
2) You need to reference definition (d.ts) files at the top of your .ts files.

Is it possible to import Visual Studio Power Tools settings?

Recently I've upgraded from VS2013 to VS2015. I've imported my settings file from 13 to 15. Now I would like to import my settings for the extension 'Visual Studio Power Tools'. Specifically the document well regex settings. I use this to color my tabs differently in each of my three environments, for each of the file types. I was able to find where these settings are stored thanks to this question:
Visual Studio Productivity Power Tools configuration settings
I've located these settings, but now my question is: how do I import them into VS2015? I'm not very experienced messing with the registry and don't want to muck something up. So far I was able to export the specific reg settings for my VS2013 colors. I also found the location of the color settings folder (in the registry) for vs2015. Is it possible to somehow take that .reg file I exported and import it into the settings for vs2015? Thanks for any help. It's greatly appreciated!
Edit: So it's been a week or so and I've gotten no responses to the question :(
I suppose another way to ask this would be: "is there a way to import registry settings?"
In Visual Studio 2015 those settings are stored under a registry key:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio\14.0\DialogPage
Assuming that the plugin didn't change the way its color settings are stored, it should be enough to edit the .reg file that you exported from Visual Studio 2013 in a chosen text editor (notepad.exe will do) and replace all ocurrences of \12.0\ (which is version number of VS2013) with \14.0\ (which is version number of VS2015).
Then you may open the .reg file to import settings.
By the way, if you would like to include registry settings like this in your backup plan, you might easily export registry keys from a command line with something like:
regedit /e d:\VSPowerToolsColorSettingsBackup.reg "HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio\14.0\DialogPage"

Team foundation server source control - changing .resx files

I have never use TFS version control...so I will try to explain problem I'm facing..
I have a small application for language localization...app make changes to .resx files of the project hosted on TFS...problem is that source control does't see that .resx files has been changed?
Any suggestions?
You need to change the file type options, try this article. It might be what you're after.