Update UI when pushing new object to an array attribute

In one of my blocks I’m using an array of cards so that a user can add multiple cards to a block without having to use nested blocks and complicate the HTML.

The attributes look like this:

attributes: {     cards: {         type: 'array',         source: 'query',         selector: '.staff-list-item',         default: [],         query: {             name: {                 type: 'array',                 source: 'children',                 selector: 'h3',                 default: 'Enter name.',             },             title: {                 type: 'array',                 source: 'children',                 selector: 'p',                 default: 'Enter title.',             },             mediaID: {                 type: 'number',                 source: 'attribute',                 attribute: 'data-id',                 selector: 'img',             },             mediaURL: {                 type: 'string',                 source: 'attribute',                 attribute: 'src',                 selector: 'img',             },         },     }, } 

I then have a button component that can add one of these cards:

el(components.Button, { className: 'button button-large', onClick: onAddCard }, 'Add Card') 

And the function it calls is:

function onAddCard() {     return props.attributes.cards.push({         name: 'Enter name.',         title: 'Enter title.'     }) } 

So I basically push a new object into the cards… however what I’ve found is that even though I’m returning the objects… it doesn’t update the UI until I click OUT of the block… how can I get it to work similar to setAttributes?

I even tried:

props.attributes.cards.push({     name: 'Enter name.',     title: 'Enter title.' })  return props.setAttributes( {     cards: props.attributes.cards }); 

FunctionCompile returns Part::partd: Part specification 151345[[1]] is longer than depth of object

Today, I install mathematica 12.3 on my computer(windows), then I run the FunctionCompile code

cf = FunctionCompile[Function[Typed[arg, "MachineInteger"], arg + 1]] 

but it goes wrong, and return the information

Part::partd: Part specification 151345[[1]] is longer than depth of object 

I test on my another computer, FunctionCompile works well, so what’s happening here?

customise JSON object of a block

A simple wp block:

<!-- wp:video {"id":155742} --> <figure class="wp-block-video"><video controls src="http:vidoe.mp4"></video></figure> <!-- /wp:video --> 

How to achieve something along those lines:

<!-- wp:video {"id":155742, "poster_id":155654 } --> <figure class="wp-block-video"><video controls src="http:vidoe.mp4"></video></figure> <!-- /wp:video --> 

I’ve been going through many articles on adding custom attributes to blocks but can’t find reference to modify the JSON object that is included in the HTML comment that WP adds to blocks. Is there a hook to modify the JSON object?

How to get count of an object, through 3 different tables in postgres with ID’s stored in each table

I’m currently using Postgres 9.6.16.

I am currently using 3 different tables to store a hypothetical users details.

The first table, called contact, this contains:

ID, Preferred_Contact_Method 

The second table, called orders, This contains:

ID, UserID, Contact_ID (the id of a row, in the contact table that relates to this order) 

The Third Table, Called order_details

ID, Orders_ID (the id in the orders table that relates to this order details) 

The tables contain other data as well, but for minimal reproduction, these are the columns that are relevant to this question.

I am trying to return some data so that i can generate a graph, in this hypothetical store, There’s only three ways we can contact a user: Email, SMS, or Physical Mail.

The graph is supposed to be 3 numbers, how many mails, emails, and SMS we’ve sent to the user; since in this hypothetical store whenever you purchase something you get notified of the successful shipment, these methods are 1:1 to the order_details, so if there’s 10 order_detail rows for the same user, then we sent 10 tracking numbers, and since there can be multiple order_details (each item has a different row in order_details) in an order, we can get the count by counting the total rows of order details belonging to a single user/contact, then attributing to what kind of contact method that user preferred at the time of making that order.

To represent this better: If a new user makes a new order, and orders 1 apple, 1 banana, and 1 orange. For the apple, the user set preferred tracking number delivery as SMS, for the banana, they set it to EMAIL, for the orange, they thought it would be funny to set the tracking number delivery via MAIL. Now, i want to generate a graph to this users preferred delivery method. So i’d like to query all those rows and obtain:

SMS, 1 EMAIL, 1 MAIL, 1 

Here’s a SQL Fiddle link with the schema and test data: http://sqlfiddle.com/#!17/eb8c0

the response with the above dataset should look like this:

