Brackets, configure proxy - json

I want to use Brackets (at best) but it's impossible to install extensions.
Indeed I have a proxy, I configured the brackets.json file like (check this https://github.com/adobe/brackets/wiki/How-to-Use-Brackets)
"proxy" : "http://username:password​#server:port/"
I use the same synthax like .npmrc file for node.js and that work, but with brackets, impossible to access extensions.
I try to install extensions with zip file but with this method, extensions don't work properly.
Any idea ?
Thanks for the help !

I was facing the same problem.The thing I was missing was a comma after the above element, here "downloadCount"
As my college proxy server is 172.16.30.80 and port is 8080,my brackets.json file looked like this
{
"brackets-eslint.gutterMarks": true,
"brackets-eslint.useLocalESLint": false,
"fonts.fontSize": "12px",
"fonts.fontFamily": "'SourceCodePro-Medium', MS ゴシック, 'MS Gothic', monospace",
"themes.theme": "delkos",
"extensions.sort": "downloadCount",
"proxy": "http://172.16.30.80:8080"
}
I have just added
"proxy": "http://172.16.30.80:8080"
For those who don't know, you can edit brackets.json file by selecting Open Preference File option of Debug in menu bar.

Related

module pygame has no init member pylint [duplicate]

This is the code I have:
import pygame
pygame.init()
I'm very confused because if I try to run the file, then there seems to be no issue, but pylint says the following:
E1101:Module 'pygame' has no 'init' member
I have searched thoroughly for a solution to this "error". In every relevant case I found, the solution was to make sure that I have not made another file or folder with the name "pygame", because in that case, I would just be importing my own file or folder.
However, I have not made a folder or file with a name even close to "pygame", so I don't know what the problem is.
As said earlier, it seems like I'm able to run the file without any issues and having errors like this confuses me in my learning process.
I write code in Visual Studio Code, I'm using python 3.6, I'm using pygame 1.9.3 and have updated my pylint. Any help would be appreciated.
Summarizing all answers.
This is a security measure to not load non-default C extensions.
You can white-list specific extension(s).
Open user settings and add the following between {}:
"python.linting.pylintArgs": [
"--extension-pkg-whitelist=extensionname" // comma separated
]
You can allow to "unsafe load" all extensions.
Open user settings and add the following between {}:
"python.linting.pylintArgs": [
"--unsafe-load-any-extension=y"
]
If you have VS code, go in your .vscode folder > settings.json or search for python.linting.mypyArgs Under user settings tab paste inbetween curly braces
"python.linting.pylintArgs": [
"--extension-pkg-whitelist=lxml" // The extension is "lxml" not "1xml"
]
I no longer see the pyinit error.
I had the same issue when I started using Visual Studio Code with Python. It has nothing to do with having another pygame.py or not installing it properly. It has to do with the fact that Visual Studio Code takes your code literally, and since you cannot import pygame.init(), it thinks that it isn't a correct module.
To fix this, open up settings.json (go into your settings, and click the {} icon) and paste
"python.linting.pylintArgs": [
"--extension-pkg-whitelist=pygame"
]
to it.
I had the same issue with one of my modules. This is what I did to resolve the problem. (I'm using visual studio on windows 10)
Press CTRL+SHIFT+P in visual studio
Choose "Preferences: Open Settings (JSON)"
Add "python.linting.pylintArgs": ["--generate-members"] below one of the lines (put a comma if necessary)
Save the .json file (CTRL+S)
For me, the code looks like this :
{
"breadcrumbs.enabled": false,
"editor.minimap.enabled": false,
"python.pythonPath": "C:\\Users\\xxx\\Anaconda3",
"terminal.integrated.rendererType": "dom",
"window.menuBarVisibility": "default",
"workbench.activityBar.visible": false,
"workbench.statusBar.visible": true,
"python.linting.pylintArgs": ["--generate-members"], //line to add
"[json]": {
}
}
Hope it helps.
Credit to #Alamnoor on github
This answer includes the answer to your question. In short it explains:
Pylint imports modules to effectively identify valid methods and attributes. It was decided that importing c extensions that are not part of the python stdlib is a security risk and could introduce malicious code.
and as a solution it mentions, among others:
Disable safety using the .pylintrc setting unsafe-load-any-extensions=yes.
See here for more information about pylint.rc. Quickest method is to just create the file .pylintrc in your project directory or your home directory.
I found adding this in settings.json() solves the problem.
"python.linting.pylintArgs":[
"--extension-pkg-whitelist=pygame",
"--erros-only"
]
I find an answer and it really works for me.
See the accepted answer and change it to extension-pkg-whitelist=lxml
pylint 1.4 reports E1101(no-member) on all C extensions
I recommend going to the view tab, clicking command palette and searching preferences: open settings.json. Then add a comma on the last line of code.Below that paste this:
"python.linting.pylintArgs": [
"--extension-pkg-whitelist=extensionname" // comma separated
]
Then save your document (ctrl + s).
Check if you have a python file named pygame.py created by you in your directory. If you do, then the import pygame line is importing your own file instead of the real Pygame module. Since you don't have an init() function in that file, you're seeing this particular error message.
I found a solution, modifying the most voted answer:
"python.linting.pylintArgs": [
"--extension-pkg-whitelist=pygame"
]
Replaced the "lxml" with "pygame".
Disable Pylint
1.Press ctrl + shift + p
2.Then type Disable Pylint
If you are using vscode then you can go to settings:
python.linting.pylintEnabled = False
It will fix the problem. If you aren't using vscode then you can go the command prompt and manually uninstall pylint with the command
pip uninstall pylint.

Disable predefined filename - JSON schema association

I am using Visual Studio Code 1.60.1.
In my project I use many files called project.json and have created my custom JSON schema for them.
When I specify my schema via $schema field directly in project.json everything works just fine.
But I want to use .vscode/settings.json file for that:
{
"json.schemas": [
{
"fileMatch": [
"data/projects/list/*/project.json"
],
"url": "./.vscode/schemas/project.json"
}
]
}
This works too BUT in this case it appears that VS Code is mixing two schemas for my file, which is showing in a tip when I hover the opening { in editor:
JSON schema for .NET Core project.json files
[My scheme name]
This results in mixing properties and messed up hints and autocomplition suggestions.
How can I disable VS Code default ".NET Core" schema for my files and leave only my schema?
Turns out I had C# official extension installed.
I disabled it and everything is working just fine!
The moral is: if something goes wrong, don't forget to check your extensions!

Very odd Cordova/Phonegap JSON error: Unexpected token in JSON at position 0

So i've been developing an app for the past few weeks. I have never messed with any json file whatsoever. Today I tried to run my app and it shows a very odd error from Cordova, Error:
Error: Unexpected token in JSON at position 0
The token is ' '?
Which JSON file is it? I went over all the main Json package files, and all of them started with the 0'th token as a '{'.
I'm completely lost, I didn't do anything at all, I didn't add a plugin or something that day it just appeared out of no where.
I have no idea which json files to attach here, there are dozens of them in the project directory.. Any ideas or direction will be extremely helpful, thanks.
Check plugins/*.json
There's most likely an issue hiding in one of those files.
For me it was an unresolved merge conflict inside fetch.json
Run npm install and it will give you more details of the error. In my case, it was an extra comma in package.json. It is a painful bug and I wish cordova explicitly mentioned where this issue was!
You had to check the file fetch.json in Plugins folder. Fetch.json must be encode in UTF8 and at the end of the JSON, the file need to finish correctly, without a comma, like this :
{
"es6-promise-plugin": {
"source": {
"type": "registry",
"id": "es6-promise-plugin#^4.1.0"
},
"is_top_level": false,
"variables": {}
},
"cordova-plugin-nativestorage": {
"source": {
"type": "registry",
"id": "cordova-plugin-nativestorage#^2.3.2"
},
"is_top_level": true,
"variables": {}
} //No Comma
}
Good luck !
My approach to any JSON error:
[optional] Remove/uninstall all plugins
Delete all your platform directory folders (ie. browser, Android, iOS etc,), and delete the package.json file
Note: Don't delete the package-lock.json file
Create a new package.json file by running npm init on your command line (run this command on your Cordova project directory).
Make sure you create this file with the same package name you used before. If you don't remember, you can check the config.xml file (including the 'version').
Reinstall all your plugins (if you followed step 1).
Add your platforms.
Run, build your Cordova project.
If it fails, follow step 1 to the last step.
It works 100℅
If this doesn't work, contact me and send me your issues.

How do I auto format Ruby or .erb files in VS Code?

I press ⌥ + ⇧ + F in Visual Studio Code for macOS, the shortcut to Format Document, to format a file called foo.rb or foo.html.erb.
Instead of formatting the document it prints out this letter: Ï
How do I get it to format the document?
You can set format associations in VSCode, so .erb files would be treated like .html.
Go to File->Preferences->Settings->Click ... in top right corner->Open settings.json
Then add this piece of code to your settings.json
"files.associations": {
"*.html.erb": "html"
}
This is how I solved this problem. It will remove some of the code highlights but will autoformat HTML templates like an HTML document.
You're going to need all of these settings in VS Code's settings.json file:
"ruby.rubocop.onSave": true,
"editor.formatOnSaveTimeout": 5000,
"editor.formatOnSave": true,
"files.associations": {
"*.erb": "erb"
},
Save the settings file. Install the "ruby-rubocop" and "ERB Formatter/Beautify" extensions on VS Code. Follow the documentation on both of those extensions to install their gem dependencies. Restart VS Code.
Format-on-save functionality will only trigger if the file is actually saved (which only happens if you change the file). Saving a file that has no changes will not trigger format-on-save.
If you're using prettier to format your html/css/js files, it is worth trying prettier-erb-plugin. Just add to your .prettierrc:
"plugins": ["#prettier/plugin-ruby", "prettier-plugin-erb"]
Or install it with yarn:
yarn add -D prettier #prettier/plugin-ruby prettier-plugin-erb
And make sure that VSCode uses local version of prettier from node_modules (or, you probably can install these plugins globally as well). Prettier VSCode plugin usually declared itself as default formatter, but just in case, make sure that in your settings.json is NOT written something like:
"[erb]": {
"editor.defaultFormatter": "aliariff.vscode-erb-beautify"
},
You can use Rufo to format your Ruby code. It is an opinionated formatter (like Prettier is for JS, if you are familiar with it).
You can use the vscode-rufo extension to integrate it with VSCode.
Update the settings.json of Visual Studio code:
File -> Preferences -> Settings -> Extensions -> Scroll down and find "Edit in settings.json"
Or in these paths in your OS
Windows %APPDATA%\Code\User\settings.json
macOS $HOME/Library/Application Support/Code/User/settings.json
Linux $HOME/.config/Code/User/settings.json
From Visual Studio Code Ruby extension documentation they recommend to use as an initial configuration:
"ruby.useBundler": true, //run non-lint commands with bundle exec
"ruby.useLanguageServer": true, // use the internal language server (see below)
"ruby.lint": {
"rubocop": {
"useBundler": true // enable rubocop via bundler
},
"reek": {
"useBundler": true // enable reek via bundler
}
},
"ruby.format": "rubocop" // use rubocop for formatting
Look at the linting documentation too for further improvements. Plus as mentioned previously, you can add that .erb should be treated as .html:
"files.associations": {
"*.html.erb": "html"
}
If you have no code formatting
That is, when you hit shift + option + F to format your code, vscode says something like:
install a formatter by clicking on the 'Extensions' tab on the left hand side of vscode, searching for 'ERB Formatter/Beautify' (by Ali Ariff), and installing it.
Run gem install htmlbeautifier
Press shift + command + P and search for
Preferences: Open Settings (JSON)
It should open a file that has a your JSON settings in it; something like this:
{
"window.zoomLevel": 1,
"editor.inlineSuggest.enabled": true
}
Add this to the settings.json file you opened in the previous step
"files.associations": {
"*.html.erb": "erb"
}
Your finished file might look like this:
{
"window.zoomLevel": 1,
"editor.inlineSuggest.enabled": true,
"files.associations": {
"*.html.erb": "erb"
}
}
Close and reopen vscode and it should now let you format with shift + option + F
If you have no syntax highlighting for erb files
The extension called 'ruby' will solve that.
Click on the 'Extensions' tab on the right hand side of vscode.
type in ruby
Install the ruby extension by Peng Lv
You may need to restart vscode
All done!
Reference
More info in this video
Nowadays (March 2019) I think prettier with prettier-ruby are the best options: it can handle Ruby, ERB (as HTML), JS, and many many more.
prettier script.rb # will show you the formatted script
prettier --write script.rb # will overwrite the file with the formatted script
You can use the Prettier VS Code plugin to do that automatically: https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
https://github.com/prettier/plugin-ruby
gem install htmlbeautifier
through the search functionality provided in the editor with Ctrl +Shift+ P (or Command + Shift + P on Mac), and then searching for format document.
I use the rubocop instead of rufo.
At the beginning, I used rufo. However, I met the issue
{
boo: {
a: 1,
b: 2,
c: 3
}
}
it always format it for me as
{
boo: {
a: 1,
b: 2,
c: 3,
},
}
add two ,, behind c: 3 and boo: {}. It is that makes my rubocop fail always.
As for, I use the rubocop in the project. Why not use it format my codes directly!
If you are interested, you can do as the following:
install the plugin VSCode ruby and then add the following snippets in the the settings.json
"ruby.format": "rubocop",
"ruby.intellisense": "rubyLocate",
"ruby.useBundler": true,
"ruby.lint": {
"rubocop": {
"useBundler": true
}
},
save it. It works~~(I wish you)
It is now possible to:
Install ruby-rubocop in VS Code
Go to File -> Preferences -> Settings
Search for Editor: Default Formatter and select "misogi.ruby-rubocop"
Go to File -> Preferences -> Keyboard Shortcuts
Search for Ruby: autocorrect by rubocop. There you have the shortcut to run rubocop in order to automatic format your ruby code following your rubocop settings.
You may also right click in your ruby file and you will find the "Format Document" option, which triggers "Ruby: autocorrect by rubocop" once ruby-rubocop is installed.
To format your ruby files, you don't need any extra plugin, you can just map some keys to do "editor.action.reindentLines"
If you use vscode-vim plugin, you can add this to your settings:
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["=", "="],
"commands": ["editor.action.reindentlines"]
}
],
Then in normal vim mode, == will reformat your file.

Sublime Text Config Q

(Running ST2 on Win7)
Just looking into ST2 as an ide for WebDev. I've introduced a few packages, but have got a bit lost in the configuration of them! I've a couple of problems.
Firstly I've got ST2 configured to open the browser on file save, but unfortunately it opens all files rather than just .html files. Ideally I'd like it to live refresh if the js is already in use, but in the worst case, just open .html files and ignore .js files
Secondly when it opens a .html file it opens it as a file rather than via SublimeServer which is running. I've followed this link and believe SublimeServer is running on the same port.
Here's the SublimeServer config:
{
"attempts": 5,
"autorun": true,
"interval": 500,
"mimetypes":
{
"": "application/octet-stream",
".c": "text/plain",
".h": "text/plain",
".py": "text/plain"
},
"port": 8000
}
and the proj config
{
"folders":
[
{
"path": "/E/Projects/MyProjects/My.Web/My.Web.App/My.Web.App.Designer"
}
],
"settings":
{
"sublime-view-in-browser":
{
"baseUrl": "http://localhost:8000/",
"basePath": "E:\\Projects\\MyProjects\\My.Web\\My.Web.App\\My.Web.App.Designer"
}
}
}
So where do I need to look in the config to modify this behaviour?
EDIT:
The packages I currently have installed are:
Bracket Highlighter
Browser Refresh
DocBlockr
Emmet
Git
Grunt
JSLint
Nodejs
Package Control
Side Bar
SublimeCodeIntel
SublimeLinter
View in Browser
Web Inspector
(and SublimeServer)
I pretty much got them all from Package Control.
As I newbie, I may need to pair some of these back.
Many thx IA
Simon