javascript: find the size of the elements that fit a certain width

This is a follow-up of resizing the elements until the father reaches a certain height

The purpose of the function is to find a size for the elements within a primary element, so that they all fit into a single row. I tried it with a loop (check the previous question), and now I changed it to if statements. However, I would like to simplify it, but I can't find how. The size of the elements does not have to be exactly as they are now. The default size is width: 10px; height: 10px; margin: 5px 7px, which is a total of 24px large.

function _AdjustHeightOwlDots() {
    const thisElementId = 'owl-carousel-{{!}}';
    const dotRowWidth = $(`#${thisElementId} .owl-dots`).width();
    const amountOfDots = document.querySelector(`#${thisElementId} .owl-dots`).childElementCount;
    const singleDotWidth = $(`#${thisElementId} .owl-dots > button`).width();

    if ( (singleDotWidth * amountOfDots) < dotRowWidth ) { // dots fit in single row
      let maxDotWidth = Math.floor(dotRowWidth / amountOfDots);
      const setNewStyle = function(hw, margin) {
        $(`#${thisElementId} div.owl-dots > button > span`).css('width', `${hw}px`);
        $(`#${thisElementId} div.owl-dots > button > span`).css('height', `${hw}px`);
        $(`#${thisElementId} div.owl-dots > button > span`).css('margin', `5px ${margin}px`);
      if (maxDotWidth % 2 === 1) {
        maxDotWidth -= 1;

      // A/B
      // width = Apx
      // height = Apx
      // margin = 5px Bpx

      if (maxDotWidth <= 3) {
        // set to 1/1
        setNewStyle(1, 1);
      } else if (maxDotWidth === 4) {
        // set to 2/1
        setNewStyle(2, 1);

      } else if (maxDotWidth === 6) {
        // set to 2/2
        setNewStyle(2, 2);

      } else if (maxDotWidth === 8) {
        // set to 4/2
        setNewStyle(4, 2);

      } else if (maxDotWidth === 10) {
        // set to 4/3
        setNewStyle(4, 3);

      } else if (maxDotWidth === 12) {
        // set to 6/3
        setNewStyle(6, 3);

      } else if (maxDotWidth === 14) {
        // set to 6/4
        setNewStyle(6, 4);

      } else if (maxDotWidth === 16) {
        // set to 8/4
        setNewStyle(8, 4);

      } else if (maxDotWidth === 18) {
        // set to 8/5
        setNewStyle(8, 5);

      } else if (maxDotWidth === 20) {
        // set to 10/5
        setNewStyle(10, 5);

      } else if (maxDotWidth === 22) {
        // set to 10/6
        setNewStyle(10, 6);

dnd 5e: Does the element that applies the Replicate Magic element infusion change its shape to fit the magic element you chose?

The characteristic of the Infuse element of the architect says (E: RftLW, p. 57; the emphasis is mine):

On the second level, you get the ability to imbue worldly items with certain magical infusions (…) Every time you finish a long break, you can touch a non-magical object and imbue it with one of your infusions of the architect, turning it into a magical object. An infusion works only on certain types of objects, as specified in the description of the infusion.

The Artificial Infusions section at the end of the class description says (E: RftLW, p. 61; my emphasis):

The description of each of the following infusions. the type of item that can receive it, along with whether the resulting magic item requires tuning.

And finally, the infusion states of Replicate Magic Item (E: RftLW, p. 63; emphasis is mine):

In tables, the input of an element tells you if the element requires tuning. See the description of the article in the Dungeon Master's Guide for more information about it, including The type of object required for its manufacture.

if you have Xanathar's guide to everything, you can choose among the common magic items in that book when you choose a magic item that you can replicate with this infusion.

Each of these parts in bold makes it clear that you need a non-magical version of the element to infuse, whether you are using Replicate magic item or one of the other infusions of architects.

In the case of your example, the description of discarded armor state:

Armor (light, medium or heavy)common

Therefore, you need a non-magical version of any type of armor that you want to convert discarded armor. If you want discarded half plate armor, you need a non-magical set of half-plate armor to permeate that infusion. The Infusion Replica Magic Object does not create a magical object from an air thing: it gives you the ability to imbue a certain mundane version of that object with the magic necessary to function as that magical object.

Fit – How to adjust a curve with noise in Mathematica

I have a 1D signal vector that shows the following behavior. After an exponential decrease, it becomes a totally white noise (or noise mixtures).

enter the description of the image here

How can I use Mathematica extra the true noise signal and learn the type of noise (a single Gaussian noise or a mixture?) Does it also fit the signal curve (potentially exponentially distributed)?

fit: find a differential equation of the data set

I am trying to fit a differential equation to a large data set, but I am not achieving anything.

This is my data set.
enter the description of the image here

and my differential equation / model is


I tried to solve it with ParametricNDSolveValue without good results.

Drivers: Does the RX590 and Ubuntu 19.10 graphics card not fit?

I am a user of the RX590 graphics card. I recently tried to install Ubuntu 19.10 on my computer, but it doesn't proceed beyond the black screen. However, the black screen does not appear in Safe Graphis mode.

But install it in Safe Graphis mode, since Safe Graphics mode is released when the installation is complete, nothing can be seen on the screen.

During installation, the console displays a warning phrase, VGA or an error related to graphics.
_ _

Q. Does the RX590 and Ubuntu 19.10 graphics card not fit? Is there any way?

For your information, I made a bootable USB and proceeded with the installation.

system agnostic: save a character that does not fit at the party

I have been playing in a Warhammer campaign for about 7 months with my friends.

I created a character that I thought would be interesting for me, since I planned to play it for a long time and wanted to have some possibilities for him to develop his personality along the way. He was on the side of thought, he was not a great fighter, but he had a very high self-esteem, but he was totally unable to understand any form of sarcasm.
It turned out that I loved playing this character, and the campaign continued and we had a great time.

But recently, we got into a situation where we had to infiltrate a place, and while one of my friends and I were trying to find a way to remain undetected, one of the others (who plays a really reckless halfling ) he went crazy. Jenkins and decided to jump from one roof to another, followed directly by the other friend (a brave gentleman). They saw us, quickly surrounded us with enemies and captured us.

For the moment, I got mad at them, so when I realized, I decided to keep my mouth shut. For the moment, I really thought they were ruining my fun and that this should be addressed. But then I thought that I could do it by forcing them to plan and organize things as my character would.

So, the decision I made was to make my character leave, since he had no confidence in his group. He didn't fit in there with his mentality, while the others got along very well. I was a little sad to have to leave this character that I loved to play, but I didn't see any other solution and decided to create a character that would be a better combination for the team in terms of behavior.

So here is my question: could I have "saved" my character from leaving the party? And if so, how?

tracing: why does the slope of my linear fit the incorrect sign of my data?

data = {{Sin(21*2*Pi/360), 587.6}, {Sin(339.5*Pi/180), 
   587.6}, {Sin((360 - 342.5)*Pi/180), 501.5}, {Sin(18*Pi/180), 
   501.5}, {Sin((360 - 343.8)*Pi/180), 471.3}, {17.8*Pi/180, 
   471.3}, {Sin(16.6*Pi/180), 438.8}, {Sin((360 - 343)*Pi/180), 
   438.8}, {Sin(19.6*Pi/180), 546.1}, {Sin((360 - 341)*Pi/180), 
   546.1}, {Sin(15.5*Pi/180), 435.8}, {Sin((360 - 345)*Pi/180), 
   435.8}, {Sin(20.9*Pi/180), 579.0}, {Sin((360 - 339.9)*Pi/180), 
   579.0}, {Sin((360 - 343)*Pi/180), 491.6}, {Sin(17.8*Pi/180), 

Yes data is numbered as


{{0.358368, 587.6}, {-0.350207, 587.6}, {0.300706, 501.5}, {0.309017,
501.5}, {0.278991, 471.3}, {0.310669, 471.3}, {0.285688,
438.8}, {0.292372, 438.8}, {0.335452, 546.1}, {0.325568,
546.1}, {0.267238, 435.8}, {0.258819, 435.8}, {0.356738,
579.}, {0.34366, 579.}, {0.292372, 491.6}, {0.305695, 491.6}}

We can see that the second point is a fairly extreme value in the data. Fit Of course it includes this point in the adjustment, which gives the negative slope.

If we ignore the outlier with

DeleteCases(N@data, {x_?Negative, _})

{{0.358368, 587.6}, {0.300706, 501.5}, {0.309017, 501.5}, {0.278991,
471.3}, {0.310669, 471.3}, {0.285688, 438.8}, {0.292372,
438.8}, {0.335452, 546.1}, {0.325568, 546.1}, {0.267238,
435.8}, {0.258819, 435.8}, {0.356738, 579.}, {0.34366,
579.}, {0.292372, 491.6}, {0.305695, 491.6}}

Then we get the expected result.

Fit(DeleteCases(N@data, {x_?Negative, _}), {1, x}, x)

-15.0492 + 1675.17 x

  ListPlot(data, PlotRange -> Full), 
    Evaluate@Fit(DeleteCases(N@data, {x_?Negative, _}), {1, x}, x),
    {x, 0.2, 0.4}

enter the description of the image here

Object-oriented design: what abstraction should fit in the following scenario?

.NET provides several methods to create Memory mapped files. There are many static methods in MemoryMappedFile class that gives options to create the MemoryMappedFile from a file or simply a block of memory not backed by any file with many other options such as security indicators for memory, heritability, etc. All the different creation methods are here: dotnet / api / view = netframework-4.8

I want to create an interface that can handle different creation scenarios, but there are so many options that it seems impossible to have a generic interface. This makes me think that creating an interface is not useful in this case, but at the same time we should code the interfaces.

How can I design the solution to be flexible? The builder pattern does not seem to work in this case because eventually in the build() function we will have to call one of the static methods in the MemoryMappedFile class and this build() the function will be ruined with many if-else spaghetti. What design pattern could best fit here?

unity – Render Mode "Screen Space – Camera" inflates the prefabricated buttons so that they no longer fit on the canvas, help

When referring to a previous publication (link) and when using the solution, I found a situation that I do not understand when when I set the canvas in "Screen space – Camera" instead of "Screen space – Overlay" as it has Having set the original post, my buttons in the context menu inflate to a size that is larger than the canvas itself. I try to manually change the size of the prefabricated button to a reasonable size, however, it seems that the width will not allow me to modify it. And changing the rendering to Overlay itself will require a good amount of reworking of existing assets for things to work properly.

So my question is this, what does it take to keep the "Screen space – Camera" as the rendering mode, but still have the size of the buttons accordingly?

Paste previous content for reference:

Create content panel
(This panel will be a container for our context menu buttons)

Create new UI panel
Set the anchor in the lower left
Set the width to 300 (as desired)
Add a new Vertical Design Group component to a panel and set Secondary alignment in the upper center, Expand secondary force to width (not height)
Add a new Content Size Fitter component to a panel and set Vertical Fit to Min Size
Save it as prefabricated
(At this point, our Panel will be reduced to one line. It is normal. This panel will accept buttons as secondary elements, align them vertically and stretch to the height of the summary content)

Create sample button
(This button will be instantiated and customized to show context menu items)

Create new UI button

Set the anchor in the upper left corner
Add a new component Design element to a button, set Minimum height to 30, Preferred height to 30

Save it as prefabricated

Create ContextMenu.cs script

(This script has a method that creates and displays the context menu)

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ContextMenuItem
    // this class - just a box to some data

    public string text;             // text to display on button
    public Button button;           // sample button prefab
    public Action action;    // delegate to method that needs to be executed when button is clicked

    public ContextMenuItem(string text, Button button, Action action)
        this.text = text;
        this.button = button;
        this.action = action;

public class ContextMenu : MonoBehaviour
    public Image contentPanel;              // content panel prefab
    public Canvas canvas;                   // link to main canvas, where will be Context Menu

    private static ContextMenu instance;    // some kind of singleton here

    public static ContextMenu Instance
            if(instance == null)
                instance = FindObjectOfType(typeof(ContextMenu)) as ContextMenu;
                if(instance == null)
                    instance = new ContextMenu();
            return instance;

    public void CreateContextMenu(List items, Vector2 position)
        // here we are creating and displaying Context Menu

        Image panel = Instantiate(contentPanel, new Vector3(position.x, position.y, 0), Quaternion.identity) as Image;
        panel.rectTransform.anchoredPosition = position;

        foreach(var item in items)
            ContextMenuItem tempReference = item;
            Button button = Instantiate(item.button) as Button;
            Text buttonText = button.GetComponentInChildren(typeof(Text)) as Text;
            buttonText.text = item.text;
            button.onClick.AddListener(delegate { tempReference.action(panel); });

Attach this script to a Canvas and complete the fields. Drag and drop the prefabricated ContentPanel to the corresponding space, and drag Canvas to the Canvas slot.

Create ItemController.cs script

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class ItemController : MonoBehaviour
    public Button sampleButton;                         // sample button prefab
    private List contextMenuItems;     // list of items in menu

    void Awake()
        // Here we are creating and populating our future Context Menu.
        // I do it in Awake once, but as you can see, 
        // it can be edited at runtime anywhere and anytime.

        contextMenuItems = new List();
        Action equip = new Action(EquipAction);
        Action use = new Action(UseAction);
        Action drop = new Action(DropAction);

        contextMenuItems.Add(new ContextMenuItem("Equip", sampleButton, equip));
        contextMenuItems.Add(new ContextMenuItem("Use", sampleButton, use));
        contextMenuItems.Add(new ContextMenuItem("Drop", sampleButton, drop));

    void OnMouseOver()
            Vector3 pos = Camera.main.WorldToScreenPoint(transform.position);
            ContextMenu.Instance.CreateContextMenu(contextMenuItems, new Vector2(pos.x, pos.y));


    void EquipAction(Image contextPanel)

    void UseAction(Image contextPanel)

    void DropAction(Image contextPanel)

Create a sample object in the scene (i.e., Cube), place it to be visible to the camera and attach this script to it. Drag and drop prebuilt sampleButton to the corresponding slot.

Receptive tables: adjust the row count to fit the available space

I am designing a screen with tabular data and trying to explain to the developers what is required. First of all, I want to make sure that my design is feasible.

My objective is …

  1. Have tabular data on the screen, including filters and paging.
  2. Filters should be at the top and near the header row
  3. The header row should always be visible.
  4. The pagination control should always be visible near the bottom row shown
  5. Row height is set at 36px

So, for responsiveness, this leaves only the number of rows shown as a variable. If there is space to display only three rows while all mandatory controls are visible, only three rows will be displayed. If the same is represented on a larger screen and there is room for 25 rows, show 25. The user should always be able to expect that the mandatory controls are approximately in the same place, regardless of the size of the property.

So, do you have any examples of this that I can send to the development team?

Thank you