method | count SMS,     4 EMAIL,   4 MAIL,    4 

How to spawn an object at a given position and angle?

Let’s say I have an enemy at position ( 150, 150 ) in my screen and I want it to shoot a bullet from its position at an angle of 315° (south-east if we’re cosidering a regular unit circle)…

I’ve tried doing something like this (pseudo-code):

bullet.xpos = enemy.xpos + (cos(315) * bullet.radius )

bullet.ypos = enemy.ypos + (sin(315) * bullet.radius )

The idea is to change the bullet’s position by increasing its radius…

However, the problem with this code is that the angle at wich the bullet gets placed it’s not really the one specified (315° in this case) because of course, the final result going into the bullets position gets influenced by the enemy’s position ( bullet.xpos = enemy.xpos… and bullet.ypos = enemy.ypos… ) but I still need to consider it since it will be the starting point for the bullet.

I might be overlooking something but I’m not sure how to actually do this… Thanks for taking the time

How do I delete a user from the master database when the user has been deleted from the Server Logins using the SSMS Object Explorer

I am using an Azure SQL Database. I deleted some users from a Azure SQL database after I saw them mentioned in a Vulnerability Assessment report. Here’s how I deleted them:

  1. Log in to SSMS
  2. Expand the Object Explorer tree
  3. Expand the ‘Security’ folder
  4. Expand the ‘Logins’ folder
  5. Highlight the user
  6. Right-click and select ‘Delete’

I went back to the Vulnerability Assessment blade and ran a new ‘Scan’ but the users I deleted still show up in the list. The list included SQL code to show that my users still exist. I ran that code back in SSMS in the master database and confirmed my users still exist. Here’s the relevant code:

SELECT * FROM sys.database_principals

When I run the following code, I get an error saying the user does not exist (‘or you do not have permission’ – but I am a server admin so I ruled that out):

DROP LOGIN <username>

How do I get rid of these logins?

Can Mending return an ornamented object to a flawless state?

I have a small hand mirror broken into two. The mirror glass itself was already broken into pieces, but the important part is the ornamented back of the hand mirror, which depicts an encrypted map.

The “tear” is no more than 1 foot, but gathering all the chips from the back of the mirror is impossible. (Imagine you are piecing a broken vase back together. You would end up with a gap that should be filled with small, fine pieces.)

Assuming that those fine chips (from the back of mirror) are lost (no time to retrieve), can Mending repair the back of the mirror to its former state, with the perfect state of the encrypted map?

Unity2D – Rotation of gun following mouse error when parent ‘player’ object rotates

I have a bug I’ve been trying to fix with the rotation of a gun object that follows the mouse position but has issues when the parent object player rotates. Example:

Example of rotation error

The player has a gravity script to keep them aligned with the ‘planet’ as you walk around it. The gun as a child of the player, is supposed to always rotate to point at where the mouse is (sorry you can’t see it in the gif). The gun normally flips itself at 90 and -90 (top and bottom), and flips the player to face the same side the mouse is on.

The problem is that the player rotates to stay aligned with the planet, but the 90 and -90 angles that the gun bases flipping itself and the player off of course don’t rotate.

Here’s my code for the gun:

         Vector3 difference = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;           difference.Normalize();           float rotationZ = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;            float startRotation = rotationZ + offset;            float shotRotation = startRotation + Random.Range(-scatter, scatter);            transform.rotation = Quaternion.Euler(0f, 0f, startRotation);            //Flip the gun at top and bottom           if (rotationZ < -90 || rotationZ > 90)           {               if (player.transform.eulerAngles.y == 0)               {                   transform.localRotation = Quaternion.Euler(180, 0, -rotationZ + offset);               }               else if (player.transform.eulerAngles.y == 180)               {                   transform.localRotation = Quaternion.Euler(180, 180, -rotationZ + offset);               }           }            //Use gun rotation to set player direction           //left           if (rotationZ >= -90f || rotationZ <= 90f)           {               animator.SetFloat("Vertical", 0);               animator.SetFloat("Horizontal", -1);           }           //right           if (rotationZ <= -90f || rotationZ >= 90f)           {               animator.SetFloat("Vertical", 0);               animator.SetFloat("Horizontal", 1);           }