Same Icon on a folder and its nested sub folder in Windows 7

enter image description here

Does Window 7 provide such a feature where the same Icon can be applied to folders nested folders? Even if a new folder is created it should have the same folder.

The images are shown of all folders, which in my machine are nested under a Primary folder named academy.

algorithms – Nested loop complexity

I am working through MIT 6.006 OpenCourseWare as taught in Fall 2011. Problem 1.2c asks for the time complexity of an algorithm which finds a peak element (i.e. all neighbors are less than or equal) of an M x N matrix. My solution does not match theirs and appears to hinge on the complexity of a nested loop.

The algorithm creates a cross which divides the matrix into four “subproblems”. It finds the max on the cross, checks neighbors, and recurses as needed:

def algorithm3(problem, bestSeen = None, trace = None):
    # if it's empty, we're done 
    if problem.numRow <= 0 or problem.numCol <= 0:
        return None

    midRow = problem.numRow // 2
    midCol = problem.numCol // 2

    # first, get the list of all subproblems
    subproblems = ()

    (subStartR1, subNumR1) = (0, midRow)
    (subStartR2, subNumR2) = (midRow + 1, problem.numRow - (midRow + 1))
    (subStartC1, subNumC1) = (0, midCol)
    (subStartC2, subNumC2) = (midCol + 1, problem.numCol - (midCol + 1))

    subproblems.append((subStartR1, subStartC1, subNumR1, subNumC1))
    subproblems.append((subStartR1, subStartC2, subNumR1, subNumC2))
    subproblems.append((subStartR2, subStartC1, subNumR2, subNumC1))
    subproblems.append((subStartR2, subStartC2, subNumR2, subNumC2))

    # find the best location on the cross (the middle row combined with the
    # middle column)
    cross = ()

    cross.extend(crossProduct((midRow), range(problem.numCol)))
    cross.extend(crossProduct(range(problem.numRow), (midCol)))

    crossLoc = problem.getMaximum(cross, trace)
    neighbor = problem.getBetterNeighbor(crossLoc, trace)

    # update the best we've seen so far based on this new maximum
    if bestSeen is None or problem.get(neighbor) > problem.get(bestSeen):
        bestSeen = neighbor
        if not trace is None: trace.setBestSeen(bestSeen)

    # return if we can't see any better neighbors
    if neighbor == crossLoc:
        if not trace is None: trace.foundPeak(crossLoc)
        return crossLoc

    # figure out which subproblem contains the largest number we've seen so
    # far, and recurse
    sub = problem.getSubproblemContaining(subproblems, bestSeen)
    newBest = sub.getLocationInSelf(problem, bestSeen)
    if not trace is None: trace.setProblemDimensions(sub)
    result = algorithm3(sub, newBest, trace)
    return problem.getLocationInSelf(sub, result)

The instructor provides the complexity for getMaximum as O(len(locations)), getBetterNeighbor and getLocationInSelf as O(1), getSubproblemContaining as O(len(boundList)), and all trace calls as O(1). The crossProduct is computed as:

def crossProduct(list1, list2):
    answer = ()
    for a in list1:
        for b in list2:
            answer.append ((a, b))
    return answer

The solution states, “a single call of the function (not counting the recursive call) does work proportional to m + n.” I don’t understand this.

Isn’t crossProduct O(mn)?

My reasoning is that for an M x N matrix, getMaximum must traverse the dividing cross (one row, one column) which contributes O(m + n). The getSubproblemContaining contributes something linear, O(m) or O(n). Everything else besides crossProduct is O(1), the complexity of crossProduct not being provided, so that the recurrence relation is

T(m, n) = O(mn) + O(m + n) + cO(n) + T(m/2, n/2)   for some constant c
        = O(mn) + T(m/2, n/2)

The recurrence reduces via the geometric series to O(m + n),

T(m, n) = O(mn) + O(m + n)
        = O(mn) 

which yields T(n,n) = O(n^2). The solution provided is O(n). The crossProduct term appears to be the discrepancy.

VMware nested ESXi + pfSense + VLAN trunk lab

