Put JSON data into HTML elements

I want to put values from a JSON object into HTML elements.
If I break this down into steps, I think I know the first two steps, but then I am lost

  1. get the html elements into javascript objects using a loop and selectors
  2. get the values of the JSON properties one by one using a for…in loop

I am already at a stumbling block in step 1, as I don’t know how to select by ID when iterating over the set of elements.

I would like help to understand the steps I need to define for this task, as well as any advice about which functions to use.

This is the JSON :

var sonnet_1 = { 
    line_1 : "FROM fairest creatures we desire increase", 
    line_2 : "That thereby beauty's rose might never die", 
    line_3 : "But as the riper should by time decease,",    
    line_4 : "His tender heir might bear his memory:", }

Here is the HTML:

<p id = "1"></p>
<p id = "2"></p>
<p id = "3"></p>
<p id = "4"></p>

Step 1 ) I have tried this

First, tested a single query

document.getElementById('1');

OK. output: <p id ="1"></p>

for (i= 0; i< 14 ; i++) {
        var line = document.getELementById('i');
        console.log(line);
    }

I am expecting output:

<p id ="1"></p>
<p id ="2"></p>
...

But instead this doesn’t log anything.

Step 2)

Tried this :

console.log(`${sonnet_1(line)}`);

Output: FROM fairest creatures we desire increase

All good!

The this:

for (line in sonnet_1) {    
        console.log(`${sonnet_1(line)}`);
    }

Again all good.

Then this:

for (line in sonnet_1) {    
        document.getElementById(`${line}`).innerHTML = `${sonnet_1(line)}`;
    }

I think I need an embedded loop. Is this correct?

No luck.

Any help much appreciated.

simplifying expressions – How to put numerator and denominator in a canonical form?

So I have the following expression that I obtained after some computation:

TDiscrete=-(R2/(R1 tauC^2 (R2/(R4 tauC^2) + (CC2 R2 (1 - y^2))/(
    CC1 R3 tauC^2 y) + (CC2^2 (1 - y^2)^2)/(CC1^2 tauC^2 y^2))))

Now I want that Mathematica displays this in a canonical form, meaning, has a fraction of two polynomials dependent on y. Any idea on how to do that?

dnd 5e – As a sword-and-board Eldritch Knight fighter, do I need to put away my sword on my turn if I want to cast the Shield spell as a reaction?

You cannot cast shield without a free hand.

Shield has somatic components, and the rules for somatic components say:

Spellcasting gestures might include a forceful gesticulation or an intricate set of gestures. If a spell requires a somatic component, the caster must have free use of at least one hand to perform these gestures.

Without Warcaster, you must free up one of your hands somehow in order to cast shield, which have you have observed, probably means dropping your sword.

A generous (evil?) DM may allow you to drop your sword off-turn.

This answer cites an unofficial tweet from rules designer Jeremy Crawford that states that dropping a weapon is not intended to take any action. There are no rules for dropping a weapon, so a generous DM may rule that you can drop your sword to cast shield. But it is up to the DM to allow this or not.

As NautArch mentioned in the comments, this is probably a terrible idea since your enemy can pick up your sword. But maybe this isn’t too big of a deal – if it is your weapon bond sword you can summon your sword back to your hand next turn, albeit at the cost of a bonus action.

How to best put many images on Google Sheets?

I need to put a lot of images on my Google Sheet but that makes the file so big. What I want is to put a link or something which can redirect us to another window which contains all the images.

Word Cloud I will put your words into shapes. for $10

Word Cloud I will put your words into shapes.

I have been producing these pictures for years to clients all over the world. I ALWAYS take pride in what I do and make sure that the picture is exactly what you asked for as I thoroughly enjoy making them.

.

My list of songs from iTunes file changes when I put them on Garageband

I do not want Garageband to put my songs in alphabetical order but left in the order I had them. How do I get them to stay in the same order I had them?

dnd 5e – As a sword and board Eldritch Knight do I need to put away my sword on my turn if I want to use Shield as a reaction?

You cannot cast shield without a free hand.

Shield has somatic components, and the rules for somatic components say:

Spellcasting gestures might include a forceful gesticulation or an intricate set of gestures. If a spell requires a somatic component, the caster must have free use of at least one hand to perform these gestures.

