Como criar um código em JavaScript que cria várias variáveis com nomes e valores aleatórios em looping? (Se isso for possível)

É possível criar um looping em Js que cria várias variáveis com nomes e valores aleatórios (ou algo parecido)?

Um looping não termina para começar outro. Como resolver? (Python)

Olá, sou novo no fórum e ainda estou aprendendo a usar a interface. Se eu postei no lugar errado ou qualquer coisa assim, me desculpem. Criei uma conta para fazer uma pergunta a respeito de um problema que está me incomodando bastante. Estou fazendo um programa em python 3 que pega um arquivo Fasta e faz uma lista das “extensões” das sequências genômicas. O problema é que numa parte do código, mais precisamente nessa função, eu não consigo fazer com que o outro for comece para dar o resultado (no caso, a id do maior número, ou seja, do de maior extensão na sequência genômica). O primeiro for fica num looping eterno e eu não sei tirar ele disso.

def identifiers():
  lista = ()
  for record in SeqIO.parse(fasta, "fasta"):
    lista.append(len(record))
  for record in SeqIO.parse(fasta, "fasta"):
    if len(record) == lista_sort(-1):
      print(record.id)

Alguém sabe como solucionar isso?

loop – Why is my archive page looping through all but one post?

I’ve created an archive page for my custom posts, it loops through every one except the first. There is 11 posts overall and I only get 10 on the archive page.

Here is my archive template:

<div class="container">
  <h2 class="entry-title text-center pt-5">Market Place</h2>
  <p class="text-center">Filter providers by service and click on the logos shown below for more information and to contact a representative of the risk solution provider.</p>
  <div class="category-search-box text-center"><?php echo do_shortcode( '(searchandfilter fields="provider,categories")' ); ?></div>
  <div class="row py-5">
    <?php if (have_posts()) : while (have_posts()) :the_post();
          $taxonomy = wp_get_object_terms($post->ID, 'categories');
          $ids = "";

          foreach ($taxonomy as $cat) {
           $ids .= "cat-".$cat->term_id ." ";
         }
        ?>
      <div class="col-6 col-md-4 text-center">
        <div id="provider-archive-boxes" class="provider-archive-box <?php echo $ids; ?>">
          <a href="<?php echo the_permalink();?>"><?php the_post_thumbnail( 'full', array( 'class' => 'img-responsive' ) ); ?></a>
          <p><strong><?php the_title();?></strong></p>
        </div>
      </div>
    <?php endwhile; ?>
    </div>
  <?php endif; ?>
</div>

Here is how I registered the post in the functions.php file:

function provider_setup_post_type() {
    $args = array(
        'public'    => true,
        'label'     => __( 'Providers', 'textdomain' ),
                "public" => true,
                "publicly_queryable" => true,
                "show_ui" => true,
                "show_in_rest" => false,
                "rest_base" => "",
                "has_archive" => 'marketplace',
                "show_in_menu" => true,
                "exclude_from_search" => false,
                "capability_type" => "page",
                "map_meta_cap" => true,
                "hierarchical" => true,
                'rewrite' => array('slug' => 'marketplace'),
        'menu_icon' => 'dashicons-building',
                "supports" => array( "thumbnail","post-thumbnail","title", "editor" ),
    );
    register_post_type( 'provider', $args );

        register_taxonomy("categories", array("provider"), array("hierarchical" => true, "label" => "Categories", "singular_label" => "Category", "rewrite" => array( 'slug' => 'marketplace', 'with_front'=> false )));
}
add_action( 'init', 'provider_setup_post_type' );

Looping through a SharePoint List to compare a field value with another List Item ID in Powershell

I have two Lists. A Calendar Lists and a Custom List
In one List I have multiple records all with an ‘EventID’ field which relates to a Calendar record (The record ID)

I am trying to use PowerShell to recurse through each Custom List record and check to see if the ‘EventID’ has a relating ‘Calendar ID’ in the Calendar record. If not, it means the Calendar entry has been deleted and the ‘Orphaned’ field in the Custom List record should be set to ‘YES’. There may be multiple records in the Custom List per Calendar Entry. I need to update ALL records WITHOUT a valid Calendar Entry to ‘Orphaned’.