I got a lab issue. the env is:

  1. A nested ESXi env
  2. 3 x ESXi 6.7 U2 VMs within the 1st level ESXi
  3. One VCSA 6.7 U2 VM within the 1st level ESXi
  4. A pfSense 2.4.5-p1 VM within the 1st level ESXi
  5. 2 x win10 VM within the 1st level ESXi
  6. A Ubuntu 18.04 VM within the 1st level ESXi
  7. A vds/vss created and configured as a trunk (0-4094)
  8. All above VMs NIC are vmxnet3

The lab facts are:

a). 2 x win10 VM setup the VLAN ID xxx and connect to the vds/vss are able to communicate with each other
b). Ubuntu VMs also connect to the same vds/vss and configure the same VLAN ID xxx, but CAN NOT communicate to other VMs
c). The 3x ESXi VMs also connect to the same vds/vss and setup the VGT attached to VLAN ID xxx, but also not communicate with each other.

Questions:
does the pfSense trunk pick the client? how come win10 works perfectly but ubuntu and ESXi VM are not working? Did I miss any configure?

javascript – Returning a promise with nested conditionals from a Firebase function?

This Firebase cloud function must return a promise but my understanding of nesting them is shaky. This function performs a Firestore read and then sends a remote message if a condition is met (based on data from that read).

I first return the call to get the document because get() itself returns a promise. And if the call to get() fails, that will be reflected in the promise and the function will properly terminate because I’ve returned that.

However, if get() doesn’t fail, then() is called before the promise is ultimately resolved. So within the then() block, if the boolean that I got from Firestore is false (for example), because this is now a synchronous operation, I can simply just return (which returns out of the then() block) and the original promise will be resolved and the function terminates. However, if the boolean is true, I do send the remote message and return that call to send() because it too returns a promise.

export const pushNotifyConnection = functions.https.onCall((data, context) => {
    const recipientUserId = data.recipientUserId

    return admin.firestore().collection("userSettings").doc(recipientUserId).get().then((snapshot) => {
        if (snapshot.exists) {
            const allowConnectionNotifications = snapshot.get("private.connectionNotifications") || false

            if (allowConnectionNotifications) {
                const fcmToken = snapshot.get("private.fcmToken")
                const message = {
                    ...
                }

                return admin.messaging().send(message)
            } else {
                return
            }
        } else {
            return
        }
    })
})
  1. Do I have all of this right?
  2. If I do, and I send the message and return that promise, what happens to the original promise that was returned (from get())? Is it trumped by the final nested promise?

pattern matching – Rust Beginner: flatten nested matches

This is how I implemented the guessing game – chapter 2 of the Rust book: https://doc.rust-lang.org/book/ch02-00-guessing-game-tutorial.html

use std::io;
use std::io::Error;
use std::cmp::Ordering;
use std::num::ParseIntError;

use rand::Rng;


enum MyReadLineError {
    FailReadLine(Error)
}

#(derive(Debug))
enum MyReadU32Line {
    FailReadLine(Error),
    FailParse(ParseIntError)
}

​
fn my_read_line() -> Result<String, MyReadLineError> {
    let mut input = String::new();
    let result = io::stdin().read_line(&mut input);
    match result {
        Ok(_) => Ok(input),
        Err(error ) => Err(MyReadLineError::FailReadLine(error)),
    }
}

​fn my_read_u32_line() -> Result<u32, MyReadU32Line> {
    match my_read_line() {
        Result::Ok(line) =>
            match line.trim().parse::<u32>() {
                Ok(value) => Ok(value),
                Err(error) => Err(MyReadU32Line::FailParse(error)),
            }

        Result::Err(MyReadLineError::FailReadLine(error)) => Err(MyReadU32Line::FailReadLine(error)),
    }
}
​
fn main() {
    println!("Guess the number!");

    let secret_number = rand::thread_rng().gen_range(1, 101);

    loop {
        println!("Please input your guess.");
        let guess = my_read_u32_line();
        match guess {
            Ok (value) => match value.cmp(&secret_number) {
                Ordering::Less => println!("Too small!"),
                Ordering::Greater => println!("Too big!"),
                Ordering::Equal => {
                    println!("You win!");
                    break;
                },
            }
            Err (_) => println!("Sorry I couldn't read a u32 from your input! Please try again."),
        }
    }
}

