data structures – Can an algorithm complexity be lower than its tight low bound / higher than its tight high bound?

Let $t(x)$ be the time taken for input $xin {0,1}^*$, and $T(n)=max_{xin{0,1}^*,|x|=n}t(x)$ is the worst case.

If $Tintheta(n^3log(n))$, this means that there are constants $C_1,C_2$ and $N$ such that for all $n> N$ you have $$C_1n^3log(n)leq T(n)leq C_2n^3log(n)$$.

Since $n^3log(n)geq n^2$ for $n>1$, then $C_1n^2leq C_1n^3log(n)leq T(n)$. Therefore, $TinOmega(n^2)$.

We also have that $n^3log(n)leq n^4$, for all $n>1$. Therefore, $T(n)leq C_2n^3log(n)leq C_2n^4$.

This implies that $Tin O(n^4)$.

Finally, $$begin{align}A(n)&=E(t(x), |x|=n)\&leq E(T(n), |x|=n)\&=T(n)E(1,|x|=n)\&=T(n)\&leq C_2n^3log(n)\&leq C_2n^4end{align}$$, for $n>1$. Therefore, the average number of steps satisfies $Ain O(n^4)$.


Sometimes computing tight bounds is hard, while more relaxed bounds are more accessible.

Provider Hosted App-Not able to get data from list using JSOM or Javascript in sharepoint 2016 On-Premise

My Provider-Hosted App published and hosted on IIS with https. The URL is like:

https://localhost:44343/Pages/Default.aspx?SPHostUrl=http%3A%2F%2Fecontent&0319c41%2Eecontent%2Eelibrary%2Eapps%2Elocal%2FSharePointApp2%5Fsingeltest

How can I get list data using JavaScript or JSOM.

Please share the helpful code snippet.

FileStream DB SQL Server – merging DB data

We recently upgraded a server from 2014 to 2017. Since down time was a concern, we migrated some DB’s a couple days before.

Migration complete Sunday afternoon, we’ve now come to find out the Filestream DB was used between restore and cutover. So we have a datagap to mitigate. I restored the old DB to a backup server, and did a basic ‘not in’ to find 12 documents in the old DB.

Finally, the question: how do we get those 12 documents into the current DB? Is it as simple as an insert from old to new?

If it helps, this query is what shows the 12 record gap:

SELECT * 
INTO #tmpFileStore
FROM OPENQUERY (OldDBSever_LinkedServer, 'SELECT * FROM (FSDB).(dbo).(DocumentFileStore)');

SELECT stream_id
  FROM #tmpFileStore
  WHERE stream_id not in (Select (stream_id) FROM (dbo).(DocumentFileStore))
GO

macos – Search e-mail message data not including a specific phrase in Outlook

In Microsoft Outlook on MacOS – How do I search for e-mail messages that do not include a specific phrase in the message data, including the header?

Example: I could do a search for “stack” and it gives way to many “hits”.
To reduce the number of messages I could remove all hits that contain “stackexchange.com” both in the header and body.

In “Advanced Search” there is an option to search the body data, but not the header data of a message.

sql server – Replacing csv substrings in view-row using data from other table

Is there a way to perform SELECT query in a view replaces a row containing comma-separated values with their corresponding text value from another table?
Consider my view contains data from two tables; Data and CodeValue, that would look like this:

Data
Id | Value | Value2 | Value 3
==============================
  1| 0;1;2| some other data
  2| 0;2;3|
  3| 2    |

CodeValue
Id | Code
=============
  0| Apple
  1| Orange
  2| Banana
  3| Dogmeat

So the actual output from the SELECT query in my view would be:

View
Id | Value 
============
  1| Apple, Orange, Banana
  2| Apple, Banana, Dogmeat
  3| Banana

I’ve messed around with stored procedures and functions, but can’t wrap my head around those and how to actually implement this.

python – Is there a better way to parse this data file?

