rust-analyzer with optional feature [closed] - visual-studio-code

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 months ago.
Improve this question
I have vscode set up with the rust-analyzer plugin and it works in most cases. I have just added an optional feature but I cannot get vscode/rust-analyzer to parse the code, instead it always shows:
code is inactive due to #[cfg] directives: std is disabled rust-analyzer (inactive-code)
Cargo.toml:
[dependencies]
rand = {version = "0.8.5", default-features = false}
[features]
std = ["rand/std"]
main.rs:
#[cfg(std)]
use rand;
fn main() {}
My settings file has these lines:
"rust-analyzer.cargo.features": "all",
"rust-analyzer.checkOnSave.features": "all"
I thought it might be related to using both a VSCode workspace and a cargo workspace but simplifying it down to a stub cargo project shows the same issue.
Finally, I followed the advice in this question (no other plugins running and enabled RA_LOGS) but the output appears to show the command I expect with --all-features: How to activate an optional dependency?
[INFO flycheck] restart flycheck "cargo" "check" "--workspace" "--message-format=json" "--manifest-path" "$HOME/workspace/stackoverflow/Cargo.toml" "--all-targets" "--all-features"
Any idea what else I can check?

Sorry, I realise I was using the wrong form for cfg. It should have been:
#[cfg(feature = "std")]
In my real code I had a typo with the same effect #[cfg(features = "std")]

Related

