## sql server – Sqlserver backup problem – 2 programs, Diff and Log out of sync

I am running encrypted backup on Sqlserver 2017.

Doing a test restore, it failed

RESTORE DATABASE (test) FROM DISK =
N’DPH-DD-SLI-001SLI_SQL_BackupsEncryptedDPH-SQL-SLI-12PBTBLEADFULLDPH-SQL-SLI-12P_BTBLEAD_FULL_20201021_185145.bak’
WITH NORECOVERY, REPLACE;

RESTORE DATABASE (test) FROM DISK =
N’DPH-DD-SLI-001SLI_SQL_BackupsEncryptedDPH-SQL-SLI-12PBTBLEADDIFFDPH-SQL-SLI-12P_BTBLEAD_DIFF_20201022_071002.bak’
WITH NORECOVERY;

Processed 199264 pages for database ‘test’, file ‘BTBLEAD_Data’ on
file 1. Processed 2 pages for database ‘test’, file ‘BTBLEAD_Log’ on
file 1. RESTORE DATABASE successfully processed 199266 pages in
446.348 seconds (3.487 MB/sec). Msg 3136, Level 16, State 1, Line 6 This differential backup cannot be restored because the database has
not been restored to the correct earlier state. Msg 3013, Level 16,
State 1, Line 6 RESTORE DATABASE is terminating abnormally.

It WAS running flawlessly, until they installed Commvault cloud backup.

I found that if a Commvault backup kicks off, I can no longer restore my native local backup past the point in time that Commvault kicked off!

Apparently Sqlserver resets the LSN on each backup, but doesn’t know there are 2 distinct programs running. When commvault kicks off, the LSN is brought forward, and my native backup does not know about it

I like having my own local backup, as it is faster and quicker to restore than the cloud backup, than waiting for another group to do the restore from the cloud for me.

Is there any way to keep the backups separated.

Paul

## python – CSES standard solution for range query problem giving TLE

Problem statement is from CSES

This is a standard question where we are given a list of numbers and a number of queries. For each query, you have to give the sum of numbers in the given range.

My implementation in python:

``````def solve():
n,q = (int(a) for a in input().split(' '))
arr = (int(a) for a in input().split(' '))

cumulativeArray = (0) # Initial entry added to make 1 based indexing
sum = 0
for i in range(len(arr)):
sum += arr(i)
cumulativeArray.append(sum)

for i in range(q):
x,y = (int(a) for a in input().split(' '))
print(cumulativeArray(y) - cumulativeArray(x-1))

solve()
``````

This gives the required answers correctly for all my custom test cases. But gives TLE for huge test cases.

I believe this is happening due to `split()` method in my code.
Any leads are welcome.

## Dark images problem (low exposure) with canon 650d

I have a canon 650d, recently the camera is taking dark photos (low exposure) I always use good settings/standard, but somehow it started giving dark images even under the sun light !!!

in the picture below I was under a strong source of light with these settings : shutter 1/250, aperture f/4, iso 800

I used the same settings but with auto iso and the camera chose iso: 6400 and the image was nice but with a lot of noise of course.
If i switch to program mode it will always use high iso (6400) or maybe really slow shutter speed like 1/20s even under the sun light.

Any ideas or help ?

## Problem with Initialization cell and Manipulate

The following minimum failing example illustrates a problem that I am having building an application to simulate projectile motion.

In the notebook’s initialization cell, I have the definition of a function `FlightDuration`. It serves as a stand-in for a library function that computes the duration of the projectile’s flight from its initial conditions.

``````(* Initialization cell *)
FlightDuration((* arguments *)) := 16.3;
``````

The main input cell of the notebook contains a `Manipulate` for setting the values of the initial conditions and a Trigger for running the simulation.

