Import nouislider with webpack on rails - ruby-on-rails

I'm trying to implement a nouislider on Rails. I installed it with Yarn and my package.json confirms this: "nouislider": "^11.1.0".
Unfortunatly I got this error on the chrome console :
Uncaught ReferenceError: noUiSlider is not defined at Object. (slider2.js:12)
here is my app/javascript/packs/application.js :
import "nouislider";
import '../components/slider2';
(where slider2.js is my noUiSlider script)
What is wrong with this importation? Why does slider2.js don't understand what is noUislider?

Try:
import noUiSlider from "nouislider";
Also going to a assume you have a file in the correct place for your second line.

Related

How to fix find error for dart:html in VSCode?

I try to run in VSCode a simple dart program with
import 'dart:html';
clause.
import 'dart:html';
// import 'package:html/dom.dart';
// import 'package:html/dom_parsing.dart';
// import 'package:html/parser.dart';
void main() async{
var myTable = new TableElement()
..setAttribute('border','1');
// ..setAttribute(name, value);
...
In Run mode (I use VSCode extension "Code Runner 0.9.9") and in Debug appeared the same error:
Error: Not found: 'dart:html'
import 'dart:html';
I have installed Dart SDK 2.3.1 at Windows10 and not installed Flutter at all.
PATH pointed to Dart SDK bin directory
PATH =D:\Dart\dart-sdk\bin;
*) At project directory I try to add additional directive at pubspec.yaml
dependencies:
----
name: main
description: Test App sample22
dependencies:
html:
---
After "pub get" command I'll see that html present but error still persist.
pub get
Resolving dependencies...
+ charcode 1.1.2
+ csslib 0.16.0
+ html 0.14.0+2
+ path 1.6.2
+ source_span 1.5.5
+ term_glyph 1.1.0
Changed 6 dependencies!
*) My next step was to import html parts via "package:html/" (marked as comments in code sample). It is not helped and required class TableElement still unrecognizable.
"main.dart:8:19: Error: Method not found: 'TableElement'."
*) I try to change "launch.json" string from
default
"program": "bin/main.dart",
to
"program": "D:/Dart/WRK03t/main.dart",
And rename my code file to "main.dart"
*) Also I try to remove Dart extension from VSCode, restart PC and install it again. it's not helped.
But let me say that when I compile main.dart to js
"dart2js -m -o tst.js main.dart"
Resulted tst.js run correctly within the html page.
Almost the same problem in Request Dart Installation doesnt find dart:html
dart:html is only available in the browser. This is the error you get if you try to run code that uses it on the VM (instead of the browser). This is expected.
If you need to run your code outside of the browser (eg. in the VM as a CLI app or via Fluter) you cannot use dart:html. If you only want to use it in the browser but VS Code is trying to run your code in the VM, you'll need to set up some VS Code tasks/launch configs to run build_runner, similar to the Dart DevTools project:
https://github.com/flutter/devtools/tree/abe811f66e1bd36612b76bbe28250bc669a6ce08/.vscode

Flask vs Terminal: how do I manage imports so that I can use codes in both?

I have a Flask project with the following directory structure:
-my_project
- flask_code.py
- module
- submodule
- foo.py
- bar.py
- xyz.py
In flask_code.py, I must import both foo and bar. Therefore, flask_code has the following import statements:
"""flask_code.py"""
from module.foo import *
from module.bar import *
In foo.py, I need to import xyz. I also have implemented a main function in foo for testing, which I usually call from command line. If I write the imports of foo like this:
"""foo.py import 1"""
from module.xyz import *
The flask application runs exactly as expected. But, if I try to run foo.py from command line, I get the following error:
ModuleNotFoundError: No module named 'module'
On the other hand, if I change the imports of foo to:
"""foo.py import 2"""
from xyz import *
the ModuleNotFoundError is not thrown anymore when foo.py is called from command line, which I guess it's expected. But, the flask application can't find module xyz on its own.
Both my_project and module folders have a init.py empty file.
I want to manage these imports so that I can both use the flask application and call the scripts from command line for testing. Thanks in advance!

using highcharts with jhipster