How to add files required for your application to run in MATLAB [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 months ago.
Improve this question
I want to automate the compiling of my MATLAB script to an installer with MATLAB's compiler.build.standaloneApplication to create the standalone app and compiler.package.installer to create an installer.
I have python_script.exe file that my MATLAB script uses that is why I want to add it during creating the standalone app. The issue is the installed application using the outputted installer with the code below isn't adding the necessary python.exe file.
Here is my current progress.
Create the standalone app code.
opts = compiler.build.StandaloneApplicationOptions(...
'main.m', ...
'EmbedArchive', 'On', ...
'ExecutableIcon', 'C:\Program Files\MATLAB\.\toolbox\compiler\resources\default_icon_48.png', ...
'ExecutableName', 'test_app', ...
'ExecutableSplashScreen', 'C:\Program Files\MATLAB\.\toolbox\compiler\resources\default_splash.png', ...
'ExecutableVersion', '1', ...
'TreatInputsAsNumeric', 'Off', ...
'AdditionalFiles', ['python_script.exe'], ...
'AutoDetectDataFiles', 'off', ...
'OutputDir', '.\test_app_installer' ...
);
results = compiler.build.standaloneApplication(opts);
Use the result to create the package installer using the code below.
compiler.package.installer(results)
The 'AdditionalFiles' option should be a cell array of file names.
Change
['python_script.exe']
to
{'python_script.exe'}
Also make sure that the file python_script.exe is on the Matlab path on in the directory where the build is started.

error in process sentinel: Could not start nREPL server: java.lang.NumberFormatException: Invalid number

I've looked at all of the similar questions on stack overflow. This one is different enough to warrant a separate question. Basically, I can't start a repl server because I get the error below. It's been pointed out that this is typically a dependency issue, but I'm updated, to my knowledge. What am I getting wrong here? Here's the full error:
error in process sentinel: Could not start nREPL server: java.lang.NumberFormatException: Invalid number: 0.8.3
at clojure.lang.LispReader.readNumber (LispReader.java:352)
clojure.lang.LispReader.read (LispReader.java:278)
clojure.lang.LispReader.readDelimitedList (LispReader.java:1398)
clojure.lang.LispReader$VectorReader.invoke (LispReader.java:1347)
clojure.lang.LispReader.read (LispReader.java:285)
clojure.lang.LispReader.read (LispReader.java:216)
clojure.lang.LispReader.read (LispReader.java:205)
clojure.lang.RT.readString (RT.java:1878)
clojure.lang.RT.readString (RT.java:1873)
clojure.core$read_string.invokeStatic (core.clj:3815)
clojure.core$read_string.invoke (core.clj:3805)
clojure.core$mapv$fn__8445.invoke (core.clj:6912)
clojure.core.protocols$fn__8159.invokeStatic (protocols.clj:168)
clojure.core.protocols/fn (protocols.clj:124)
clojure.core.protocols$fn__8114$G__8109__8123.invoke (protocols.clj:19)
clojure.core.protocols$seq_reduce.invokeStatic (protocols.clj:31)
clojure.core.protocols$fn__8146.invokeStatic (protocols.clj:75)
clojure.core.protocols/fn (protocols.clj:75)
clojure.core.protocols$fn__8088$G__8083__8101.invoke (protocols.clj:13)
clojure.core$reduce.invokeStatic (core.clj:6828)
clojure.core$mapv.invokeStatic (core.clj:6903)
clojure.core$mapv.invoke (core.clj:6903)
leiningen.update_in$parse_args.invokeStatic (update_in.clj:13)
leiningen.update_in$parse_args.invoke (update_in.clj:9)
leiningen.update_in$update_in.invokeStatic (update_in.clj:36)
leiningen.update_in$update_in.doInvoke (update_in.clj:24)
clojure.lang.RestFn.applyTo (RestFn.java:146)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core$apply.invokeStatic (core.clj:667)
clojure.core$apply.invoke (core.clj:660)
leiningen.core.main$partial_task$fn__7331.doInvoke (main.clj:284)
clojure.lang.RestFn.applyTo (RestFn.java:139)
clojure.lang.AFunction$1.doInvoke (AFunction.java:31)
clojure.lang.RestFn.applyTo (RestFn.java:137)
clojure.core$apply.invokeStatic (core.clj:667)
clojure.core$apply.invoke (core.clj:660)
leiningen.core.main$apply_task.invokeStatic (main.clj:334)
leiningen.core.main$apply_task.invoke (main.clj:320)
leiningen.core.main$resolve_and_apply.invokeStatic (main.clj:343)
leiningen.core.main$resolve_and_apply.invoke (main.clj:336)
leiningen.core.main$_main$fn__7420.invoke (main.clj:453)
leiningen.core.main$_main.invokeStatic (main.clj:442)
leiningen.core.main$_main.doInvoke (main.clj:439)
clojure.lang.RestFn.applyTo (RestFn.java:137)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core$apply.invokeStatic (core.clj:665)
clojure.main$main_opt.invokeStatic (main.clj:514)
clojure.main$main_opt.invoke (main.clj:510)
clojure.main$main.invokeStatic (main.clj:664)
clojure.main$main.doInvoke (main.clj:616)
clojure.lang.RestFn.applyTo (RestFn.java:137)
clojure.lang.Var.applyTo (Var.java:705)
clojure.main.main (main.java:40)
EDIT:
So I've gotten farther on this problem and I think I'm down to the last little issue or two. The file that is being pulled that causes the java.lang.NumberFormatException is cider.el which you can finder in your emacs.emacs.d\elpa\cider-[VERSION NUMBER, in my case 20210104.915]. You open your cider.el file and on line 392/393, in this version, you'll find:
(cider-add-to-alist 'cider-jack-in-dependencies
"nrepl/nrepl" "0.8.3")
So changing this line, recompiling it, and reloading emacs gets the number throwing the java.lang.NumberFormatException to change to whatever I changed it to (recompile by using byte-compile-file, hitting enter, then passing it the address of the document). Adding another set of double quotes gets a null value error of sorts (obviously) and doing any type of backslashing for exceptions and sort doesn't seem to solve the issue. So, since the few related posts (though with much less detail) seem to hint at changing the version number, I'm going to have to assume that I have to do that. What version number would work best here?
TEMP SOLUTION SO FAR:
start a repl with "lein repl" in command line and connect to it manually using the connect command "cider-connect" and specifying the localhost (I started the repl in same directory as project and it detected it easily). This is not good enough for me as a permanent solution but gets me up and going temporarily until a better solution is found.
PERMANENT SOLUTION:
see below
Look at your dependencies. I had an issue where my java jdk was basically broken (java's fault, not mine, in so far as the code is concerned). I ended up using the latest OpenJDK (number 15). That worked. If you get lots of java specific type errors and those errors change with the versions that you're using, then consider updating your java jdk. I was using LTE versions before and the latest fixed it.

VSCode dynamic JSON schema validation [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have built project for a web application configuration. It includes generated (from TypeScript) JSONSchemas. To simplify - user can configure things like forms - field order (string[]), hidden fields(string[]) etc. JSON Schmeas are very helpful for users, who aren't too familiar with the configuration, and it validates some errors, that could rise from mistakes in the configuration.
But they cannot help in every situation - in those string arrays - user can put any string, and the schema will be valid.
What I would want to make - is some dynamic validation - when the user opens [ for the field order - he has to choose from the list of fields, that would be fetched from the APIs.
Something, like when you type packageName: "" in the package.json dependencies - it gets a version for the given package.
I would think, that I would have to make some VSCode extension for this - but I don't know - where to start. Can someone point me in the direction - an example, where someone uses real time JSON schema validation would be grateful.
Found an answer by digging through vscode source code. Searched all files, that contains package.json and dependencies (regex search (package.json[\s\S\n]*dependencies)|(dependencies[\s\S\n]*package.json)) and found a class PackageJSONContribution and this was exactly what I was looking for.
Then I made a simple extension using yo code (as from the example of Your first extension).
Some interfaces and classes I was unable to import from vscode, I just made a local copies for my extension. Made my own class FooJSONContribution with the only difference -
it's getDocumentSelector() function changed to
public getDocumentSelector(): vscode.DocumentSelector {
return [{ language: 'json', scheme: '*', pattern: '**/foo.json' }];
}
Adjusted extensions package.json activationEvents and added "onLanguage:json" (this could be optimised).
Adjusted activate event of the extension by adding
const contribution = new FooJSONContribution(xhr, true);
const disposableCompletionItemProvider = vscode.languages.registerCompletionItemProvider(
contribution.getDocumentSelector(),
new JSONCompletionItemProvider(contribution),
'"',
':'
);
context.subscriptions.push(disposableCompletionItemProvider);
And that's it. All of the foo.json files now work like package.json files -
Things I need to do now - adjust the code of FooJSONContribution.ts to work for my own needs, for my own API's, for my own files.
I Uploaded this example here https://github.com/leqwasd/VsCodeAsyncJsonAutocomplete

Installing Copy Selection or Line Macro for Jedit

hi I am new to jedit and I am trying to install a feature that lets me copy the current line when nothing is selected. I found this macro here http://www.jedit.org/users-guide/macros-clipboard.html under Copy_Selection_or_Line.bsh.
it seems like it is a default macro and I should be able to just use it without installing anything. but I can't find it in the list.
then I tried using the code for this macro here https://github.com/aismail/sedemo2011/blob/master/lib/jason/bin/jedit/macros/Clipboard/Copy_Selection_or_Line.bsh
I installed it and I can now enable it, but it doesn't work.
I spent ages trying to get this macro working but it's just not working. anyone able to give me a hand? thanks
The Copy_Selection_or_Line.bsh macro was renamed 7 years ago as can bee seen here: https://sourceforge.net/p/jedit/svn/11860.
It seems the documentation was not updated accordingly.
Would be great if you open a documentation bug here: https://sourceforge.net/p/jedit/bugs/new/
This shipped macro should work without any problems.
What you linked above is the macro as it was before that change I linked. It could well be that some API changed since 7 years ago and that the macro is not usable as is. Is the Copy_Lines.bsh macro doing what you want? If not, it could maybe at least help in updating the old Copy_Selection_or_Line.bsh macro to work with current jEdit.
I modified the macro (attached below):
// My Copy_Selection_or_Line.bsh
if (textArea.getSelectionCount() == 0) {
caretLine = textArea.getCaretLine();
lineEndOffset = textArea.getLineEndOffset(caretLine);
textArea.setSelection(new Selection.Range(textArea.getLineStartOffset(caretLine), textArea.getBufferLength() >= lineEndOffset? lineEndOffset : lineEndOffset-1));
}
Registers.copy(textArea,'$');

phow_caltech101 to change categories in matlab (vlfeat) [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I'm studying the Caltech101 computer vision dataset using Matlab..
I wanted to classify and train the images of caltech-101 using phow_caltech.m file
but there was a problem, I don't know how to change the categories...
these are what I did.
setup lv_setup
test version : vl_version verbose OK
vl_demo OK
make m_file phow_caltech101.m (copy)
I downloaded caltech101 images at [here][2] by myself and copied to data/caltech-101
>>phow_caltech101 (in command widnow)
I saw fixed example categories (BACKGROUND_Goole, Faces, Faces_easy, Leopards, Motobikes)
I've tried to change the example categories(BACKGROUND_Goole, Faces, Faces_easy, Leopards, Motobikes)
I want to use categories ( accordion, airplanes, anchor, ant in caltech-101)
I changed some codes of phow_caltech101.m but it didn't work...
plz give me some advice ... help me
I look forward to replying your mail or answer thank you~!
this is phow_caltech101 code
C:\VLFEAT\data\caltech-101 ( there are many image folders )
conf.calDir = 'data/caltech-101' ; ( I changed like this in phow_caltech101.m file)
From the help header to phow_caltech101:
The program can also be used to train a model on custom data by pointing CONF.CALDIR to it. Just create a subdirectory for each class and put the training images there. Make sure to adjust
CONF.NUMTRAIN accordingly.
Create a folder (say 'data/myclasses') containing the new classes (image collections) and have conf.caldir point to it, in phow_caltech101.m. That should be the first thing you change. There should be no need to change conf.prefiX if you are still putting the classes under data/.... but you need to adjust conf.numtrain to be the number of training sets you want to use.
caveat: my answer is based entirely on the documentation, I have not run the software.
Edit
Rather than attempt to run the script directly, start by trying to run the following lines at the matlab prompt, to check that you set up your folders correctly:
% the following line should contain the path to your data...
conf.calDir = 'data/caltech-101'; % <-- change this line if necessary
% make sure matlab finds the folder with your data
exist(conf.calDir, 'dir') % should return a "1"
% check the contents of the calibration data folder
classes = dir(conf.calDir)
If the folder does not exist or the contents being listed as classes are incorrect you need to adjust conf.calDir or the location of your data.