flow – Sharepoint String Column being set as boolean

I have a PowerApp that submits all fields to a PowerAutomate script via JSON. For my Yes/No fields, I set the value of the JSON objects to the strings “Yes” or “No” rather than passing them as boolean.
In my PowerAutomate flow I define the schema of the ParseJSON action with these fields listed as “string”. Then I update a SharePoint List (actually a new doc in a document repository) with these fields. All the columns are defined there as strings (NOT boolean).
Yet, 7 of my 13 Yes/No values get set as boolean (true/false). The other 6 get set as strings (“Yes”/”No”).

I tried adding a space or even a period at the end of the strings in the JSON. It’s still misbehaving and converting some of them to boolean. And it’s always the same fields.
What the hell is happening here???

Here are the fields as defined in SharePoint (with names changed to protect the innocent):
Field1 is getting converted to boolean while Field2 is processing correctly as strings of “Yes” or “No”.
{
“columnGroup”: “Custom Intake”,
“description”: “”,
“displayName”: “Field1”,
“enforceUniqueValues”: false,
“hidden”: false,
“id”: “xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”,
“indexed”: false,
“name”: “Field1”,
“readOnly”: false,
“required”: false,
“text”: {
“allowMultipleLines”: false,
“appendChangesToExistingText”: false,
“linesForEditing”: 0,
“maxLength”: 255
}
},
{
“columnGroup”: “Custom Intake”,
“description”: “”,
“displayName”: “Field2”,
“enforceUniqueValues”: false,
“hidden”: false,
“id”: “xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”,
“indexed”: false,
“name”: “Field2”,
“readOnly”: false,
“required”: false,
“text”: {
“allowMultipleLines”: false,
“appendChangesToExistingText”: false,
“linesForEditing”: 0,
“maxLength”: 255
}
}

Here’s the snippet of the JSON Schema:
{

“Field1”: {
“type”: “string”
},
“Field2”: {
“type”: “string”
},

}

And here’s the snippet of the data passed in as JSON.
{

“Field1”: “No.”,
“Field2”: “No.”,

}

Also, When I manually try to change the value of one of the misbehaving columns in the list (doc repository) to “Yes” or “No”, it reverts back to boolean.

Please help me keep my remaining hair…..

Inserting a string in the middle of page’s permalink?

I know the more sensible approach for this would be to rely on archives so that my URL for news would be:

domain.com/news/

However, due to how I am setting this up for the client to easily modify the content, I have created 3 news pages (each referencing 3 categories), inside each one, there is code to display the news listing for each category.

I would like to change the permalink for those pages so that instead of being:

domain.com/in-the-media

The permalink is:

domain.com/news/in-the-media

I have looked around and the hook page_link seems to be what I would like.

Here is my callback function (which I have verified gets called):

    public static function change_news_permalinks( $url, $post ) {  
        $url = "{$url}something/";
        return $url;
    }

This is just a test, if this worked, then I would continue and write the conditions so that the change would only take place when it’s one of those 3 pages.

However, regardless of what page I view, the permalink remains unchanged when the page loads.

Am I using this incorrectly or am I misinterpreting what this hook actually allows you to carry out?

Thanks!

Retrieving top-level opening and closing sequences from a Python string

The problem I’m solving is a more complex version of pairing up opening and closing brackets.
Instead of matching only on (({})), I additionally need to match arbitrary opening sequences of arbitrary length to closing sequences of arbitrary length, such as '(' which is mapped to ')'.

Motivation:
For parsing a grammar in a custom parser, I need to discern between bracket literals, which are surrounded by apostrophes and brackets on the grammar level, which are normal brackets. The goal is to return a list of all top-level matches that are found. A match is represented as a 4-tuple of the range that the opening and closing sequences span.
For a motivating example, evaluating id '(' (FArgs) ')' ('::' FunType) '{' VarDecl* Stmt+ '}' should yield the following list:

((3, 6, 15, 18), (19, 20, 32, 33), (34, 37, 53, 56))

My starting point was this code review on checking for balanced brackets in Python
, which I adapted to suit the additional requirements:

  • Match arbitrary opening and closing sequences of length >= 1
  • Collect tuples of the ranges at which the sequences are found.

Armed with Python 3.9, this is my code:

def get_top_level_matching_pairs(expression: str, mapping: dict(str, str)) 
        -> list(tuple(int, int, int, int)):
    """
    Returns all top-level matches of opening sequences to closing sequences.
    Each match is represented as a 4-tuple of the range that the opening and closing sequences span.

    >>>get_top_level_matching_pairs("(a) op b cl", {'(': ')', 'op': 'cl'})
    ((0, 1, 2, 3), (4, 6, 11, 13))
    """
    def head_starts_with_one_from(match_targets: Union(KeysView(str), ValuesView(str))) -> Optional(str):
        # Check whether the expression, from index i, starts with one of the provided keys or values.
        # Return the first match found, none otherwise.
        return next(filter(lambda m: expression.startswith(m, i), match_targets), None)
    res = ()
    queue = ()  # functions as a stack to keep track of the opened pairs.
    start_index = None
    start_match = None
    i = 0
    while i < len(expression):
        if open := head_starts_with_one_from(mapping.keys()):
            if start_index is None:
                start_index = i
                start_match = open
            queue.append(mapping(open))  # Store the closing counterpart for easy comparisons
            i += len(open)
            continue
        if close := head_starts_with_one_from(mapping.values()):
            try:
                if (stack_head := queue.pop()) == close:
                    if not queue:  # This closing token closes a top-level opening sequence, so add the result
                        res.append((start_index, start_index + len(start_match), i, i + len(close)))
                        start_index = None
                        start_match = None
                    i += len(close)
                    continue
                # raise mismatched opening and closing characters.

            except IndexError:
                # raise closing sequence without an opening.
        i += 1
    return res

