list manipulation – Split OR conditions into full cases

I have a list of inequalities with AND/OR conditions (A,B,C,D are all inequalities):

   l={A&&(B||C||D)} (This is simplified, in reality it will be far more complicated as shown below.)

What I want to like the following:

l={A&&B,A&&C,A&&D}

In other words, I want to remove all OR conditions to make it a list of conditions for all possible cases.

For your reference, the following is a real example I actually want to change using the above process. I just want to remove all OR conditions to make this expression more readable. Therefore, I would like to split the following into many different cases.

 (x + p (Delta) > 
    y && (((p (-1 + v) + f v - x + y - v y)/(f v) < (Rho) < (
        v (f - x) + p (-1 + v + (Delta) - v (Delta)))/(f v) && 
       v + (Delta) != 1) || (v + (Delta) < 
        1 && ((v (f - x) + p (-1 + v + (Delta) - v (Delta)))/(
          f v) < (Rho) < (v (f - y) + p (-1 + v + (Delta)))/(f v) ||
          p + x + v y + f v (-1 + (Rho)) < 
          p v + y)) || (v + (Delta) > 
        1 && ((v (f - x) + p (-1 + v + (Delta) - v (Delta)))/(
          f v) < (Rho) < (
          f v (Delta) - x (-1 + v + (Delta)) + 
           y (-1 + v + (Delta) - v (Delta)))/(f v (Delta)) || 
         p + x + v y + f v (-1 + (Rho)) < p v + y)))) || (x + 
     p (Delta) < y && 
   y + x (-1 + (Delta)) + (-1 + v) y (Delta) + 
     f v (Delta) (Rho) < (f + p) v (Delta) && v + (Delta) != 1)

Thanks in advance for your help!

python – Simple interface for collecting issues after a list of validations

In this case, I would really keep it simple. I would drop the OOP and just write a simple function that validates the radar and returns a list of issues. To be clear:

def check_radar(radar: Radar) -> Set(str):
    return {
        *_check_1(radar),
        *_check_2(radar),
        ...
    }

def _check_1(radar: Radar) -> Set(str):
    # perform check and return set() or {"issue"}

The example above is just an idea for the implementation, you can then implement the internals as you wish, for instance by defining a list of checker functions and iterating and appending to the list as you’re doing in your sample code. The issues could be str or some more complicated object, depending on your needs.

This not only avoids having to write and maintain a class that in the end has just a single method kind of an unusual interface, but also writing a class that behaves like an Iterable(str) and which make the API harder to understand.

Another note: instead of ok, issue = checker() you could just return None when there’s no issue, which would simplify early returns from the checker functions.

I know it’s not really OOP, but there’s no need to use OOP everywhere if another pattern solves the problem more intuitively.

terminology – How can I efficiently search the bitcoin-dev mailing list for discussion of a specific term?

The simplest way to do this is use a search engine e.g. Google and enter:

"bip37 site:lists.linuxfoundation.org"

(This is also useful for searching GitHub issues, pull requests as a Google search is often more effective than the github.com search functionality.)

Alternatively you can go to https://lists.linuxfoundation.org/pipermail/bitcoin-dev/ and download all the gzip mboxes (the URL scheme is simple, so you write a shell one-liner with curl), ungzip them, cat them together, and then use mutt -f combined.mbox.

This question was answered by various individuals on IRC.

How to return user email from a custom column “Owner” to an XML from sharepoint online list using CSOM?

How to return user email from a custom column “Owner” to an XML from sharepoint online list using CSOM?
This works but bug exists as it sends Microsoft.SharePoint.Client.FieldUserValue() instead of sending user name /email. Please help with this bug

string xmlFile = @"c:tempexport.xml";
Web web = clientContext.Web;
                    ListCollection listColl = web.Lists;
                    List list = clientContext.Web.Lists.GetByTitle("Site Pages");
                    clientContext.Load(list);
                    FieldCollection listFields = list.Fields;
                    clientContext.Load(listFields);
                    clientContext.Load(listColl);
                    clientContext.ExecuteQuery();

                    ListItemCollection listItems = list.GetItems(CamlQuery.CreateAllItemsQuery());
                    clientContext.Load(listItems);
                    clientContext.ExecuteQuery();

                    XmlDocument doc = new XmlDocument();
                    XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", "ISO-8859-1", null);
                    doc.AppendChild(declaration);
                    XmlElement root = doc.CreateElement("SitePages"); //CREATES FIRST ROOT NODE
                    

                    foreach (ListItem item in listItems)
                    {

                       


                        ListItem LItem = listItems.GetById(item.Id);
                        XmlElement elem = doc.CreateElement("List"); //CREATES CHILD NODE
                        

                        elem.SetAttribute("DateLastReviewed", Convert.ToString(item("DateLastReviewed")));
                        elem.SetAttribute("NextReviewDate", Convert.ToString(item("NextReviewDate")));
                        elem.SetAttribute("ContentOwner", Convert.ToString(item("Owner")));                   // bug exists as it sends Microsoft.SharePoint.Client.FieldUserValue() instead of sending user name /email
                        elem.SetAttribute("ContentNumber", Convert.ToString(item("ContentNumber")));                       
                        elem.SetAttribute("ID", Convert.ToString(item.Id));
                        root.AppendChild(elem);

                    }
                    doc.AppendChild(root);
                    doc.Save(xmlFile);
                    Console.WriteLine(" XML file is successfully generated");
                    Console.ReadKey();
                }

