Why I get this error (new Set(...)).slice is not a function? - stackblitz

I tried to run this code in any of the online code editors but I always get error
(new Set(...)).slice is not a function
Code:
myarray = ['d','s', 'a'];
chr_arr = [...new Set(myarray)];
why I get this error ?

you can't edit stackbiltz beacuse tsconfig.json is not available unfortunately .
but for now you can use Array.from
myarray = ['d','s', 'a'];
chr_arr = Array.from(new Set(myarray));
More info https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from

This only valid on ECMA Script 6
You need configure in tsconfig.json but online code editor (stackbliz) can't edit
https://angular.io/guide/typescript-configuration

Related

Keep getting 'Unexpected identifier' when running tests

I am trying to copy a tutorial for a Wordle solving bot but its just not going well. whenever I try to run a test on the code it doesn't work at certain points, I'll either get 'Uncaught SyntaxError: Unexpected identifier'. I'm doing this on UIlicious.
Here's what I've got so far:
I.goTo("https://www.powerlanguage.co.uk/wordle/")
I.click("reject")
I.see("Guess the Wordle")
I.click('/html/body', 40, 80)
let guessWord = null
for(Let r=0 ; r<6 ; ++r) {
guessWord = solver.suggestWord(gameState)
I.type(guessWord);
I.pressEnter()
I.wait(2)
}
let rowList = document.querySelector("game-app").shadowRoot. //
querySelector("game-theme-manager"). //
querySelector("#board").querySelectorAll("game-row");
you are probably referring to the article I wrote here : https://uilicious.com/blog/automate-wordle-via-uilicious/
This test script, is designed specifically to use uilicious.com, so you will need to edit and run it through the platform.
You can do so via the snippet here : https://snippet.uilicious.com/test/public/N5qZKraAaBsAgFuSN8wxCL
If you have syntax error there, do let me know with a snippet link - and I will try to help you respectively.
Also the snippet you provided so far, excludes the "solver" class which was initialised much further down.

youtube_explode_dart package has wrong documentation

I am trying to use flutter youtube_explode_dart package but I am facing some errors mainly two
with video.property
Code:-
var video = yt.videos.get('https://youtube.com/watch?v=Dpp1sIL1m5Q');
var title = video.title; // Error in this line
with streamManifest
Code:-
// Error saying streamManifest is not defined
var streamInfo = streamManifest.muxed.withHigestVideoQuality();
Link to the documentation code :- https://pub.dev/packages/youtube_explode_dart
If anyone has used the package or knows the fix PLEASE HELP!
use
manifest=yt.videos.streamsClient.getManifest(url);
after getting manifest then
var streamInfo = manifest.muxed.withHigestVideoQuality();
then use this hopefully your error will be solved please let me know if solved

How to resolve "unresolved import" in Rust when using VS Code?

I'm fairly new to rust and have been following the official book that they provide on their site. During chapter 2 they tell you to import a "Rand" cargo which I did. However, when I try to run my code directly through VS Code I get an error saying "unresolved import rand". When I run it through command prompt, everything works fine. I've already tried every solution suggested here: https://github.com/rust-lang/rls-vscode/issues/513 and nothing seemed to have worked. Extensions that I'm using:
Better TOML
Cargo
Code Runner
Rust (rls)
Rust Assist
vsc-rustfmt
vscode-rust-syntax
Has anyone else ran into a similar problem or a know a solution? Thank you!
Edit: My Cargo.TOML looks like this:
[package]
name = "guessing_game"
version = "0.1.0"
authors = ["Name <MyNameHere#gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rand = "0.6.0"
Edit 2: my main.rs file looks like this:
use rand::Rng;
use std::io;
use std::cmp::Ordering;
fn main()
{
println!("Guess the number!");
let secret_number = rand::thread_rng().gen_range(1, 101);
loop
{
println!("Please input your guess!");
let mut guess = String::new();
io::stdin().read_line(&mut guess).expect("Failed to read line!");
let guess: u32 = match guess.trim().parse()
{
Ok(num) => num,
Err(_) => continue,
};
println!("Your guess {}", guess);
match guess.cmp(&secret_number)
{
Ordering::Less => println!("Too small!"),
Ordering::Greater => println!("Too big!"),
Ordering::Equal =>
{
println!("You win!");
break;
}
}
}
}
Got a fix!
In VSC, select Extensions, select the Code Runner extension, click the little gear symbol and select Extension Settings. It's the Code-runner: Executor Map setting that needs to be changed. Click the 'Edit in settings.json' link.
Add the following to the file:
"code-runner.executorMap": {
"rust": "cargo run # $fileName"
}
If you already have content in the settings.json file then remember to add a comma to the line above and put your edit inside the outermost curly braces, e.g.
{
"breadcrumbs.enabled": true,
"code-runner.clearPreviousOutput": true,
"code-runner.executorMap": {
"rust": "cargo run # $fileName"
}
}
This tells Code Runner to use the 'cargo run' command, instead of 'rustc'
This fix came from this question on stackoverflow.

Unable to run compiled Matlab code that uses "Presentation" for report generation

I am trying to convert a simple program that uses "Presentation" (from reportgen package) to a .exe.
The code is as follows:
makePPTCompilable();
import mlreportgen.ppt.*
slides = Presentation('mySlideAddPresentation.pptx');
slide1 = add(slides,'Title and Picture');
plane = Picture(which('tulips.jpg'));
plane.X = '4in';
plane.Y = '4in';
plane.Width = '5in';
plane.Height = '2in';
add(slide1,plane);
close(slides);
I get the following error on running the complied version:
" Undefined function 'Presentation' for input arguments of type 'char'"
Any idea what I am missing here?I am on 2015b, used the following link for help: https://www.mathworks.com/help/rptgen/ug/compile-a-presentation-program.html
You need to make the reportgen compilable, see here and here
In my code I put:
if ismcc || isdeployed
% Make sure DOM is compilable
makeDOMCompilable()
end
Then it compiles fine! :)

Uploading to cloud storage with API, RequestException

Can anyone tell me why this code gets a request exception?
Google.Apis.Storage.v1.Data.Object obj = new Google.Apis.Storage.v1.Data.Object();
obj.Bucket = "testbucket1817";
obj.ContentType = "binary/octet-stream";
obj.SelfLink = #"C:\Users\User\Desktop\file";
obj.Name = "filename";
Google.Apis.Storage.v1.ObjectsResource.InsertRequest uploadrequest = new ObjectsResource.InsertRequest(storagecredentials, obj, "testbucket1817");
uploadrequest.Execute();
When run I get this error message-
Required [400]
Errors [
Message[Required] Location[ - ] Reason[required] Domain[global]
Message[Required] Location[ - ] Reason[required] Domain[global]
]
I'm not sure about the selflink thing or the content type (for an xml file) but there's nothing anywhere that actually says how this should be done.
Thanks anyone
InsertMediaUpload seems to work fine. Don't know what the difference is from InsertRequest other than I can figure out where to put the data with InsertMediaUpload. So whatever file you want to upload, just set a stream as File.Open(yourfile, FileMode.Open) and set an object like I did in the question.
Google.Apis.Storage.v1.ObjectsResource.InsertMediaUpload uploadmedia = new
ObjectsResource.InsertMediaUpload(ss, object, "bucketname", fileStream, "binary/octet-stream");
that sets up the upload and then uploadmedia.Upload() executes.
Thanks everyone!
Ross