My questions:

  1. Should I put the preconditions in the docstring for the function or should I verify them in the code? The preconditions are: strings in the mapping are not empty and no mapping string can be a subset of another.
  2. Is the head_starts_with_one_from nested function justified as a nested function? It allows for some neat walrus expressions on the if open and if close lines.
  3. Is there a better way to iterate over the expression, given that you need to match a varying range (here: 1 or 3 characters) of the expression at once and sometimes skip over part of it?

Of course, additional comments are more than welcome.

pandas – Combine multiple numeric value based on same string name python

Imagine I have dataframe like this:

name    num
as       1  
aj       3
as       3
an       2
aj       4
ar       5

And I want to sum up numeric value on num column based on duplicate string on name column before display it into barchart. Would be like this:

name    num
as       4  
aj       7
an       2
ar       5

Any help would be appreciated.

sharepoint online – Get text in Base64 encoded string in Power Automate

I have a library where users are uploading .msg files.

I am able to get the contents of the file using Get File Content action in Power Automate. It returns Base64 Encoded string.

Is there a way to get the text contents from the output of the Get File Content action?

When I run Javascript function atob(stringfromGetFileContent) in Browser console, I can see the contents of the msg file. Is there a way to do this in Power Automate?

Setting up an Oracle linked server using an LDAP connection string

I am trying to set up an Oracle Linked Server in SQL Server 2016. With the information I have for the Oracle server, I am able to reach it with tnsping using a connect string via LDAP.

tnsping Result

Adding the string that works with tnsping as the Provider string in linked server setup, however, doesn’t work and results in an “ORA-12154: TNS:could not resolve the connect identifier specified” error.

enter image description here

I’m sure it’s something I am missing, but don’t know enough about Oracle to know what that might be.

string – Na linguagem R, qual a diferença entre usar ‘ ‘ ou ” “?

Bom dia.
Estou iniciando meu aprendizado em R e gostaria de saber qual a diferença entre criar strings usando aspas simples ou duplas. Por exemplo:
texto1 <- “isso é um texto”
text2 <= ‘isso é um texto’

Existe alguma diferença entre os casos acima? Existe alguma situação que você é obrigado a usar aspas simples ou duplas??
Agradeço pela atenção e colaboração.

compression – How to compress a string in Mathematica so that it can decompressed in python

I need to compress a string into some format without spaces so that I can pass it along on the command line and avoid writing it to file (which would require locking files to prevent simultaneous writes so I prefer to pass it directly). I then need to decompress the string in Python. The standard Compress function seems like a good candidate as it indeed compresses strings into string without spaces. According to https://mathematica.stackexchange.com/a/104661/45020 I should be able to decode the string in python using zlib.

However, I cannot manage.

I tried with

import zlib
data = data if isinstance(data, bytes) else data.encode('utf-8')
data = base64.b64decode(data)
zlib.decompress(data)

where data is the string outputted by Compress in Mathematica with the leading 1: removed as suggested in the linked post.

It decompressed without any error in python, but seems to be a meaningless string nothing like the original string that I put in. I guess that the standard Compress is no good to me in this situation?

How can I best compress a string in Mathematica in such a way that I can decompress it in Python.


Compressing using “GZIP” does not seem to work at all. I get an error

"File !("/tmp/m0000213298301.gz") not found during Import"

função pronta da c ou c++ para separar uma string que não contém delimitadores

Espero que estejam indo bem!

Minha pergunta é bem parecida com várias a respeito de separar strings e C ou C++, porém, as respostas não servem para mim.

Minha intenção é simplesmente pegar uma parte de uma string que eu sei que da posição 0 até a posição 29, por exemplo, contém um nome próprio. E da posição 31 até a posição 45, está o telefone associado ao nome da pessoa.
Então, existe tal função/instrução em alguma biblioteca que faça, por exemplo, str1 = str fonte 0..29 para pegar os 30 primeiros caracteres da string fonte e colocar na string str1 e usando tal função novamente str2 = str fonte 30..45 para pegar os caracteres 30 até 45 para colocar na string str2?
Ou seja uma função elegante, eficiente, em que eu não precise usar caracteres delimitadores para separar as partes da string uma vez que eu sei o que está contido na string em um intervalo de índices pré conhecido. E também não precise iterar sobre a string fonte e ir armazenando os caracteres em seus destinos.

É isso, até breve!

python – Como substituir várias palavras de uma string a partir do primeiro elemento de tuplas com a função replace?

Preciso verificar se o primeiro elemento das tuplas abaixo existe na string historia e, se sim, fazer a substituição na string pelo segundo elemento de cada tupla. No final, terei uma nova história.

tuplas = (('menina', 'moça'), ('passeava', 'caminhava'), ('lobo', 'monstro'), ('espiava', 'perseguia'), ('sorrateiramente', 'silenciosamente'))

historia = "A menina passeava pela floresta enquanto o lobo a espiava sorrateiramente"

nova_historia = " "

Tentei substituir com um replace após join, mas não dá certo.

lista = () lista_2 = () for x in historia.split(): lista.append(x) for y in tuplas: if x == y(0): lista_2.append(' '.join(lista).replace(y(0), y(1)))

Resultado:

('A moça', 'A menina caminhava', 'A menina passeava pela floresta enquanto o monstro', 'A menina passeava pela floresta enquanto o lobo a perseguia', 'A menina passeava pela floresta enquanto o lobo a espiava silenciosamente')