Give you a list of 500K blog comment backlink sources for $10

I will provide you with 500,000 backlink sources for you to create your own backlinks without needing to search for them.

by: yuyu2000
Created: —
Category: Link Building
Viewed: 429


.

2013 – Workflow on Survey list not starting?

This is on SP 2013 and using 2013 workflow.

I have a survey list, and when a user completes the survey, we want to create a list item in another list and populate one of the fields with data from the survey.

However, I can’t seem to get the workflow to start. Initially the workflow was set to start automatically upon new item creation, then wait until the Completed field equals Yes, then create the item in the other list.

I added a bunch of logging to track the workflow’s progress, but I don’t see anything in the Workflow History list. I then changed the workflow to be able to be manually started. After that, if I went to a survey response and looked at the workflows for that item, I could see my workflow and try to start it, but if I look at the workflow status it just sits there with internal status of “Not Started”.

What’s going on here, why won’t my workflow start?

export – Exporting multiple lists (x1,y1…n) (x2,y2..n)of different lengths into same excel files separated by spaces of two columns between each (x,y) list?

I have multiple lists like this this with different lengths and different x, y values,

list1 = {{3., 1.49463}, {3.1, 1.49238}, {3.2, 1.49027}, {3.3, 1.48814}, {3.4, 
  1.48592}, {3.5, 1.48366}, {3.6, 1.48158}, {3.7, 1.47997}, {3.8, 
  1.47894}, {3.9, 1.47848}, {4., 1.47824}, {4.1, 1.47892}, {4.2, 
  1.47973}, {4.3, 1.4809}, {4.4, 1.48231}, {4.5, 1.48374}, {4.6, 
  1.48498}, {4.7, 1.48589}, {4.8, 1.4865}, {4.9, 1.4869}, {5., 
  1.48717}}

list2 = {{0.3, 1.70796}, {0.4, 1.69032}, {0.5, 1.66887}, {0.6, 1.65187}, {0.7,
   1.64455}, {0.8, 1.64575}, {0.9, 1.65089}, {1., 1.65581}}

list 3 = {4.1, 1.47892}, {4.2, 1.47973}, {4.3, 1.4809}, {4.4, 1.48231}, {4.5, 
  1.48374}, {4.6, 1.48498}, {4.7, 1.48589}, {4.8, 1.4865}, {4.9, 
  1.4869}, {5., 1.48717}}

and so on until 10 lists and all of them have different lengths with some having (x,y) sets as much as 30 (x1,y1),(x2,y2) … (x30,y30) like that,

i want to list them list this in single excel sheet with two different options whichever you can guide,

list 1 x,y values (next list after two columns separation) –list 2 x,y values– (next list after two columns separation) -**list 3 x,y values****

list 1 x,y values (no separation)- list 2 x,y values– (no separation)- list 3 x,y values

sharepoint online – Programatically Deploy List Item Layout

Suppose we created a list with a custom list form layout. Now, I want to move this list to a different SharePoint tenant/site. How do I programmatically apply the custom form laout?

enter image description here

More details
I am using SharePoint PnP Provisioning templates to export and import lists. Unfortunately, it does not seem that the PnP Provisining template contains list item form’s laoyout.

Example of the Header JSON that I am trying to deploy programmatically:

