foreach

Java - Parse - iterate over ParseObject fields

荒凉一梦 提交于 2020-06-09 06:25:31
问题 Having a ParseObject object how can I loop through its fields and get the name of the field along with the value of it? This would really help me minimize my code. 回答1: Hmm, ParseObject contains key-value pairs, and I think you can't iterate though it. But. I found something called .keySet() method of ParseObject. It returns ... well, the set of keys (excluding createdAt, updatedAt, authData, or objectId). I think you can convert it into an array and iterate trhough it? Something like this:

Start-Process with Process Priority in Loop doesn't recognize variable

烈酒焚心 提交于 2020-06-01 05:06:45
问题 I'm using FFmpeg with PowerShell. I have a loop that goes through a folder of mpg files and grabs the names to a variable $inputName . FFmpeg then converts each one to an mp4 . Works Batch Processing $files = Get-ChildItem "C:\Path\" -Filter *.mpg; foreach ($f in $files) { $inputName = $f.Name; #name + extension $outputName = (Get-Item $inputName).Basename; #name only ffmpeg -y -i "C:\Users\Matt\Videos\$inputName" -c:v libx264 -crf 25 "C:\Users\Matt\Videos\$outputName.mp4" } Not Working Batch

Start-Process with Process Priority in Loop doesn't recognize variable

佐手、 提交于 2020-06-01 05:06:21
问题 I'm using FFmpeg with PowerShell. I have a loop that goes through a folder of mpg files and grabs the names to a variable $inputName . FFmpeg then converts each one to an mp4 . Works Batch Processing $files = Get-ChildItem "C:\Path\" -Filter *.mpg; foreach ($f in $files) { $inputName = $f.Name; #name + extension $outputName = (Get-Item $inputName).Basename; #name only ffmpeg -y -i "C:\Users\Matt\Videos\$inputName" -c:v libx264 -crf 25 "C:\Users\Matt\Videos\$outputName.mp4" } Not Working Batch

What is the fastest way to update SQL rows with values, based upon a value in the row?

落爺英雄遲暮 提交于 2020-05-31 06:30:31
问题 I have the following table in SQL Server called tblProducts : +-----------+--------------+-------------+ | pkProduct | fkProductID | intIssue | +-----------+--------------+-------------+ | 1 | 10 | 1 | | 2 | 10 | 2 | | 3 | 10 | 4 | | 4 | 11 | 1 | | 5 | 11 | 2 | | 6 | 11 | 3 | | 7 | 11 | 5 | | 8 | 12 | 1 | | 9 | 13 | 1 | | 10 | 13 | 4 | | 11 | 14 | 1 | | 12 | 14 | 3 | | 13 | 14 | 6 | | 14 | 15 | 1 | | 15 | 16 | 1 | +-----------+--------------+-------------+ Over time, with rows having being

How to avoid 'sink stack is full' error when sink() is used to capture messages in foreach loop

江枫思渺然 提交于 2020-05-27 04:26:45
问题 In order to see the console messages output by a function running in a foreach() loop I followed the advice of this guy and added a sink() call like so: library(foreach) library(doMC) cores <- detectCores() registerDoMC(cores) X <- foreach(i=1:100) %dopar%{ sink("./out/log.branchpies.txt", append=TRUE) cat(paste("\n","Starting iteration",i,"\n"), append=TRUE) myFunction(data, argument1="foo", argument2="bar") } However, at iteration 77 I got the error 'sink stack is full'. There are well

parallelizing heterogenous tasks in R: foreach, doMC, doParallel

霸气de小男生 提交于 2020-05-25 08:27:39
问题 Here's what's been puzzling me: When you schedule a sequence of tasks that are homogenous in terms of content but heterogenous in terms of processing time (not known ex ante) using foreach, how exactly does foreach process these embarrassingly parallel tasks sequentially? For instance, I registered 4 threads registerDoMC(cores=4) and I have 10 tasks and the 4th and the 5th each turned out to be longer than all others combine. Then the first batch is obviously the 1st, 2nd, 3rd and 4th. When

display html li elements column-wise under their alphabets in php

让人想犯罪 __ 提交于 2020-05-23 21:15:14
问题 I have a php code as shown below which displays list of items (listings) under their alphabets column-wise (show in the fiddle below). php code: if ( is_array( $beta_lists ) && ! empty( $beta_lists ) ) : $before_title_character = ''; echo "<pre>"; print_r($beta_lists); echo "</pre>"; // Line A ?> <ul id="programs-list" class="programs-list js-list-active"> <?php foreach ( $beta_lists as $title => $permalink ) : $character_title=substr(transliterator_transliterate('Any-Latin;Latin-ASCII;',

How to collect submitted values of a List<T> in JSF?

爱⌒轻易说出口 提交于 2020-05-23 17:33:43
问题 I have a bean with a List<T> : @Named @ViewScoped public class Bean { private List<Item> items; private String value; @Inject private ItemService itemService; @PostConstruct public void init() { items = itemService.list(); } public void submit() { System.out.println("Submitted value: " + value); } public List<Item> getItems() { return items; } } And I'd like to edit the value property of every item: <h:form> <ui:repeat value="#{bean.items}" var="item"> <h:inputText value="#{bean.value}" /> <

Bash foreach loop

安稳与你 提交于 2020-05-22 10:21:29
问题 I have an input (let's say a file). On each line there is a file name. How can I read this file and display the content for each one. 回答1: Something like this would do: xargs cat <filenames.txt The xargs program reads its standard input, and for each line of input runs the cat program with the input lines as argument(s). If you really want to do this in a loop, you can: for fn in `cat filenames.txt`; do echo "the next file is $fn" cat $fn done 回答2: "foreach" is not the name for bash. It is

Bash foreach loop

前提是你 提交于 2020-05-22 10:21:05
问题 I have an input (let's say a file). On each line there is a file name. How can I read this file and display the content for each one. 回答1: Something like this would do: xargs cat <filenames.txt The xargs program reads its standard input, and for each line of input runs the cat program with the input lines as argument(s). If you really want to do this in a loop, you can: for fn in `cat filenames.txt`; do echo "the next file is $fn" cat $fn done 回答2: "foreach" is not the name for bash. It is