I have a text data file in SPWLA format; I cannot find a specification for it. It contains physical measurements and/or rock descriptions from wellbore core samples. It’s fairly gross. The example here is substantially simplified:

text = """
30     1
     2001.10     0.00   2.11
40     1   2
     -1002.0000 34.5678
30     1
     2001.90     0.00   1
36     1    1
    Sst.Lt-gry. Pyr.
40     1   2
        18.72400    15.45700
30     1
     2002.90     0.00   2
36     1    1
    Sst.Lt-gry. W-cmt.
"""

This example contains data records for three depths in the wellbore:

  • Record type 30 gives the depth of the following group of records.
  • Record type 36, if present, contains a string in a DSL.
  • Record type 40, if present, contains the data whose fields are listed in another record type.
  • I don’t think there can be more than one ’30’ record for a given depth, and in my solution I assume there cannot.

There are several other record types, but I’ve left them out of this example.

I’ve written a parsing expression grammar (PEG), using Python parsimonious, to describe this format:

from parsimonious import Grammar

grammar = Grammar(
    r"""
    file          = data_blocks+

    data_blocks   = depth_block descr_block? data_block?

    depth_block   = "30" WS "1" WS depth WS NUMBER WS NUMBER WS
    descr_block   = "36" WS "1" WS "1" WS description WS
    data_block    = "40" WS "1" WS record_count WS DATA WS

    record_count  = NUMBER+
    depth         = NUMBER+
    description   = SENTENCE+
    field_name    = SENTENCE+

    WS            = ~r"s*"
    NUMBER        = ~r"(-.0-9)+"
    DATA          = ~r"(- .0-9)+"
    COMPANY       = ~r"(-_A-Z)+"i
    SENTENCE      = ~r"(-., /ÅA-Z)"i
    """
)

And this parses successfully, producing an abstract syntax tree (AST):

ast = grammar.parse(text)

According to the docs, the usual approach now is to subclass the NodeVisitor class in parsimonious to crawl the AST, returning whatever you need from each node’s special method (for example, the visit_description() method determines what gets returned from the description nodes). Here’s my node crawler:

from parsimonious import NodeVisitor

class FileVisitor(NodeVisitor):
    
    def visit_file(self, node, visited_children):
        data = {}
        for record in visited_children:
            data.update(record)
        return data

    def visit_field_block(self, node, visited_children):
        *_, fields = visited_children
        return fields

    def visit_field_row(self, node, visited_children):
        *_, field, _ = node.children
        return field.text.strip()
    
    def visit_data_blocks(self, node, visited_children):
        depth, descr, data = visited_children
        descr = descr(0) if isinstance(descr, list) else ''
        data = data(0) if isinstance(data, list) else ()
        return {depth: {'descr': descr, 'data': data}}
    
    def visit_depth_block(self, node, visited_children):
        _, _, _, _, depth, *_ = node.children
        return float(depth.text)

    def visit_descr_block(self, node, visited_children):
        *_, descr, _ = visited_children
        return descr

    def visit_description(self, node, visited_children):
        return node.text

    def visit_data_block(self, node, visited_children):
        *_, data, _ = visited_children
        return data
    
    def visit_DATA(self, node, visited_children):
        return (float(x) for x in node.text.split())
        
    def generic_visit(self, node, visited_children):
        return visited_children or node

I run it like so:

fv = FileVisitor()
fv.visit(ast)

The result is this dictionary:

{'data': {2001.1: {'descr': '', 'data': (-1002.0, 34.5678)},
  2001.9: {'descr': 'Sst.Lt-gry. Pyr.', 'data': (18.724, 15.457)},
  2002.9: {'descr': 'Sst.Lt-gry. W-cmt.', 'data': ()}}}

Which is what I want, but my question is: is there a more efficient way to write this NodeVisitor? In particular:

  • Can I avoid the data = data(0) if isinstance(data, list) else () business, which I seem to need to deal with the data (and description) node sometimes being empty?
  • Writing things like _, _, _, _, depth, *_ = node.children feels a bit fragile and hard to maintain, which obviates solving the entire problem this way. Am I missing something?