This works as expected but I would like to flatten the matches so that doesn’t look at verbose, is that possible. Also is there any other way to make that code look better, more readable?

time complexity – Big-O of iterating through nested structure

While trying to understand complexity I run into an example of going through records organized in following way:

data = (
  {"name": "category1", "files": ({"name": "file1"}, {"name": "file2"}),
  {"name": "category2", "files": ({"name": "file3"})
)

The task requires to go through all file records which is straight forward:

for category in data:
  for file in category("files"):
    pass

It seems like complexity of this algorithm is O(n * m), where n is length of data and m is max length of files array in any of data records. But is O(n * m) only correct answer?

Because even there are two for-loops it still looks like iterating over a global array of file records organized in nested way. Is it legit to compare with iteration over different structure like that:

data = (
  ('category1', 'file1'),
  ('category1', 'file2'),
  ('category2', 'file3'),
)
for category, file in data:
  pass

…where complexity is obviously O(n), and n is a total number of records?

performance – What Method / Formula does a Nested Loops Operator use for row estimation?

The following, simple query in AdventureWorks:

SELECT  *
FROM    Person.Person p
        JOIN HumanResources.Employee e
            ON p.BusinessEntityID = e.BusinessEntityID

Gives the following execution plans:

New estimator plan

If I look at the above plan, I can see the index scan and index seek both (correctly) estimate 290 rows, however, the estimated loops operator that joins the two, estimates 279 rows.

Old estimator

The old estimator also correctly guesses 290 rows out of both the seek and the scan but the nested loops estimates 289 rows which in the case of this query is a better estimate.

Is it true then that in the case of the new CE the optimizer estimates that when it is joins 290 rows from the index scan and 290 from the index seek, there will be 11 rows that do not match?

What method / formula does it use to make this estimate?

Am I correct in saying whatever said method is, that it has changed from the earlier CE version as that has made a different estimate?

I realise the “bad” estimate of the new CE is not significant enough to detriment performance, I am just trying to understand the estimators processing

layout – How to organize nested groups of forms where a user can just keep adding to them?

As far as I understood, user may have many records and for many records scenario, tabular structure is very useful (your second option).

At first, you will have empty table of records and in above toolbar there will button to create a new Project service. On the button click, you can open a pop up(I assume Project Service Table is not opening in pop up already).

You can provide drop down to Service and other fields on that pop up window. For Breakdown option, you may have editable table where + sign to add Breakdown and – is for removal. Also,one save button at the bottom of pop up. Once, you save the record, it will be displayed as first row in table.

On edit mode, you can populate same form with all values.

For your reference:

Manage Page for list all your Project Service. Give Add/Edit/Delete buttons at the top of this table.
enter image description here

When create, the pop up should open with this kind of form.
enter image description here

Sample for breakdown table inside above window as other form item:
enter image description here

Hope, you will get the idea. Thanks.

java – Iterate a HashMap with nested HashMap values in javascript by using thymeleaf

This is the object added to the model:

HashMap<String,HashMap<String,Integer>> eventByMonthAndYear;

How i’m trying to iterate it

I’ve tried these solutions but none has worked so far for me.

Iterate HashMap using thymeleaf

My efford


/*<!(CDATA(*/

   /*(# th:each="entry: ${eventByMonthAndYear}")*/

    console.log(/*((${entry}))*/);
    
    /*(/)*/     
    
/*))>*/

No object is printed, how can i at-least retrieve the first HashMap?

optimization – Nested loops join algorithm – additional available page buffers

The basic version of nested llops join algorithm only uses two main memory page buffers for loading the pages.

But if additional page buffers are available the I/O cost can be reduced.

Should I chose to use the additional available page buffers to hold more pages of the relation considered by the outer loop or the inner loop?

And why?

I apologies if this is the wrong place to post this question
Thanks in advance,