Although not finished, so far I have this code, but I’m sure there must be a better way to do this, and a different way so that once a MISSING ‘EventID’ is found (the Calendar entry is deleted) then the loop stops and moves on to the next Calendar entry. My mind has just gone blank.

cls
#Add Snapin
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue

Start-Transcript -Path "D:SharePointScriptsEmailTranscript.txt"

#Set Variables
$spWeb = Get-SPWeb -Identity "http://ds.stylus.com"
$PClist = (Get-SPWeb "http://ds.stylus.com").Lists("PreventionCalendar")
$DElist = (Get-SPWeb "http://ds.stylus.com").Lists("DirectEngagement")
$DEvID = "EventID"
$DEvStatus = "Status"

#Get Today's Date - var: $now
$now = Get-Date 
Write-Host "Today is:" $now

$PCitems = $PClist.Items
#show the item count for the library
Write-Host "PreventionCalendar - Total Records: $($PCitems.count)"

$DEitems = $DElist.Items
#show the item count for the library
Write-Host "DirectEngagement - Total Records: $($DEitems.count)"

if($PCitems.count -lt 1)
{
    foreach($item in $DEitems)
    {   
       $DEID = $item.ID
       #Get the DE Status value
       $DEvStat = $item($DEvStatus)
       #Get the DE EventID value
       $DEvIDent = $item($DEvID)           
                
       Write-Host "PreventionCalendar is Empty. Orphan Appliance"
       $SPListItem = $DElist.GetItemById($DEID)
       $SPListItem("Status") = "Appliance Orphaned"
       $SPListItem.Update()
     }
}
elseif($PCitems.count -ge 1)
{

    foreach($item in $DEitems)
    {
        $DEID = $item.ID
        #Get the DE Status value
        $DEvStat = $item($DEvStatus)
        #Get the DE EventID value
        $DEvIDent = $item($DEvID) 

        Write-Host -Foregroundcolor Green "Checking..... Appliance ID:" $DEID "EventID:" $DEvIDent 

            foreach($item in $PCitems)
            {
                $PCID = $item.ID
                Write-Host -Foregroundcolor Red "IF 'EventID'" $DEvIDent "EQUALS 'CalendarID'" $PCID "run.." 
                
                if($DEvIDent -eq $PCID)
                {
                    Write-Host "Appliance ID:" $DEID "EventID:" $DevIDent "Matched with PreventionCalendar ID:" $PCID
                    {break}
                }
                else
                {
                    Write-Host "Appliance ID:" $DEID "EventID:" $DevIDent "PreventionCalendar ID: No Match Found"
                }
            }
            
        
        
                
     }          
                
                
}

Write-Host "Orphaned Appliances Updated"

Any help would be appreciated.

Rick

8 – Looping through an array using Migrate Plus

I’m trying to loop through an array (called “Attributes”) in a JSON migration source, but I can’t figure out how to do it. Here’s a shortened sample of my data source:

(
  {
    "Id": "ST00000002",
    "Title": "Fast & Furious 9",
    "Attributes": (
      "0000000013",
      "0000000015"
    )
  }
)

My ultimate goal is to check certain checkbox/boolean fields based on those attribute values, but I can’t figure out how to handle each of the attributes individually.