I'm trying to integrate highcharts to my jhipster Gateway using angular 4.
In the command line I used
>yarn add angular-highcharts#4
> yarn add --dev #types/highcharts#4
but i got this error :
./node_modules/angular-highcharts/angular-highcharts.es5.js
Module not found: Error: Can't resolve 'highcharts' in '/home/vagrant/IdeaProjects/chart/node_modules/angular-highcharts'
When I opened ./node_modules/angular-highchartsangular-highcharts.es5.js:
I got:
this import is not supported by current javascriptversion
import * as Highcharts from 'highcharts';
import { Directive, ElementRef, Inject, Injectable, InjectionToken, Input, NgModule } from '#angular/core';
Am I missing a setting somewhere?

PyLint not recognizing cv2 members

I am running pylint on an opencv project and I am getting many pylint errors in VS code about members not being present.
Example code:
import cv2
cv2.imshow(....)
Errors obtained:
However , the code runs correctly without any errors.
Versions : pylint 1.8.1 , astroid 1.6.0
This is from pylint. You can generate a pylint config file in the root of your project with this command:
(I find this to be helpful if you work in a team or on different computers from the same repo)
pylint --generate-rcfile > ~/.pylintrc
At the beginning of the generated .pylintrc file you will see
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code.
extension-pkg-whitelist=
Add cv2 so you end up with
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code.
extension-pkg-whitelist=cv2
Save the file.
The lint errors should disappear.
On VScode: CTRL + Shift + P
Choose "Preferences: Open Settings (JSON)"
Add this line into JSON file:
"python.linting.pylintArgs": ["--generate-members"]
Done, it works for me
Note: Make sure you choose "Preferences: Open Settings (JSON)", not "Preferences: Open Default Settings (JSON)"
Setting File would look like
{
"workbench.iconTheme": "vscode-icons",
"python.dataScience.sendSelectionToInteractiveWindow": true,
"kite.showWelcomeNotificationOnStartup": false,
"python.dataScience.askForKernelRestart": false,
"python.dataScience.jupyterServerURI": "local",
"python.pythonPath": "/usr/bin/python3",
"workbench.colorTheme": "Monokai",
"vsicons.dontShowNewVersionMessage": true,
"python.linting.pylintArgs": ["--generate-members"] }
Try import cv2 like this:
from cv2 import cv2
Yes it is because the extension has not been installed.
Set this: extension-pkg-whitelist=cv2 and you're good to go.
However it may not detect the functions or modules implemented in cv2
Here the code snippet for the settings.json file in MS V Code
"python.linting.pylintArgs":["--extension-pkg-whitelist=cv2"]
I didn't have to change anything in the pylint Jason file like the most of the answers here My solution is to change the import statement to the form below
from cv2 import cv2
Eventually, cv2 members can be used!
In VSCode, edit the Settings JSON (Ctrl+Shift+P, > "Preferences: Open Settings JSON)
Then, paste the following into the JSON:
"python.linting.pylintArgs": [
... // prievious arguments
"--generated-members=cv2.*"
]
Don't know why, but other solutions (allowlist, etc) weren't working for me, and I didn't want ot create the .pylintrc file.
I used below config settings in settings.json of vscode and it helped me avoid the unessential flags by pylint, and also got intellisense for cv2 working,
it it doesn't work try uninstalling and deleting cv2 packages from C:\Anaconda3\envs\demo1\Lib\site-packages folder, and reinstalling opencv-python package
{
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.linting.pylintArgs": [
"--extension-pkg-whitelist=cv2"
]
}

Imports failed in Config.groovy file (Grails 2.2.3)

I try to run a grails app thanks to grails run-app command. Version I use is grails 2.2.3.
All imports failed and I've got the "unable to resolve class" about all import line. For example :
unable to resolve class com.octo.captcha.component.image.backgroundgenerator.GradientBackgroundGenerator
Errors are about the following lines :
import com.octo.captcha.service.multitype.GenericManageableCaptchaService
import com.octo.captcha.engine.GenericCaptchaEngine
import com.octo.captcha.image.gimpy.GimpyFactory
import com.octo.captcha.component.word.wordgenerator.RandomWordGenerator
import com.octo.captcha.component.image.wordtoimage.ComposedWordToImage
import com.octo.captcha.component.image.fontgenerator.RandomFontGenerator
import com.octo.captcha.component.image.backgroundgenerator.GradientBackgroundGenerator
import com.octo.captcha.component.image.color.SingleColorGenerator
import com.octo.captcha.component.image.textpaster.NonLinearTextPaster
Here you can read these 2 files : Config.groovy and the return of "grails run-app" to help you : http://dl.free.fr/vPbCJEUnN
Thanks for your help !

Resources