I know I can do all this with string processing or regex, and I’ve done both. I’m interested in using a PEG-based method, because I’m drawn to the idea… but clearly I’m a little out of my depth! I guess I was hoping to be able to focus on maintaining the grammar, but writing that was relatively easy (assuming I’ve done it in a reasonable way!). The hard part was writing this tree crawler thing. So I’m wondering if I just swapped one kind of fragility (chained string methods or lengthy regexes) for another.

lock screens – unlock my pixel 2xl withou losing data

1 hello google community i am hoping to have some help with my google pixel 2XL please. i need to unlock my google pixel 2xl with out losing my data i cant
afford to buy software so i downloaded a app called drfone, unfortunately does not support pixel at this time.
I am not the most computer or tech informed when it comes to these things so i went to a local phone store and ask if they have software to do this and still no luck. i also tried to use some you tube tutorials and did not have luck there either due to my lack of ability to obtain some of the resources or actions that they needed me to perform from the phone because i cannot get into the system. i figured out the simple solution of doing a hard reset but
i cant lose all the important things on my phone because i need them for court and all of my clients of 20 years for work please help***

—thanks and god bless
leslie bishop

How should I manage my data that needs to be associated with rank (Unity)

So I am making a game with a similar content progression to Clash Royale. Essentially u have ranking points (Identified as Trophies), and the number of trophies you have will determine what content you will have access to in the game. So for example every 100 ranking points, you will be able to find new types of cards in chests, new chests in general or new maps. In my game, I want it to be somewhat similar, but I also have some other data that changes based on rank points that is more specific to my game, such as army supply. I’m trying to figure out how I can implement this in a manageable way.

Maybe this is overkill, but this is my design so far:

enter image description here

Basically I have my RankContentItemBase class which has a ranking points int and an IsUnlocked method that returns whether or not the passed in rank is > than the rank passed in. Then I extend this with classes with classes that add the data type I wanna work with (Int, Troop, Map, w/e).

I then have a Generic base container class that has a method for getting all unlocked item in the list of T contents that is extended to contain the concrete RankUnlockItembase types.

I’ve basically structured things this way so it’s easy for me to add new types of items that I want unlocked by rank without having to do much work. Also it prevents things from being coupled together.

Just curious what ppl think of this setup, and what kinda setup you would go with?

Thanks

opengl – Data structure for collecting entities for instanced rendering

My game, a citybuilder, has many simple entities that rendered via glDrawArraysInstanced. A large city has over 600,000 entities, but most of those entities are one of a few hundred meshes. Every frame, I need a way to collect all those entities so that every entity with the same mesh, texture, and shader pass can be rendered with one draw call. Since my game thread is separate from my render thread, I currently use a data structure, which I call the draw buffer, to collect a plan for what order to draw things in.

This data structure has become a real problem. It’s essentially a three dimensional chain of pointers to dynamic arrays, with the first dimension being shader pass, the second mesh, and the third texture. Every frame, the game goes through all entities (which are not in any particular order), filters out the ones that aren’t in the view frustum, and inserts that mesh’s data into the data structure. The draw buffer takes up a lot of memory and is highly fragmented.

I feel like this isn’t the right approach, but I’m not sure what the right approach is. I’m trying to figure out if there is a way to do it without storing what I plan to do, but I do think that can be done without multiple passes on the entity list. Maybe I can keep a master version of the data structure without view frustum culling and compute view frustum culling somewhere else. Then I wouldn’t have to rebuild the data structure every frame. Instead I would have to update the data structure every time something is added or removed — fortunately entities never change shader pass, texture or mesh, so entities will always stay in the same place in the master data structure.

I hope this makes sense to someone because it barely makes sense to me. The question is, can I solve this problem with a better data structure, or should I consider a different approach entirely? Thanks for any advice you guys have.