Things I have tried so far:

  • Using single_value and multiple_values
  • Using the custom Deepen process plugin (as seen on this issue)
  • Using sub_process
  • Using the static_map plugin (to do something like this:
map:
    '0000000015': 1
default_value: 0

I feel like this can’t possibly be as difficult as I’m making it, so I hope someone can help me out. Thank you so much.

mojave – keynote first slide and looping automatically

I’m using keynote 8.2 and have the show working just fine showing 218 slides automatically. But I do not want it to auto start. I want the the first slide displayed until triggered, and then I want it to play through until it’s back to the first slide and want it to stop there until triggered. Any help appreciated!

looping – How can I replace a set of Nested For Loops with a Functional Code Alternative?

Despite having looked over various posts concerning optimizing nested For loop expressions into a functional programming equivalent I still can not figure out how to actually to do this. Such constructs are inefficient in Mathematica and hence, I seek to find a more efficient approach. Sadly, having started with programming with FORTRAN (prior to IV), some ideas die hard in an aging brain.

I have a very large array that I must evaluate. This array m, is 31×2754, but for purposes of example I have down-sampled so that it is only a 30 x 32 matrix. It produces a square matrix whose order is the size of the columns (here 32, when downsampled, but 2754×2754 when fully sampled). Although a doubly nested set of For loops provides the answer I seek and is relatively efficient when the matrix is only 32×32, it’s efficiency degrades rapidly as n approaches 2754. I am at a loss to how to convert the following procedural code snippet into a functional programming equivalent that is more efficient.

The test input (ignoring how I get there, which itself is rather complicated) is:

m = {{0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 
      0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
      0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 
      0}, {1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0,
      0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
      0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
      0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0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 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 
      0}, {0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1,
      0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 
      0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 
      0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0,
      0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 
      1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1}}

 Dimensions(m)

 {30, 32}

Although not essential, to be sure that the output is properly created I create
a constant array and fill the matrix c, which will be the eventual output matrix
with a value that WILL NOT be present in the matrix upon completion, so that by
quick observation I can be sure that the matrix has been properly populated.

This is done as follows and establishes the order of the square matrix, where the length of columnlabels for this snippet is 32 (the actual column labels are irrelevant
here):

 c = ConstantArray(3, {Length(columnlabels), Length(columnlabels)});

 {characterrows, charactercolumns} = Dimensions(c)

The loop construct I wish to replace with a functional approach effectively compares two column of m, each of which has only two distinct values (either 0 or 1), and for which their product partial order potentially generates 4 distinct possibilities (vertices) ({0,0},{1,0},{0,1},{1,1}} and for which I want to assign to the each pair of columns a 1 if less than 4 of these possibilities are actually present in the comparison and a 0 if all 4 possibilities are present when comparing the two columns). This construct is as follows:

 t0 = AbsoluteTime();

 For(i = 1, i <= Length(columnlabels), i++,
    For(j = 1, j <= Length(columnlabels), j++,
       f = m((All, i));
       g = m((All, j));
       c((i, j)) = If(Length(Tally(Table({g((n)), f((n))}, {n, 1, Length(g)}))) < 4, 1, 0);
    )
 )

 t1 = AbsoluteTime();
 timeelapsed = UnitConvert(Quantity(t1 - t0, "Seconds"), "Minutes")

What is the most efficient functional programming expression needed to replace this nested set of For loops?

virtualhost – site looping redirection in apache2

Here is a site i recently tried to setup.. when i try to access it for some reason it always redirects back and forth www to non www without end. Here is my apache2 virtual host.. i really can’t figure out why this is happening.. i only set the A record to point to my server IP address

<VirtualHost *:80>

    ServerAdmin aditya@siral.marketing
    ServerName siral.marketing
    ServerAlias www.siral.marketing
    DocumentRoot /var/www/smartpanel

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory /var/www/smartpanel>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Require all granted
    </Directory>

</VirtualHost>

Looping through all the functions defined in Mathematica

Is there a way to loop through all the functions (elementary and special functions) that exist in Mathematica?

I want to build a table of some identities and maybe I can discover something surprising if I connect all the functions that are in my formula.

That is to say. I want to do something like:

for function in Mathematica
print function(x)^2

(Note that this is not the Mathematica syntax, but I hope you understand the idea)

Thanks Michał

procedural programming: codes run without looping but not looping

I have three nested For I also have loops Monitor wrapped around the outermost loop so you can see how many indexing variables have passed.

However, when I run I can see that the index is stuck on {1, 1, 1}. Also, I know the code inside the loop works if I remove it from the loop and use specific values ​​for the indexes. Even more, I have the same Monitor and For loops wrapped around a different piece of code and that works fine. The code is too long to post here. I am completely confused