I am starting to learn about Linux Operating System, and I am confused with differences between mutex, conditional variables, and synchronization primitives. Which one is the best to avoid deadlocks and mutual exclusion problems?

# Tag: conditional

## How does derandomization of (1-1/e) factor algorithm of MAX-SAT work with conditional expectations?

I am attempting to understand how to show that the (1-1/e) factor algorithm for MAX-SAT can be derandomized with conditional expectations.

Similar to the 1/2 factor algorithm, I have attempted a greedy approach, scanning across each literal x_i, from x_1 to x_n, and setting each literal to true or false depending on which results in the greatest total expectation. However I am struggling to show how the total expectation at each step of this approach is at least as great as the total expectation of the previous step.

I would appreciate any insight on how to proceed.

## Can’t get conditional syntax correct

Have [Tier] column with choice values of 0,1,2,3 If [Tier] = 0 calculated column should = 0 If [Tier] = 1 calculated column should = 4 If [Tier] = 2 calculated column should = 24 If [Tier] = 3 calculated column should = 48

Can get to work for 2 values using the following syntax but not for 4 values =IF(OR([Tier]=”1″,[Tier]=”2″),”4″,”24″)

## Powershell script to update list column from another column Conditional

Any help is greatly appreciated. Here is the scenario:

I have a powershell script which I am using from another post on stackexchange.

I have two fields in a list, the script copies the value from one field into the other and works great however, I would like to add some conditional logic into the script.

`TestPublishedDate`

gets updated by `testupdatedate`

field however, I would like for `TestPublishedDate`

only to be updated if it is empty.

Here is the script I am using:

`#Add SharePoint PowerShell Snapin which adds SharePoint specific cmdlets Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue #Variables that we are going to use for list editing $ listName = "Approvals" #Get the SPWeb object and save it to a variable $ web = Get-SPWeb http://discoverydev09/ #Get the SPList object to retrieve the "Demo List" $ list = $ web.Lists[$ listName] #Get all items in this list and save them to a variable $ items = $ list.items #Go through all items foreach($ item in $ items) { $ user = $ item["testupdatedate"] #Change the value of the "Title" column $ item["TestPublishedDate"] = $ user #Update the item $ item.Update() } `

I am sure it is something simple, the list will need to run daily on a list with over 5000 items. If there are any tips on making this script more streamlined please feel free to let me know!

Or even if PnP could be used to make this easier?

Thanks

## SharePoint Column Conditional Formatting – Applying CSS classes to a date field using a nested IF statement

Apologies, I am relatively new to SharePoint/JSON, So forgive me if I am not seeing the obvious. I would be INCREDIBLY grateful if someone would help.

I would like to apply conditional formatting to a **date** field using a nested IF statement.

*IF the current field is blank, then set the CSS class to ‘blocked’. However, if the current field is populated, run a second IF: IF the current field is more than 1 year before today, then set the CSS class to ‘blocked’, however if the current field is within the last year, set the CSS class to ‘good’.*

I have ran the following, without success. No formatting is applied whatsoever.

` { "$ schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "attributes": { "class": "=if(toString(@currentField)=='', 'sp-field-severity--blocked', if([@currentField]+31104000000 < @now,'sp-field-severity--blocked', 'sp-field-severity--good'))" }, "txtContent": "@currentField" } `

HOWEVER, when I split the conditions into two, they work independently.

- =IF empty, blocked, good.

`{ "$ schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json", "elmType": "div", "attributes": { "class": "=if(toString(@currentField)=='','sp-field-severity--blocked', 'sp-field-severity--good')" }, "txtContent": "@currentField" } `

- =IF exceeds 1 year, blocked, good.

`{ "$ schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "attributes": { "class": "=if(@currentField+31104000000 < @now, 'sp-field-severity--blocked', 'sp-field-severity--good')" }, "txtContent": "@currentField" } `

My next step would be to add the corresponding CSS class icon into the field.

## How to count this Conditional Probability

Iam not good in math, especially for conditional probabilities please help me for this :

How do you count to get the values in the table?

## How to hide field on editform.aspx using conditional statements?

