loops

Bash Script Loop Out of Memory?

我与影子孤独终老i 提交于 2020-01-25 08:08:30
问题 In bash I need to run a script that loops from i=1 to i=99999999 but it always run out of memory. Is there any workaround? or is there a max value for i? first=1 last=99999999 randomString="CXCXQOOPSOIS" for val in $( seq $first $last ) do padVal=$( printf "%010d\n" $val ) hash=$( echo -n $randomString$padVal | md5sum ) if [[ "$hash" =~ ^000000) ]]; then echo "Number: $val" >> log_000000 echo "$val added to log - please check." fi done 回答1: bash provides C-like syntax for loop: first=1 last

how to iterate $TwitterStatuses as an array or as Objects?

你。 提交于 2020-01-25 07:57:06
问题 How can I iterate each $TwitterStatuses element/item/object? (And, how do I inspect each "status"?) Import-Module PSTwitterAPI Set-TwitterOAuthSettings -ApiKey $env:ApiKey -ApiSecret $env:ApiSecret -AccessToken $env:AccessToken -AccessTokenSecret $env:AccessTokenSecret #Get-TwitterUsers_Lookup -screen_name 'mkellerman' $TwitterStatuses = Get-TwitterStatuses_UserTimeline -screen_name 'mkellerman' #$TwitterStatuses = [array]Get-TwitterStatuses_UserTimeline -screen_name 'mkellerman' Foreach (

Writing to a file code causing an endless loop

走远了吗. 提交于 2020-01-25 07:54:11
问题 I am writing a program to write text to a file based on user input, stopping when a blank line is entered, I.E. when hasNextLine is false. However, after running the program the file contains thousands of instances of the same line of input, which continues to grow until I kill the program. Could someone advise me on where I am going wrong please? import java.util.Scanner; import java.io.FileNotFoundException; import java.io.PrintWriter;; public class Lab_Week8_WriteAStory { public static

How would you loop every 30 minutes

流过昼夜 提交于 2020-01-25 07:53:07
问题 Trying to make a for loop that has the HHMM outputted in a data-time HTML field. I currently have: for ($i = 1; $i <= 20; ++$i) { echo '<div class="mb-timer-hour"><div class="mb-timer-half" data-time="0830"></div></div>'; } Except this outputs data-time="0830" every time. I then tried $h = 30; $h + 30 but this then goes: 0800, 0830, 0860, 0890, ... Is it possible to loop 0800, 0830, 0900, 0930, ... ? The start time and end times are user variables which is why I haven't hard coded an array.

How do I make this macro create a new sheet after comparing values to a set variable?

妖精的绣舞 提交于 2020-01-25 07:29:10
问题 I am writing a macro that splits out data to another sheet after comparing values in column A to a set variable. Column A has all Work Order numbers. I need the macro to create a new sheet for each new work order, and copy all lines to that sheet. It needs to name the sheet with a concatenation of the value found in column A and Column B, and then copy all rows associated with that Work Order to the new sheet. The prefix is the Work Order. Prefix 12581 should get its own sheet, named 12581-4,

Trying to iterate my function many times using i

十年热恋 提交于 2020-01-25 07:05:18
问题 I'm trying to iterate a for loop many times but it's only printing out once. sample_gamma <- function(alpha, beta, n, iter) { mean_s = c() mean_sd = c() for(i in 1:iter){ a = rgamma(n, shape = alpha, scale = 1/beta) return(c(mean(a), sd(a))) } 回答1: i think you are looking for this sample_gamma <- function(alpha, beta, n, iter) { mean_s = c() mean_sd = c() for(i in 1:iter){ a = rgamma(n, shape = alpha, scale = 1/beta) print(c(mean(a), sd(a))) } } 来源: https://stackoverflow.com/questions

How to append characters to a string array in C

走远了吗. 提交于 2020-01-25 06:48:06
问题 I'm very new to C and I'm trying to write a program that checks if a string contains any uppercase letters, and if it does, prints them out. I'm using https://www.onlinegdb.com/online_c_compiler# as my compiler (cause I don't have access to my personal computer right now) and after a test run, the results are (p.s. I know gets isn't safe): main.c:16:5: warning: ‘gets’ is deprecated [-Wdeprecated-declarations] /usr/include/stdio.h:638:14: note: declared here main.c:(.text+0x26): warning: the

R: repeat linear regression for all variables and save results in a new data frame

为君一笑 提交于 2020-01-25 06:46:12
问题 I have a data frame named “dat” with 10 numeric variables (var1, var2,var3,var4 , var5,…var 10), each with several observations… dat var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 1 12 5 18 19 12 17 11 16 18 10 2 3 2 10 6 13 17 11 16 18 10 3 13 15 14 13 1 17 11 16 18 10 4 17 11 16 18 10 17 11 16 18 10 5 9 13 8 8 7 17 11 16 18 10 6 15 6 20 17 3 17 11 16 18 10 7 12 5 18 19 12 17 11 16 18 10 8 3 2 10 6 13 17 11 16 18 10 9 13 15 14 13 1 17 11 16 18 10 ... I would like to write a code to

R: repeat linear regression for all variables and save results in a new data frame

老子叫甜甜 提交于 2020-01-25 06:46:07
问题 I have a data frame named “dat” with 10 numeric variables (var1, var2,var3,var4 , var5,…var 10), each with several observations… dat var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 1 12 5 18 19 12 17 11 16 18 10 2 3 2 10 6 13 17 11 16 18 10 3 13 15 14 13 1 17 11 16 18 10 4 17 11 16 18 10 17 11 16 18 10 5 9 13 8 8 7 17 11 16 18 10 6 15 6 20 17 3 17 11 16 18 10 7 12 5 18 19 12 17 11 16 18 10 8 3 2 10 6 13 17 11 16 18 10 9 13 15 14 13 1 17 11 16 18 10 ... I would like to write a code to

How to prevent Repetitive Looping and Data Duplication

梦想的初衷 提交于 2020-01-25 05:40:06
问题 This is currently the code that I am using. I embedded the code inside a change event when a cell within a range changes. But, every time I do change a cell within the range the entire loop starts from the top of the row and inserts the data in the destination cells repetitively. Is there a way that the loop doesn't post the data that is already at the destination? I guess I need the loop not to loop a cell that it already looped on the INFO INPUT sheet. The change event triggers the macro