Without Warcaster, you must free up one of your hands somehow in order to cast shield, which have you have observed, probably means dropping your sword.

A generous (evil?) DM may allow you to drop your sword off-turn.

This answer cites an unofficial tweet from rules designer Jeremy Crawford that states that dropping a weapon is not intended to take any action. There are no rules for dropping a weapon, so a generous DM may rule that you can drop your sword to cast shield. But it is up to the DM to allow this or not.

As NautArch mentioned in the comments, this is probably a terrible idea since your enemy can pick up your sword. But maybe this isn’t too big of a deal – if it is your weapon bond sword you can summon your sword back to your hand next turn, albeit at the cost of a bonus action.

buttons – Where is the best place to put the export/upload function for a data table function?

Gestalt laws of proximity would suggest you go with version 2.

Since in your design, tabs delineate different data groupings (each with their own conditions for export), the closer the action is the object (the data set under the tab), the more related they appear.

From the Nielsen Norman Group: Closeness of Actions and Objects in GUI Design

One of the oldest principles of human-computer interaction is that things that are close together on the screen are seen as related.

linux – Optimal way to create mdadm raid 1 on USB adapter and then put it into slot on motherboard

I’m looking for the optimal way how to perform the task.

On one of my debian servers:

  1. I have 2xSSD connected via USB adapter (no free ports on motherboard)
  2. I need to create RAID 1 MDADM array (2USB disks) and copy data from existing HDDs
  3. Existing HDDs (not system part) will be replaced by the new 2xSSD array

I have no problem with creating MDADM arrays on USB. The question is rather will the array still work after moving those disks from USB do actual motherboard slots and how /etc/mdadm.conf shall be populated in this case. For sure identifiers sdg,sdi will change.

A glimpse of my current mdamd.conf

# definitions of existing MD arrays
ARRAY /dev/md/0  metadata=1.2 UUID=4639c0f2:e1070742:73fa5cdf:2cd5a5cb name=debian:0

# This configuration was auto-generated on Wed, 27 Dec 2017 20:35:27 +0100 by mkconf
ARRAY /dev/md1 metadata=1.2 name=debian:1 UUID=224292b7:3d065ef2:1e2178cc:3006f7c9

And sample mdadm config (here I see drive indentifiers by drive letters)

md1 : active raid1 sdc2(0) sdd2(2)
      1465291776 blocks super 1.2 (2/2) (UU)
      bitmap: 0/11 pages (0KB), 65536KB chunk

md0 : active raid1 sda2(0) sdb2(2)
      249925632 blocks super 1.2 (2/2) (UU)
      bitmap: 2/2 pages (8KB), 65536KB chunk

Thanks!

linux – Where should I put a log file from my web application running as non-root user?

I make server applications in C# / .NET Core. They are both web applications and WebSocket services. I use Apache as reverse proxy to make them accessible from the Internet and to provide SSL certificates for them.

Apache can redirect STDOUT and STDERR to log files in /var/log directory, however, the logging in my application should go to the console, and it’s not what I want.

I want to handle logging to log files directly, to have full control over the rolling log files.

The problem is – my applications don’t write logs in /var/log. They just don’t. IDK why. I get no error messages whatsoever, logs generated by Apache are empty. The log files from my applications are not created. I suspect it’s because my applications are run on www-data account, and www-data user have no write access to /var/log directory on the server. My logging library (Serilog) is smart enough not to crash the application if it can’t write logs, so it just doesn’t write logs when it can’t, leaving the application in working state. Apache generated logs are empty, because I removed most of the writing to the console from my app, everything is handled by the logger module.

What is the best solution?

I can run my application as root, but it doesn’t look safe or even a right thing to do.

On Windows I could make a directory writable for a specific user or group, but IDK if it’s possible on Linux. Well, it shouldn’t be, because it would also not be very good for the overall system security. I mean – there would be another way for the user to shoot himself in the foot 😉

I can create a new directory owned by www-data in the directory with application, like /var/www/my-app/logs. This seems like the easiest choice, but is it “industry standard”?
Another approach is to create the directory within /var/log like /var/log/my-app. This looks tempting.

As a Linux noob I’m asking you, Linux guys, which is better? App directory, subdirectory of /var/log with owner www-data or… Other special directory?