``````(* Normal (Input) cell: *)
Manipulate(
Module({sol=DSolve({y''(t)==-9.8,y'(0)==80,y(0)==0},y,t)},
flightDuration=FlightDuration((* control values *));
Plot(
y(t)/.sol,
{t,0.0001,time},
PlotRange->{{0,flightDuration},{-50,400}},
ImageSize->500
)
),
(* other controls supplying values to FlightDuration *)
{{time,0.},0.,flightDuration,ControlType->Trigger},
{{flightDuration,FlightDuration()},None}
)
``````

When I close the normal cell, save the notebook, quit Mathematica and restart Mathematica by double clicking the notebook, the Output cell shows a red border and I see the error message:

General: Value of option PlotRange -> {{0,FlightDuration()},{-50,400}}
is not All, Full, Automatic, a positive machine number, or an
appropriate list of range specifications.

However, if I then click the Play button, the simulation works as expected.

My initial (naive) expectation was that the evaluation of the initialization cell should complete before any displays are updated. Further reflection suggested that perhaps the front end was trying to update the display at the same time that the kernel was evaluating the initialization cell. I tried various ways of delaying the re-display, such as using a semaphore, without success.

Q1: Does Mathematica provide an programmatic way for me to control when the initial display update takes place?

Q2: What is the best practice for initializing a notebook along the lines I am trying to do?

Note: Occasionally, when opening the notebook, the error does not occur. I take this to mean that there is some kind of timing dependency or race condition.

Environment: Mathematica: 12.1.0.0; MacBook Pro; Mac OS-X 10.13.4

## sort – Sorting problem price

I have a sorting problem when I do a search the titles are also taken into account whereas I would only like to manage it by price. Thank you.

`````` \$args  = array(
'post_type'           => array('product', 'product_variation'),
'post_status'         => 'publish',
'posts_per_page' => get_option('posts_per_page'),
'paged'          => \$paged,
'tax_query'      => \$tax_query,
'orderby'       =>  (isset(\$_GET("orderby"))?\$_GET("orderby"):'meta_value_num'),
'order'         => (isset(\$_GET("order"))?\$_GET("order"):'ASC'),
);

if (\$orderby == 'price') {

\$args('orderby') = 'meta_value_num';

\$args('meta_key') = '_price';

\$args('order') = 'asc';

} elseif (\$orderby == 'price-desc'){

\$args('orderby') = 'meta_value_num';

\$args('meta_key') = '_price';

\$args('order') = 'desc';   }

\$content .='<select class="dropdown-class" name="sort-posts" id="sortbox" onchange="document.location.href=location.href+this.options(this.selectedIndex).value;"><option enabled>Trier par</option>';
\$content .='<option value="?orderby=price&order=asc">Trier par tarif croissant</option>';
\$content .='<option value="?orderby=price&order=desc">Trier par tarif décroissant</option>';
\$content .='</select>';
``````

## algorithms – 0-1 Knapsack problem with item discounts

I recently encountered this kind of problem in a real world setting, and could not for the sake of me find any literature relating to the problem statement I came up with. An example will be included below.

## Simple Statement of the Problem

Suppose you have values and weights for items, such that groups of $$2$$ and $$3$$ of items in your set may produce values that are less than they would be if chosen individually (think 50% off coupons, or something similar). In this sense, we wish to find the best combination of items that allows us to carry the most weight in our knapsack, given a value constraint. How can we modify the dynamic programming method to come up with a new solution? Is a metaheuristic approach the best way? is this problem already well studied?

## A mathematical statement is given below, to the best of my ability.

Let $$V_1 = {v_1, v_2, …, v_N}$$ be the values of the single items, $$V_2 = { r_{(1,2)}, v_{(1,3)}, … }$$ as set of size $$M$$ of the values of the groups of two items , and $$V_3 = {s_{(1,2,3)}, s_{(1,2,4)} … }$$ be as set of size $$L$$ of the values of the groups of three items, along with corresponding weights (with similar notation for elements) $$W_1, W_2, W_3$$.

We seek to find $$textbf{x} = (x_i, x_{i,j}, x_{i,j,k})$$ where $$x_i, x_{i,j}, x_{i,j,k} = {0,1}$$ that is a vector of length $$N + M + L$$ so that

$$maxleft(sum_{w in W_1} wx_i + sum_{w in W_2} wx_{i,j} + sum_{w in W_3}wx_{i,j,k} right)$$
subject to
$$sum_{v in V_1} vx_i + sum_{v in V_2} vx_{i,j} + sum_{v in V_3}vx_{i,j,k} leq C$$

Where $$C$$ is the value constraint. Here, the index $$(i,j)$$ and $$(i,j,k)$$ simply correspond to the indices of their corresponding items. This also implies that an item chosen in a group of $$2$$ or $$3$$ can no longer be chosen elsewhere, so we impose the following conditions:

If $$x_{i,j,k} = 1$$ then $$x_i = 0$$, $$x_j = 0$$, $$x_k = 0$$, $$x_{i,j} = 0$$, $$x_{i,k} = 0$$, and $$x_{j,k} = 0$$.

If $$x_{i,j} = 1$$ then $$x_i = 0$$, $$x_k = 0$$, and any triplet containing item with index $$i$$ and $$j$$ is zero.

If $$x_i = 1$$, then any group containing item with index $$i$$ is zero.

## Some discussion

An item in the above problem can only be discounted in a group of two, however there may be groups of 3 that produce overlap between two groups of two, hence the need to include them. This means an obvious greedy algorithm appears by ordering the greatest weights per value of triplets, choosing form there and moving on to doubles, then singles until not possible.

I want to believe a modification to the dynamic programming algorithm is possible by simply adding more rows that represent the groups of items, but I’m not sure how we would handle the “this group has been chosen, so all subsets in the group must not be chosen.” condition. In my real world problem there were 150 items, which makes it seem like the dynamic programming method was not possible (there were many possible groups of 2 and 3 if you consider how big 150 choose 3 is..). In fact, the number of rows for my case would be, at first glance, $$150$$ $$+$$ $${150}choose{2}$$ + $${150}choose{3}$$ $$= 562,625$$ rows! Combining this with the columns representing the values which could be many, a sparse matrix option might need to be used to optimize finding a solution.

## A Quick Example

Let $$4$$ items have values $$v_1 = 4$$, $$v_2 = 7$$, $$v_3 = 3$$, and $$v_4 = 9$$ Such that the values of the following groups have discounts: $$(v_1, v_2) = 8$$, $$(v_2, v_4) = 14$$, and $$(v_1, v_2, v_4) = 15$$. It is worth noting any item combinations not listed with a discount are simply the sum of their values, and do not need to be written out. Suppose further that $$C = 17$$.

Their weights are $$w_1 = 2$$, $$w_2 = 5$$, $$w_3 = 5$$, and $$w_4 = 3$$. Then we wish to find $$bf{x}$$ so that

$$max(2x_1 + 5x_2 + 5x_3 + 3x_4 + 7x_{(1,2)} + 8x_{(2,4)} + 10x_{(1,2,4)})$$
subject to
$$4x_1 + 7x_2 + 3x_3 + 9x_4 + 8x_{(1,2)} + 14x_{(2,4)} + 15x_{(1,2,4)} leq 17$$

Where, if any item chosen is contained in another item’s group, that $$x$$ value must be zero, to avoid overlap. It appears to me that the items with indices $${(1,2), 3 }$$ is the solution with weight 12 with value 11.

## Are magnets still a problem as luggage on air travel?

I have just read through 32 pages of luggage instructions by Air France and magnets are not mentioned at all. But the page says that the list is not complete. It does not say where to find the rest.

I seem to remember that magnets used to be shown on those check-in counters, together with fire-arms and other forbidden items. Have not had a chance to check a check-in-counter recently because was not traveling. And I seem to remember that back in 2015 I tried (inside checked luggage) and was asked to remove. So I am puzzled why in 2020 Air France does list exotic things like blood but does not mention magnets on their website.

I have four heavy-duty magnets for welding purposes (to hold steel parts in place) which can lift several kilos of steel. And two lesser magnets to lift petanque balls from the ground for sports, they can lift only one kilo. If I put all that inside my luggage, in the center, you cannot feel anything, when testing with a light-weight metal probe. Will it still make a modern airplane go off course?

Since I cannot send magnets from Germany overseas by parcel (so they are dangerous, or what), and since I travel for work overseas, I would like to bring my magnets inside my checked luggage.

Any experience or knowledge about traveling with magnets on airplanes or links to a special web-site? I came here and found over 1000 questions re allowed luggage items, but no magnets so far. Thank you.

## combinatorics – Counting Problem with Arrangement of Items

I have $$12$$ cupcakes, $$6$$ of them are vanilla, $$4$$ are chocolate, and $$2$$ are birthday cake flavor. Each cupcake is decorated differently making them unique.

• How many different ways are there to arrange these cupcakes that all the cupcakes of the same flavor are right next to each other?

My Solution:

I thought that we could could use a permutation here so: $$frac{12!}{6!4!2!}$$ Where the chocolate can be organized in varies ways, same with vanilla, and birthday cake.

• How many ways can the cupcakes be arranged if one birthday cake flavored cupcakes must be on each end and the vanilla cupcake cannot be placed next to the birthday cake flavors?

My Solution:

Since we only have two birthday cake flavor then they would go on the ends. Then two chocolate flavors would go next to those leaving us $$2$$ chocolate flavors left and $$6$$ vanilla flavors.
$$frac{12!}{2!6!2!2!}$$
$$2$$ ways to arrange the birthday cakes, $$2$$ ways to arrange the chocolate flavors(buffer of the birthday cake flavors), $$2$$ more ways to arrange the chocolate flavors, and then $$6$$ ways to arrange the vanillas.

I was wondering if my approach to this problems correct using permutation in this manner.

## electrum – How can I troubleshoot whether an unconfirmed transaction that seems stuck is a problem on my end or just from high volume on mempool?

Never had transaction hang unconfirmed like this before. Granted its only been a few hours but it’s not like I skimped on fees either. I always choose the default electrum fee, but when it got stuck I doubled it using RBF to increase the fee.

But it’s still stuck!

How can I check whether I’m really in the queue being ignored because people are paying higher fees or if there’s something wrong I’m doing on my end?

Regenerating my wallet in electrum at least restored my pre-send balance. So at least I can see my coin even if there’s no movement on this transaction that I’d love to either cancel out of or see confirmed.

## export – Problem with exporting text

I prepared in Mathematica some long text:

``````text = string1 <> string2 <> ... <> stringn;
``````

(some strings contains TeX code). Then I would like to export text to some text file and I use:

``````Export(path,text,"Text")
``````

Unfortunatelly, when I look into the file instead of the expected text I found Mathematica command:

``````StringJoin(string1,string2,...)
``````

What to do, to have text, which I created in Mathematica in my file?