{
    "elmType": "div",
    "attributes": {
        "class": "ms-borderColor-neutralTertiary"
    },
    "style": {
        "width": "99%",
        "border-top-width": "0px",
        "border-bottom-width": "1px",
        "border-left-width": "0px",
        "border-right-width": "0px",
        "border-style": "solid",
        "margin-bottom": "16px"
    },
    "children": [
        {
            "elmType": "div",
            "style": {
                "display": "flex",
                "box-sizing": "border-box",
                "align-items": "center"
            },
            "children": [
                {
                    "elmType": "div",
                    "attributes": {
                        "iconName": "Mail",
                        "class": "ms-fontSize-42 ms-fontWeight-regular ms-fontColor-themePrimary",
                        "title": "Details"
                    },
                    "style": {
                        "flex": "none",
                        "padding": "0px",
                        "padding-left": "0px",
                        "height": "36px"
                    }
                }
            ]
        },
        {
            "elmType": "div",
            "attributes": {
                "class": "ms-fontColor-neutralSecondary ms-fontWeight-bold ms-fontSize-24"
            },
            "style": {
                "box-sizing": "border-box",
                "width": "100%",
                "text-align": "left",
                "padding": "21px 12px",
                "overflow": "hidden"
            },
            "children": [
                {
                    "elmType": "div",
                    "txtContent": "=' ' + [$Title]"
                }
            ]
        }
    ]
}

Is there a way to apply these JSON customizations using PowerShell PnP?

iterator – Bidirectional iterate over list in Python

I wrote a short function to iterate over a list starting at a given index, then flipping back and forth between left and right values.

import itertools
from typing import Generator


def bidirectional_iterate(lst: list, index: int) -> Generator:
    for left, right in itertools.zip_longest(reversed(lst(:index)), lst(index:)):
        if right is not None:
            yield right
        if left is not None:
            yield left


arr = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
#      ^  ^  ^  ^  ^  ^  ^  ^  ^  ^
#      7  5  3  1  0  2  4  6  8  9   <- Expected order of iteration

print(list(bidirectional_iterate(arr, 4)))

Output:

(4, 3, 5, 2, 6, 1, 7, 0, 8, 9)

I feel like I’ve seen an algorithm like this before, but I couldn’t find any reference to it.

This was the most Pythonic implementation I could come up with. The only improvement I can think to make to this implementation is a way to differentiate None list elements from the None values returned to pad itertools.zip_longest().

Are there any better/faster ways or any libraries that can accomplish this?

sharepoint enterprise – Save conflict adding a content type to list after added as allowed content type in site level doc set template. What do I need to wait for or refresh?

So I’m trying to create a new content type at the site level, add it as an allowed content type in a custom document set content type, and then add it to all the libraries where the document set is used so that it’s actually there for people to use in the doc sets.

All this in a feature upgrade receiver, so C# / server-side code.

Everything goes pretty smoothly except that I’m getting “Save Conflict” SPException when I try to add the content type to each of the lists. I am used to paying attention to when I call Update() on something and then making sure to get a new reference to it if I plan to update it again to avoid those conflicts, but in this case I don’t call update on the lists, and I’m actually getting the references to the lists after I update the document set template, so I don’t see how they could have gotten stale.

Here’s basically how the code goes (although I omitted a lot of logging and error handling for clarity/brevity – I know that the error happens for each library because I’m catching those, so those exceptions are not interrupting the loop):

// at this point the new content type has been created
// successfully, so i get the _site_ level content types
SPContentType newCType = web.ContentTypes("New CType Name");
SPContentType docSetCType = web.ContentTypes("Document Set Name");

DocumentSetTemplate template = DocumentSetTemplate.GetDocumentSetTemplate(docSetCType);
template.AllowedContentTypes.Add(newCType.Id);

// update with pushdown, because the doc set is used in many document libraries
template.Update(true);

// however, that did not actually add the new content type to any libraries,
// it only updated the document set to _allow_ it.  i still need to get the
// new content type into the libraries so users can add them in the doc sets.

// so get the usages
List<SPContentTypeUsage> usages = SPContentTypeUsage.GetUsages(docSetCType).ToList();

foreach (SPContentTypeUsage usage in usages)
{
    if (usage.IsUrlToList)
    {
        // how can this not be a fresh reference to the libraries?
        // i didn't get this reference _before_ i updated the document set template,
        // i'm getting these references _after_ that update.
        SPList list = web.GetList(usage.Url);

        // i double check to make sure it wasn't automatically added when
        // the doc set template was updated, and i know it wasn't because...
        SPContentType listLevelCType = list.ContentTypes(newCType.Name);
        if (listLevelCType == null)
        {
            // ...i have a log entry here to indicate that i am about to try to add it
            listLevelCType = list.ContentTypes.Add(newCType);

            // and this is what causes the save conflict.
        }
    }
}

What am I missing here? What do I need to refresh my reference to in order to not get a save conflict when adding to the lists’ content type collections?