## probability – With what frequency should points in a 2D grid be chosen in order to have roughly \$n\$ points left after a time \$t\$

Say I have a 2D array of $$x$$ by $$y$$ points with some default value, for generalisation we’ll just say “0”.

I randomly select a pair of coordinates with a frequency of $$f$$ per second and, if the point selected is `0`: flip it to `1`. However, if the point is already $$1$$ then do not change it.

How then, given a known $$x$$ and $$y$$ (thus known total points as $$xy$$) can I calculate a frequency $$f$$ that will leave me with approximately (as this is random) $$n$$ `0` points remaining, after a set time $$t$$? Where $$t$$ is also seconds.

For some context I am attempting some simplistic approximation of nuclear half-life but I’m not sure how to make use of the half-life equation for this, nor do I think that it is strictly correct to apply it given my implementation isn’t exactly true to life, picking single points at a time.

## Using CSS, how can I remove a Woocommerce grid from a specific page that has ::before & ::after inserted in it

The specific page ID is 6329

I have tried different variations of the CSS below, but still can’t get it to work!

CSS used:

.page-id-6329 .products.columns-3 {
display: none !important;
}

and other variations on the same lines with no success. I think it has to do with the ::before and ::after, but have no idea how to write the CSS.

I am setting up a website that caters for retail and wholesale. The retail will show the normal category grid to the user, while the wholesale will have a special page where a list of products shown in a table.
The wholesale page, as it is now, shows the category grid AND the table underneath. I just need to get the grid to disappear for that particular page.

Any help will be appreciated.
Thanks

## c – Random walk on a grid

``````// generate a random "walk" of letters from A to Z in a 2D grid, assuming a
// character set with contiguous values of uppercase letters (e.g. ASCII);
// stops if the "walker" gets stuck
// example of a successful walk:

//  A  .  .  .  I  J  K  .  .  .
//  B  C  F  G  H  .  L  .  .  .
//  .  D  E  .  .  .  M  .  .  .
//  .  .  .  .  .  O  N  .  .  .
//  .  .  .  .  .  P  .  .  .  .
//  .  .  .  .  .  Q  .  .  .  .
//  .  .  .  .  .  R  S  .  .  .
//  .  .  .  .  .  .  T  U  .  .
//  .  .  .  .  .  .  .  V  W  Z
//  .  .  .  .  .  .  .  .  X  Y

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <stdbool.h>
#include <ctype.h>

#define GRID_SIZE 10

// movement directions
#define DIR_NUM 4

#define UP      0
#define LEFT    1
#define DOWN    2
#define RIGHT   3
#define ANY     (-1)

bool can_move(int dir, size_t rpos, size_t cpos, size_t rows, size_t cols,
char grid(rows)(cols));
void generate_random_walk(size_t rows, size_t cols, char grid(rows)(cols));
void print_array(size_t rows, size_t cols, char grid(rows)(cols));

int main(void)
{
char grid(GRID_SIZE)(GRID_SIZE) = { 0 };

generate_random_walk(GRID_SIZE, GRID_SIZE, grid);
print_array(GRID_SIZE, GRID_SIZE, grid);

return 0;
}

void print_array(size_t rows, size_t cols, char grid(rows)(cols))
{
for (size_t r = 0; r < rows; ++r) {
for (size_t c = 0; c < cols; ++c) {
char grid_c = grid(r)(c);
printf(" %c ", isalpha(grid_c) ? grid_c : '.');
}
putchar('n');
}
}

// checks all the directions by default (ANY)
bool can_move(int dir, size_t rpos, size_t cpos, size_t rows, size_t cols,
char grid(rows)(cols))
{
bool cangoup    = (rpos > 0) && grid(rpos - 1)(cpos) == 0;
bool cangoleft  = (cpos > 0) && grid(rpos)(cpos - 1) == 0;
bool cangodown  = (rpos < rows - 1) && grid(rpos + 1)(cpos)  == 0;
bool cangoright = (cpos < cols - 1) && grid(rpos)(cpos + 1)  == 0;

switch (dir) {
case UP:    return cangoup;
case LEFT:  return cangoleft;
case DOWN:  return cangodown;
case RIGHT: return cangoright;
default:    return cangoup || cangoleft || cangodown || cangoright; // ANY
}
}

void generate_random_walk(size_t rows, size_t cols, char grid(rows)(cols))
{
size_t rpos, cpos;

srand((unsigned int) time(NULL));

rpos = cpos = 0;
grid(0)(0) = 'A';
for (char c = 'B'; c <= 'Z' && can_move(ANY, rpos, cpos, rows, cols, grid); c++) {
// move in a random direction
for (int dir;;) {
dir = rand() % DIR_NUM;
if (can_move(dir, rpos, cpos, rows, cols, grid)) {
switch (dir) {
case UP:    --rpos; break;
case LEFT:  --cpos; break;
case DOWN:  ++rpos; break;
case RIGHT: ++cpos; break;
default:
printf("Impossible movement direction.n");
exit(EXIT_FAILURE);
}
break; // break out of the loop
}
}

// leave a trail
grid(rpos)(cpos) = c;
}
}
``````