I have a column name “Order” and if order is equal to “Car” then show the “Warranty” field, else hide it. I am using script editor for this and here is my code and someone it is not working. Can you point me to a right direction.

`<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script> <script> if ($ ("select[title='Order']").val() != "Car") { $ (document).ready(function(){ $ ("nobr:contains('Warranty')").closest('tr').hide(); }); } else { $ (document).ready(function(){ $ ("nobr:contains('Warranty')").closest('tr').hide(); }); } </script> `

## conditional probability of dependent random variables

Suppose I have 3 random variables:

$ $ X \sim \mbox{Bernoulli}(1/2)$ $ $ $ Z \sim \mbox{Normal}(0,1)$ $ $ $ Y = X+Z$ $

How do I compute the conditional probability:

$ $ P(X=1 | Y=y)$ $

# Attempt1:

`Probability[ X == 1 \[Conditioned] X + Z == y, { X \[Distributed] BernoulliDistribution[1/2] ,Z \[Distributed] NormalDistribution[] } ] `

# Attempt2:

`D[Probability[ X == 1 \[Conditioned] X + Z >= y, { X \[Distributed] BernoulliDistribution[1/2] ,Z \[Distributed] NormalDistribution[] } ],y] `

# Attempt3:

`Likelihood[ TransformedDistribution[X + Z, { X \[Distributed]BernoulliDistribution[1/2], Z \[Distributed] NormalDistribution[]}] , {y}] `

# Pencil and Paper attempt:

$ $ P(X=1 | Y=y) = \frac{P(X=1 , Y=y)}{P(Y=y)}$ $ $ $ = \frac{P(X=1 , X+Z=y)}{P(Y=y)}$ $ $ $ = \frac{P(X=1)P(Z=y-1)}{P(Y=y)}$ $ $ $ = \frac{P(X=1)P(Z=y-1)}{P(X=1)P(Z=y-1)+P(X=0)P(Z=y-0)}$ $

$ $ P(Z=y)=\frac{e^{-\frac{y^2}{2}}}{\sqrt{2 \pi }}$ $ $ $ P(Z=y-0)=\frac{e^{-\frac{y^2}{2}}}{\sqrt{2 \pi }}$ $ $ $ P(Z=y-1)=\frac{e^{-\frac{1}{2} (y-1)^2}}{\sqrt{2 \pi }}$ $ $ $ P(X=1)=\frac{1}{2}$ $ $ $ P(X=0)=\frac{1}{2}$ $

$ $ P(X=1 | Y=y) = \frac{e^{-\frac{1}{2} (y-1)^2}}{2 \sqrt{2 \pi } \left(\frac{e^{-\frac{y^2}{2}}}{2 \sqrt{2 \pi }}+\frac{e^{-\frac{1}{2} (y-1)^2}}{2 \sqrt{2 \pi }}\right)}$ $

$ $ P(X=1|Y=y) = \frac{e^y}{e^y+\sqrt{e}}$ $

## SharePoint Designer 2010 – Conditional Formatting on List

I have been asked to apply conditional formatting to a list in SharePoint 2010 to change the font colour if the difference is 7 or less when you minus the date in the Date Valid column from todays date. So…

`Today – Date Valid <= 7 `

I can apply simple conditions but I think the one I have been asked for would need to be done in the Advanced Condition window and I haven’t been able to figure out what it would be.

Does anyone know what the condition would be?

## WSL: Is there a conditional to detect “Open Linux Shell Here” case?

When I open the WSL by clicking on its icon I need it to be opened in a certain directory (of course one that is more useful than `System32`

), so I add a `cd destination`

in my `.bashrc`

. But then the “Open Linux Shell Here” option (available when you hold the `Shift` key on keyboard and right-click on any folder is also being redirected to that destination, which is undesirable. Is there a way I can detect this case in my `.bashrc`

script and let it behave as it should?

In short, I need to know when the shell has been opened by the option in `Shift`+*Right Click* inside a folder, so that I can avoid changing the working directory to another one.

I’m using `WSL-Ubuntu 18.04 LTS`

and `GNU bash, version 4.4.19(1)-release (x86_64-pc-linux-gnu)`

.