Swift Print() not displaying results - swift

I am new to learning Swift. I am currently taking a course through Udemy. I was attempting to use the following command, which did not yield a result.
print(inches_tall = (feet * 12) + inches)
I got back the following: "()\n"
I am posting to see, what I am missing, also to get back into the community as I continue my journey.
I was attempting to use the print() to display. I did not "need" to use print. I was looking for additional ways to solve the small building-block-task I was given.

Related

Try to MatchAll a string in Power Apps

I've been programming in Power Apps for some time now (but I'm not a specialist). I'm trying to pass an array from Power Automate to Power Apps.
I was able to do that with a string and after a few more steps I have the following text:
[{"Messung":1;"Tiegel leer":"16;5469";"Tiegel Probe":"27;6659";"Tiegel Asche":"17;6549"}]";"[{"Messung":2;"Tiegel leer":"16;9654";"Tiegel Probe":"26;5476";"Tiegel Asche":"17;6549"}]";"[{"Messung":3;"Tiegel leer":"17;0256";"Tiegel Probe":"27;9862";"Tiegel Asche":"18;2235"}"]
I would like to convert this back to a data table with a MatchAll command, unfortunately I do not understand the Microsoft explanation for this command at all. I can convert the semicolons in the values ​​back into commas later, but I needed the semicolons (language dependency, programming in German)
My plan was to do the conversion using a ClearCollect(MatchAll....) command.
I seem to be able to get these individually for my individual columns
(; <Tiegel_leer>;<Tiegel_Probe> & <Tiegel_Asche>).
ClearCollect(ResultAG;MatchAll(Label40_1.Text;"(""Messung"":(?[^""]))"));;
ClearCollect(ResultAG;MatchAll(Label40_1.Text;"(""Tiegel Probe"":(?<Tiegel_Probe>[^""]))"));;
ClearCollect(ResultAG;MatchAll(Label40_1.Text;"(""Tiegel leer"":(?<Tiegel_leer>[^""]))"));;
ClearCollect(ResultAG;MatchAll(Label40_1.Text;"(""Tiegel Asche"":(?<Tiegel_Asche>[^""]))"))
But I can't connect these lines with each other and I still don't really understand it. These lines were also created more by trial and error than by understanding.
Would be glad if someone could help me with this.
Thanks for helping
Using MatchAll approach is very old and complex approach to parse the array of objects (data) sent from Power automate to Power apps.
I would suggest you to use the recently released ParseJSON function in Power apps instead of MatchAll function for this.
For detailed information and tutorial, check:
Power Fx: Introducing ParseJSON
ParseJSON function in Power Apps (experimental)
ParseJSON function in Power Apps - Video

How to find the column of the number that you're looking for?

After I watched a video about finding back a number with random numbers (Video link, if you want to know), I tried to make a sheets program for it. When I was trying to find out how much does it take to get back to a number, I have no idea on which function to use. In order to find how much "tries" to get back to a number. I tried =FIND and =HLOOKUP and it failed because it has multiple same numbers.
Example:
[1 needs 3 tries to get back to 1, so the result should be 3. Same thing with 2, but it needs 17 tries.
Here's the link of the google sheet
try something like this:
=IFERROR(IF($B7=INDEX($B$7:$B, MATCH(B7, ROW($A$7:$A)-(ROW($A$7)-1), 0)),,
INDEX($B$7:$B, MATCH(B7, ROW($A$7:$A)-(ROW($A$7)-1), 0))))
spreadsheet demo

Mozilla Deep Speech SST suddenly can't spell

I am using deep speech for speech to text. Up to 0.8.1, when I ran transcriptions like:
byte_encoding = subprocess.check_output(
"deepspeech --model deepspeech-0.8.1-models.pbmm --scorer deepspeech-0.8.1-models.scorer --audio audio/2830-3980-0043.wav", shell=True)
transcription = byte_encoding.decode("utf-8").rstrip("\n")
I would get back results that were pretty good. But since 0.8.2, where the scorer argument was removed, my results are just rife with misspellings that make me think I am now getting a character level model where I used to get a word-level model. The errors are in a direction that looks like the model isn't correctly specified somehow.
Now I when I call:
byte_encoding = subprocess.check_output(
['deepspeech', '--model', 'deepspeech-0.8.2-models.pbmm', '--audio', myfile])
transcription = byte_encoding.decode("utf-8").rstrip("\n")
I now see errors like
endless -> "endules"
service -> "servic"
legacy -> "legaci"
earning -> "erting"
before -> "befir"
I'm not 100% that it is related to removing the scorer from the API, but it is one thing I see changing between releases, and the documentation suggested accuracy improvements in particular.
Short: The scorer matches letter output from the audio to actual words. You shouldn't leave it out.
Long: If you leave out the scorer argument, you won't be able to detect real world sentences as it matches the output from the acoustic model to words and word combinations present in the textual language model that is part of the scorer. And bear in mind that each scorer has specific lm_alpha and lm_beta values that make the search even more accurate.
The 0.8.2 version should be able to take the scorer argument. Otherwise update to 0.9.0, which has it as well. Maybe your environment is changed in a way. I would start in a new dir and venv.
Assuming you are using Python, you could add this to your code:
ds.enableExternalScorer(args.scorer)
ds.setScorerAlphaBeta(args.lm_alpha, args.lm_beta)
And check the example script.

Swift - Getting Error while using replacingOccurrence

So I'm taking Udacity's Swift for Developers course. I attempted to look at the forums for this question but oddly, they were quiet. This is the programming prompt:
var forwardString = "stressed"
var backwardsString = forwardString.characters.reversed()
print(backwardsString)
var lottaLikes = "If likeyou wanna learn Swift likeyou should build lots of small apps cuz it's likea good way to practice."
var noLikes = lottaLikes.replacingOccurrences(of:"like", with:"")
print(noLikes)
For whatever reason, I keep getting this error message:
Be sure that you have replaced all occurences of the word "like" and removed any extra spaces.
What am I missing here? If you need clarification on this I would be happy to provide it.
Thank you
It may be that your code gets the job done, but only because your variable lottaLikes is written in a weird way. You usually would have two spaces surrounding the word "like" so just removing the word would leave 2 spaces in a row. I would suggest writing the following line:
var noLikes = lottaLikes.replacingOccurrences(of:"like ", with:"")
It may be that Udacity is not checking the actual output, but the code itself. If so, It may be looking for something like I wrote above.
If this still does not work, you may want to write another line like so:
var noExtraSpaces = noLikes.replacingOccurences(of: " ", with: " ")

How do I Benchmark RESTful Service with Variable Parameters?

I'm currently working on benchmarking a RESTful service I've made, and part of that is making sure it runs in a reasonable amount of times for a large array of parameters. For example, let's say I have RESTful API of the form some_site.com/item?item_id=y. In that case to be sure my service is working as fast as I'd like it to work, I'd want to try out many values for y one by one, preferably coming from some text file. I can't figure out any way of doing this in ab or httperf. I'm open to using a different benchmarking program if I have, but would prefer something simple and light. What I want to do seems like something pretty standard, so I'm guessing there must already be a program that let's me do it, but an hour or so of googling hasn't gotten me an answer. Ideas?
Answer: Jmeter (which is apparently awesome). This faq explains how to do it. Hopefully this helps someone else, as it took me like a day of searching to figure this out.
I have just had some good experience with using JavaScript (via BSF/Rhino) in JMeter.
I have put one thread group in my test plan and stick a 'Simple Controller' with two elements under it - 'HTTP Request' sampler and 'BSF PreProcessor'.
Set BSF language to 'javascript' and either type the code into the text box or point it to a file (use full path or relative to CWD of JMeter process).
/* Since `Math.random()` gives us float, we use `java.util.Random()`
* see: http://docs.oracle.com/javase/7/docs/api/java/util/Random.html */
var Random = new Packages.java.util.Random();
var min = 10-1;
var max = 2;
var maxLines = (min)+Random.nextInt(max-min);
var s = '';
for (var d = 0; d <= maxLines; d++) {
s += d.toString()+','+Random.nextInt(1000).toString()+'\n';
}
// s => '0,312\n1,104\n2,608\n'
vars.put('PAYLOAD', s);
Now I can refer to ${PAYLOAD} in the HTTP request!
You can generate JSON, but you will need to upgrade jakarta-jmeter-2.5.1/lib/js-1.6R5.jar with the newest version of Rhino to get JSON.stringify and JSON.parse. That worked perfectly for me also, though I thought I'd put a simple example here.
You can use BSF pre-processor for URL params as well, just set another variable with vars.put('X', 'some value') and pass it as ${X} in the request parameter.
This blog post helped quite a bit, by the way.