To summarize, this program prints a grid with a random walk of uppercase letters in order. If the “walker” cannot move in any direction due to lack of space around it (up, down, left, and right), the walking terminates.

What I’m interested in, aside from general tips regarding my code that you may be able to give me, are two things:

1. I’ve read that functions shouldn’t normally take more than 2–3 parameters; do you think my functions really “suffer” from taking more than 3 parameters, and if so, how would I go about mitigating that?

2. Should I be using a `size_t` when looping over an array or similar, or should I use an `int` instead? I’ve read here on Stack Exchange various opinions concerning this: some people say `size_t` should always be used since it’s essentially undefined behavior if the array’s size is greater than `MAX_INT`, etc., while others say unsigned and signed types ought not to be mixed (and I generally have to use them in expressions that undergo the usual arithmetic conversions), and this is a major source of bugs. Pragmatically, I believe I should therefore use a regular `int`. There’s another thing I’ve noticed, and that is if I have to actually use these counters to perform some calculation: in those cases I really have no recourse, and what I end up doing is simply casting and praying, hoping that the array is of a reasonable size (i.e. that my `size_t` counter, or the result of the expression isn’t out of the representable range for an `int`). I think this is even worse than using an `int` from the beginning, since the interface that the `size_t` type provides is not conformed to, so my code is “lying” to both itself and the reader.

Note that I would use an `enum` instead of the `#define` definitions for the directions, but my book hasn’t gotten to them yet, so I think we shouldn’t focus on this. Also, I’ve looked at other questions with this same exercise, but the code/approach presented there is somewhat different.

## Chrome Tab Grid Layout can no longer be disabled via chrome://flags, is there another way?

Doing some more research, I find that this is no longer enough

Update: That used to be it, but with the most recent update Google broke this fix, but never fear there is a temporary solution to make it work again.

1. Type “chrome://flags/#temporary-unexpire-flags-m88” into the address bar
2. Tap on the drop-down menu in the Tab Grid Layout entry
3. Select “Enabled”
4. Tap the Relaunch button at the bottom of the screen

I suspect that will only be a temporary solution though.

## Azure Event Hub vs Event Grid or something else?

I have a timer function that calls a group of APIs asynchronously and then converts the XML responses to SQL Server records to an on premises database. I want to send a message in case there is a failure in the response so that I can retry the API call. After reading the documentation for Event Hubs and Event Grids, I’m not sure if either one of those options satisfies my requirement. The following is the documentation I’ve read:

https://docs.microsoft.com/en-us/azure/event-grid/compare-messaging-services

Any insight would be appreciated.

## ag grid angular – AgGrid : How to have a fixed row number that is not affected by sorting

In AgGrid, how to configure to have a fixed row number that is not affected by sorting. Basically I want a “fixed row number” so that when i resort, the row numbers stay in order.

Here is the example that is not working:

https://gypsy-jazz–ranker.firebaseapp.com/

## voxels – How to get normals from volume density grid?

I ended up taking the volume outside point normal and inside point normal and doing a lerp between them, where the lerp value is density float. This is how I get normals from SDF while creating volume gird:

``````float H = 0.001;
float dx = sdfFunc(Vector3(xPos + H, yPos, zPos)) - sdfFunc(Vector3(xPos - H, yPos, zPos));
float dy = sdfFunc(Vector3(xPos, yPos + H, zPos)) - sdfFunc(Vector3(xPos, yPos - H, zPos));
float dz = sdfFunc(Vector3(xPos, yPos, zPos + H)) - sdfFunc(Vector3(xPos, yPos, zPos - H));

float dlen = sqrt(dx * dx + dy * dy + dz * dz);

if (dlen > 0.0) {
float mul = 1.0 / dlen;
dx *= mul;
dy *= mul;
dz *= mul;
}
``````

And when calculating vertices with marching cubes I do something like that:

``````Vector3 nn = Vector3();

nn.X = (1 - t) * an.X + t * bn.X;
nn.Y = (1 - t) * an.Y + t * bn.Y;
nn.Z = (1 - t) * an.Z + t * bn.Z;
``````

where `an` is inside point and `bn` is outside point normal and `t` is calculated density float (vertex place along he edge).

## Add Grid in widget form magento2

Can i add grid template to custome widget magento2 ? I have an Blog menu in admin panel magento2 and i want to create an custom widget for this menu manage post here, purpose of this widget is i add some config in form and need an grid to check some posts to your slider.Give me some idea, it’s not a proplem.Tks!

## plotting – Why are my polar grid lines limited by the maximum radial value?

I am wondering why the displayed polar grid lines are limited by the maximum plotted value (see minimal example below) – is it possible to show polar grid lines beyond the largest radial value?

Thanks and Best,
Tim

``````{ListPolarPlot({{(Pi)/4, 0.5}}, PlotRange -> {{-1, 1}, {-1, 1}},
PolarGridLines -> {Range(0, 2 (Pi), 2 (Pi)/24), Range(0, 1, 0.1)}),
ListPolarPlot({{(Pi)/4, 0.8}}, PlotRange -> {{-1, 1}, {-1, 1}},
PolarGridLines -> {Range(0, 2 (Pi), 2 (Pi)/24),
Range(0, 1, 0.1)})}
``````