Should a web-based UI rely on the browser back button?

Question: The back button is a great "get out of a flow's dead end" option that browsers provide. Should a UI rely on the back button as the only method to allow a user to get to the previous page or should the UI provide an additional, site-specific button to return to the previous screen?
A common scenario that comes to mind with this is an eCommerce site that has a list of products. A user clicks on one of the products to view a details page. Then after viewing the details, they would like to go back to the list to click another product and view its details. Should the UI assume a user will use the browser back button  or should the web site provide a link or button that allows users to "Go back to Your Results", leaving the browser back button as an alternative option?
Comment: Whatever you do, don't cut the browser's back  button out of the picture. There is little more frustrating (especially on mobile) than hitting back and getting "Confirm Form Resubmission" instead of the previous page.
Comment: I can live with "Confirm Form Resubmission". That serves a valid security purpose and keeps me out of trouble. The one that really drives me insane is clicking Back and, rather than going back, returning to exactly the same page!
Comment: @aslum I absolutely agree. The back button has been referred to as the "2nd most used navigation feature". http://ux.stackexchange.com/questions/36017/is-the-browser-back-button-still-the-second-most-used-navigation-feature I ask the question because the popularity of the back button is likely (I have no source for this) related to a poorly crafted user flow; "I don't know what I did to get here, but this isn't the page I want. Time to hit the back button." If we crafted a good flow that includes going back in pages, should the back button be the only tool or should we offer an alternative?
Comment: I've grown accustomed to using my middle mouse button on web applications like you describe. I open product details in another tab and close the tab to "go back". One advantage is you never have unexpected results after pressing the back button, another is that your scroll position within the listing doesn't change. Navigation is a big pain with the majority of web apps out there, I've seen very few do it exactly right.
Comment: Another question about the back button: http://ux.stackexchange.com/q/7216/95
Comment: Rely on? No. Account for? Absolutely.
Answer: A web application should always strive to be compatible with the browser's back button. That is, using the back button should have deterministic results within that application that match expected behavior (global consistency).

A common scenario that comes to mind with this is an eCommerce site
  that has a list of products. A user clicks on one of the products to
  view a details page. Then after viewing the details, they would like
  to go back to the list to click another product and view its details.
  Should the UI assume a user will use the browser back button or should
  the web site provide a link or button that allows users to "Go back to
  Your Results", leaving the browser back button as an alternative
  option?

However, a web application should generally not rely solely on the browser's back button for all navigation that might be considered related.
Sadly, one of the top reasons for this is that some people are afraid of hitting their back button within certain web applications due to broken or inconsistent browser control/state related behavior found in many AJAX heavy web apps, where using the back button may not result in the effect the person using it anticipated.
Secondly, if the page was spawned from a new tab (or a bookmark!), there may not be a back button. While the person using the app should ideally still have the original tab open, if you want them to be able to access the page they came from, make sure to give them a way to do so from the context of the page they are currently on.

Using your example, say the list was a static sale page (instead of a dynamic search). What if the person browsing the site bookmarks an individual product, then closes that session. When they load that bookmark, what navigation options do you want available to them? What navigation options do you think they will want at hand? It's a good idea to make these a consistent component of your UI, hence not worth solely relying on the back button in other instances.
To expand slightly on this, providing back-navigation options within your UI gives you control over their presentation: this means you can assuage anxiety over what an action result will be by clearly delineating what using the control will do.
For example, consider whether someone would have any uncertainty over what the following might do:

Back (Back to where? also applies to the browser's back button,
because we all know it doesn't always do what we expect, depending on
the web app, and people don't know what your app will do until they
try, which can be a hesitation point)
Back to listings (which
listings? if I come here from a bookmark, do I have any clue what I
was doing that got me here?)
Back to [associated product category]
(Well, that's nice, it is functional and not a concern for failing to
be deterministic, but should probably be represented elsewhere)
Back to the January Sale Event (hey! that's what I was looking at when I came here! it's specific enough that I can expect to end up… where I would expect to go) (aka it matches the navigation context map that brought me to this page)

(and you probably want to use a wording such as "More of" rather than "Back to," depending on the context you end up using such a control in, and when the navigation from it clearly ties to specifically cross-related results)
That last example gives you what you want to strive for: a reduction of anxiety for people using your application by making clear what the related outcome will be.
Moreover, this gives you extra behavior beyond what is necessarily available in just the back button. While the back button should simply work, this control is then present if someone opens the page two months later. If they do click on it, you can present the related page for the "January Sale Event" but with a message at the top saying the event is now over, we're sorry you missed the amazing deals we were having, but see [these new events/products/etc].

These navigation points are an opportunity not only to have a backup back-navigation control that you know the person using the application will feel comfortable interacting with, but also one where you control where it goes, and which provides you an opportunity to communicate with the user under a fairly tightly managed context. They can, if managed correctly, provide more functionality than the browser's back button alone does, enhancing the experience rather than simply cluttering the screen with directly duplicated controls/functionality.
If you are going to implement back-navigation controls, make them clear, consistent, and consistently available (at least on the page types where they make sense). Try to provide extra value over what the back button alone represents, both to yourself and the people using your application.
If you are just going to literally duplicate the browser's back button functionality with a control that says back or has some similarly representative icon… don't bother. Just make sure the browser back button behavior works properly. (which you should always be doing anyway)
Comment: Agreed. Don't mess with the back button. Websites that did this were a problem in 1999 (Jakob Nielsen, [The Top 10 Web Design Mistakes of 1999](http://www.nngroup.com/articles/the-top-ten-web-design-mistakes-of-1999/) and are still a problem today.
Comment: Yes, it's very much a case of two wrongs don't make a right: make sure the back button works in an appropriate, consistent fashion. I've shadowed so many people while training/etc & they've hesitated at a back navigation task and then turned to ask if the back button would work or spent time hunting for some other control rather than just using it—but that's not an excuse for breaking it too. It can be an argument for supplementing it, though, especially with anything showing explicit action outcomes. (especially key around state change operations, e.g. progressing through a form or cart)
Comment: I've found this answer useful so many times while developing mobile interfaces that I felt you deserved more than just a single upvote from me - so have a well deserved bounty.
Answer: Yes. You should rely on the browser back button.
Users expect the button to be there, so make sure it's functional.
But should you mimic the same button with its functionality?
If your application or website needs it, yes, but not always exactly the same.
In some cases, like your example of a webshop, a button that just says back or an arrow might not be sufficient. In this example a breadcrumb navigation is in order, or a button or link that says "back to results" (some more context for the user's sake).
Answer: Rely is the wrong word
You're asking if you should rely on the button, which you shouldn't. You're also asking if you should offer another option. Which you could, and in certain situations, should.
So here's the thing:
Back button
You should never, ever, break the behavior of the back-button. At all times, you must strive to keep it's functionality in tact, as it's part of the behavior of every single browser out there. It's a user's handle on the situation, their help in case of error.
It's a life-vest which you shouldn't remove.
Your own UI
In a lot of cases, things like a crumb-trail or a "back" button could be useful. Maybe because the browser's back-button is hidden on a certain OS, maybe because it's slightly less sophisticated, or maybe just to keep users looking at your app instead of the browser.
In general, you can't really go wrong with adding some courtesy navigation.
Conclusion
Should you rely on it? You can, as long as you make sure not to break it when you don't. Should you add your own? If it seems convenient, if you'd use it, yes.
And lastly: measure. See if people use it if you do add it.
Comment: Great points. I upvoted for the importance of that last sentence:
"And lastly: measure. See if people use it if you do add it."
Comment: I think Dirk has a great point at the very beginning of the comment.  **Rely** is the wrong word. You should not "rely" on the fact that a user will use a browser back button over a different type of navigation style.

The most important factor is that you **support** the browser back button. Our applications should not break native behaviors.
Answer: I usually try to provide both on-screen back-button and support for browser back-button.
Reasons:

If the user is immersed in the flow of the app, an on-screen back button can help keep focus inside the flow and avoid losing the user's attention.
Supporting the browser back button is important to me, even at great cost,  because it's presumptuous design to assume the user will just use the on-screen button rather than the browser's back button.

Note that there are some rare exceptions where you want to intentionally avoid or break back button behavior (e.g. security forms).
Comment: Breaking the back button is never ok, not even in rare cases. If the user is not permitted to submit a form twice, that is to be checked at submission time, not when the user clicks back to the form. The reason it is never ok to break the back button is, that the user may need to click the back button multiple times to go back past your page and possibly end up on a page which isn't even part of your app. (I consider it a design flaw in the browser, that it is even possible for a webpage to break the back button.)
Comment: It may be a design flaw in the http spec, rather than in the browsers that implement that specification. The spec allows the client to send a POST request, which cannot be safely repeated without the user's permission and get a page to display in response. Maybe the spec should not have allowed that.
Comment: @kasperd in UX I've tried to stay away from the word 'never' :-)  In all seriousness, I think there are many examples where it makes sense to break the browser's native back behavior. When content is loaded via Ajax, or when you don't want users to be able to navigate back to a one-time security page, it's common to use history.pushState() or history.replaceState() to break the native browser behavior for very solid UX reasons.
Answer:
the browser back button MUST work as expected.
your web UI back button MUST NOT provide a back button unless it does the same thing the browser back button does

example: filtered category view in ecommerce - if the back button return to unfiltered category view it MUST NOT look like a back button, but rather like a breadcrumb.

you SHOULD provide contextual navigation links, but they MUST NOT look like back buttons

The main reasoning behind the back button behaviour argument - take this example scenario:

I filter our products with price < 1000
I click one product to get to the detail page
I click the "ui" back button
I see category page with all items
as customer I think "I clicked the back button and the filters are lost" (and therefore there is no reason to try browser back button)
I swear proportionally to the complexity of the filtering I had set up
If there was no "ui" back button I would most probably just use the browser's back button as I'm used to.
Comment: My argument is purely anecdotical. Although - see update.
Comment: You've stated a lot of this as absolutes without giving any reasoning why.  I'm nod disagreeing with you, but please edit your question to include the reasoning behind the suggestions.
Answer: One should not solely rely on the back button.
Why?
Because Smart phones on average are growing at a faster rate than humans hand sizes.
Look at where these back buttons typically are.
Top right (general)

Iphone standard view (bottom left)

Iphone 6 horizontal view (top left)

Now lets take a look at how users hold their devices

Sometimes its difficult to reach that back button because users hands arnt large enough to easily hit the default back button in all positions. Thus if its possible to provide an easier way to traverse do so.
See this trend in regard to screen size

Another reason to not rely on the back button is because there may be scripts preventing a user from going back and getting the result they expect due to the website design
Comment: um.... the back button is at the bottom on iPhone LOL and most Androids
Comment: You make some good points about button position and button size for mobile layouts, but I'm afraid it focuses more on how specific smartphone OS user interfaces place and size their back buttons.
Comment: Thanks @BenjaminS your 100% right. I answered this pretty late and I didnt want to replicate any of the prior content that was covered pretty well here.
Comment: Your title is confusing to read. "No one should not solely rely on the browsers back button." is the same wording as "One should solely rely on the browsers back button."
Comment: @DavidBaucum thank you for that grammar was awful. I think I updated it to make it somewhat more clear.  also as per the back button in the bottom in 2015 that was less common it appears apple and android have put it in an area that is easy to access regardless of our growing phones sizes.
Answer: I believe that you should not rely exclusively on the browser's back button.

If the user is interacting with your site to get somewhere, I think it's reasonable they would expect to be able to return the same way.
Displaying where the user is within the context of the website is important so the user has a frame of reference where they are in the overall site.

*edit for clarification: you should definitely support the browser's back button as well. Just want to make sure that was clear. I was just adding on the reasons you would not want to exclusively rely on the browser's back button.
Answer: No, you shouldn't rely on the browser's back button.
While its easy to say that you can expect it to be present and that you can expect it to always function a certain way, that's simply not the case.

Because the back button exists in an application outside of your own,
  you can't reasonably expect it to be present or function in any
  specific way. If there's anything that the Responsive Design revolution has taught us, its that you can't predict anything about the context of a user's browsing.

What if, in 2017, Google decided they didn't want to support the back button in Chrome anymore?
We can cry heresy all we want at the moment, but Google could do that for any number of reasons that we cannot predict. So could M$, Apple, Mozilla, or any other browser vendor. Then you're left relying on a feature that no longer exists.
Answer: There's a lot of stuff here about not removing or interfering with the browser back button but I don't think that's what the questioner is asking.
The Browser's back button is there for the user and shouldn't therefore form a part of your projected user journeys. The user may have customised their browser so that the back button does not show - If you are relying on this then you will end up with a broken user journey.
I wouldn't rely on anything that's likely to use the JavaScript "history.back" function either (effectively a back button press).
If your user journey shows that a user is likely to want to skip back to a search results page or somewhere else then you should provide an explicit method for them to do this - "Go back to Your Results"
Comment: you are absolutely correct in your first sentence. There is no question about the importance of leaving the back button alone. The real question is, should the UI provide a similar tool.
Comment: ...and that's what I dealt with in the other three paragraphs ;)

I hope you got an answer that works for you Benjamin!
Answer: I wouldn't use it exclusively.
The first example that comes to mind is Google Chrome for Android. Every "tab" is a new instance, and so opening a new window is akin to starting a brand new session. In these instances, the back button will simply take the user to the homescreen instead of actually going back. The same thing will happen if a user chooses "Open link in new tab".
Due to that functionality, having some navigational function on the website would allow the user to keep going without breaking the flow of things.
As a side note: I have somewhere between 40-100 tabs in Chrome because of this. It is really quite easy to accumulate tabs by using the browser normally, and not all users will actually know how to deal with this behavior.
Answer: Speaking not as a designer but as a user; anytime I have to default to my browser's back button to continue navigating a site, I can't help but consider it a failure of the site's UX. The more I have to use it, the more frustrated I get. The only exceptions are instances like "What was that seller's address on the last page?" or "What did I put in that form field on the last page again?", with the intent of returning directly to the page I'm already on.
IMHO, the native back button should never be the user's only way out of a page, even if they're trying to return to a previous listing page. There are myriad simple, tested, effective options to provide navigation for your users - a < back to listing link at the top of a page, breadcrumbs, or any of the other answers' suggestions work well.
Answer: I would expect that the back button just brings me back exactly to the last page where I have clicked on a link or submit button. Like "Open in New Window", closing the new window, and bringing the first page to front again (as MDeSchaepmeester describes above). The browser should not send a single bit over the network, just fetch the page from cache exactly like it was; no re-submittal of the form (booking another room in the hotel), no side-action at all.
As the back-button is ill-specified from the beginning (see bdsl's comment) and does something different on every browser (recently Google decided that Chrome's back button clears forms, which broke my puristic scientific data site which was unchanged since 1998 and relied on the back button), you should do everything to keep the user from pressing the back (=random) button, but provide your own, easily understandable navigation tools.
Comment: Welcome to the site, @Peter. If I'm understanding correctly, you appear to be suggesting that the website should put the onus on the user to use an in-page button rather than the browser's built-in button.   This approach seems like it would give a bad experience for the many users who are in the habit of clicking the browser's back button and may not even notice your in-page back button.  Can you explain why you believe that trying to force users not to use the browser's back button provides a better experience (better than having one button or having two consistent buttons)?
Comment: Because the back button behaves different in every browser; as said, on Chrome it goes back to the last page, but it erases all form fields. I'm using a small textarea with a save button in my website, where the users can add notes to a chronological list. If they find a typo in the result, the usually press the back button, correct the typo, and save again. This works in all browsers, but for the newest Chrome. As the result of the back button is not predictable, it cannot be integrated in any reasonable user interface.
Comment: Chrome now has changed: the back button reloads the page (and resubmits, if it was left by a POST), and then magically inserts the last field entries into the new page. Must have been fun to program this, I wonder how they handle it if the "reloaded" page happens to have different fields now.
Answer: You should rely on the browser back button but not exclusively!
Best case scenario:

back button on the screen
support for browser back-button
Comment: Can you expand more on why it shouldn't exclusively rely on the back button?
Comment: my best case scenario explains it. have both options at all time


kotlin flow how to drop old value if the same type is on the flow

Question: let us say I have flow like this
 val myflow = flow{
        emit("s1")
        emit("s2")
        emit("s2")
        emit("s2")
        emit(2)
    }

I want to collect
s1,s2(third),2 , I want to drop first,seconds s2
Comment: At the moment when you get the first of the three `s1` values, how can you determine without looking into the future that there will be more of the same values and that it needs to be dropped? If it does not matter which one of the identical values will be collected, you can use [distinctUntilChanged](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/distinct-until-changed.html) function.
Comment: I believe this related to emiiter side not collector(future)
Comment: If you're talking about the emission side, then you need to solve this filtering problem before you even emit to the Flow. It depends on what you're doing to surface new values to emit what the logic would be to filter out items that you know are going to be repeated.
Comment: I do believe this also can be done on the collectors,  collectLastest is doing a very similar job however it will skip all types (s1,s2)
Answer: This can be accomplished a couple of ways.
Using your example Flow, we can add a call to distinctUntilChanged before the collect and it will only output values that are not sequentially duplicated
    myFlow.distinctUntilChanged().collect {
        println("Distinct collect: $it")
    }

    /*
      Distinct collect: s1
      Distinct collect: s2
      Distinct collect: 2
     */

distinctUntilChanged also can accept a lambda, so you can compare the old and new on your own rules to pass items through the filter.
We can also do this with a hot flow.
These only send newly added values after a subscriber is started, and never close themselves until the coroutine is canceled.
fun test_distinct() = runTest {
    val stateFlow: MutableStateFlow<Any> = MutableStateFlow("s1")

    launch {
        stateFlow.collect {
            println("StateFlow: $it")
        }
    }

    launch {
        stateFlow.emitDelay("s2")
        stateFlow.emitDelay("s2")
        stateFlow.emitDelay("s2")
        stateFlow.emitDelay("s2")
        stateFlow.emitDelay(2)
        stateFlow.emitDelay(2)
        stateFlow.emitDelay("s2")
        stateFlow.emitDelay("s1")
        stateFlow.emitDelay("Other")
        stateFlow.emitDelay("Test")
        stateFlow.emitDelay("Semi")
    }
    /*
        StateFlow: s1
        StateFlow: s2
        StateFlow: 2
        StateFlow: s2
        StateFlow: s1
        StateFlow: Other
        StateFlow: Test
        StateFlow: Semi
     */
}

suspend fun MutableStateFlow<Any>.emitDelay(value: Any) {
    delay(400)
    emit(value)
}

Here I made the emit delay function just to exemplify the way the state is updated. Otherwise it doesn't get each change as effectively in a test environment. This MutableStateFlow will stay open until currentCoroutineContext().cancel() is called from the scope that the MutableStateFlow is being collected in.
If the values must be unique to the entire lifetime of a flow.... You can then have a list of seen values that you can reference in a filter function.
fun test_distinct() = runTest {
    val flowValues = mutableListOf<Any>()
    val myFlow = flow {
        emit("s1")
        emit("s2")
        emit("s2")
        emit("s2")
        emit("s1")
        emit(2)
        emit(3)
        emit("s1")
    }

    myFlow.filter {
        if (flowValues.contains(it)) false
        else {
            flowValues.add(it)
            true
        }
    }.collect {
        println("Distinct for lifetime: $it")
    }

    /*
        Distinct for lifetime: s1
        Distinct for lifetime: s2
        Distinct for lifetime: 2
        Distinct for lifetime: 3
     */


Why is my fragment shader not showing any colors?

Question: I am basically following this tutorial about diffuse lighting in OpenGL.
I did some modifications but the idea is the same, at least that's what I think. However, my fragment shader is not showing any colors. I checked and rechecked my uniform variables and light properties and data is ok on CPU side (don't know how to check on GPU side, though).
Here are my shaders where I cannot spot any errors, maybe someone can help me out
VERTEX SHADER
<code>#version 410

in vec4 vposition;
in vec3 vnormal;

uniform mat4 M;
uniform mat4 VP;

out vec4 fcolor;
out vec3 fnormal;

void main()
{
    gl_Position = vposition * M * VP;
    fcolor = vposition + vec4(0.5);
    fnormal = (M * vec4(vnormal, 0.0)).xyz;
}
</code>
FRAGMENT SHADER
<code>#version 410

in vec4 fcolor;
in vec3 fnormal;

out vec4 color;

uniform vec3 lightColor;
uniform vec3 lightDirection;
uniform float lightIntensity;

void main()
{
    vec3 N = normalize(fnormal);
    vec3 L = normalize(lightDirection);
    float visibility = clamp(dot(N, L), 0.0, 1.0);
    color = fcolor * vec4(lightColor, 1.0) * lightIntensity * visibility;
    //color = vec4(1.0); Not even this shows model in complete white
}
</code>
UPDATE
The buffer for my mesh are created like follows, maybe it helps out detecting the problem
<code>void Mesh::initBuffers()
{
    glGenVertexArrays(1, &m_verticesVao);
    glBindVertexArray(m_verticesVao);

    glGenBuffers(1, &m_positionsVbo);
    glBindBuffer(GL_ARRAY_BUFFER, m_positionsVbo);
    glBufferData(GL_ARRAY_BUFFER, m_numVertices * 3 * sizeof(float), &m_positions[0], GL_STATIC_DRAW);
    glEnableVertexAttribArray(0);
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), 0);

    glGenBuffers(1, &m_normalsVbo);
    glBindBuffer(GL_ARRAY_BUFFER, m_normalsVbo);
    glBufferData(GL_ARRAY_BUFFER, m_numVertices * 3 * sizeof(float), &m_normals[0], GL_STATIC_DRAW);
    glEnableVertexAttribArray(1);
    glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), 0);

    glGenBuffers(1, &m_positionsEbo);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_positionsEbo);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_numIndices * 3 * sizeof(unsigned int), &m_indices[0], GL_STATIC_DRAW);

    glBindVertexArray(0);

    m_initBuffers = true;
}
</code>
Commenting all the code related to the normal in shaders results in a correct rendered mesh with colors (or white)
If it helps, you can checkout my code
Comment: In one statement in the vertex shader you do a left multiply with the vertex data and in the other you do a right multiply. One of those is probably wrong.
Comment: Commenting all the code related to the normal results in a correct rendered mesh with colors (or white)
Comment: Good catch but still not rendering. I am starting to think that the normals are not being passed to the shader ... somehow.
Comment: I notice you are specifying your vertices as vec3s in the CPP side but use vec4s in the vertex shader. Change "in vec4 position" to "in vec3 position", you may need to convert to vec4 with something like vec4(position, 1); . Also I would perform colour calculations in the pixel shader using a vec3 otherwise you will get lighting in your alpha channel.
Comment: I changed that, but still not able to see anything. Am I binding the index buffer correctly to the positions and normals of the vertices?
Answer: After checking and rechecking my code over and over again. I finally made it work.
The problem was that I was creating the buffers and assigning locations to the position and the normals buffers
<code>// Positions
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), 0);
// Normals
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), 0);
</code>
However in the vertex shader I was not setting the locations
<code>#version 410

in vec4 vposition;
in vec3 vnormal;
...
</code>
So changing the previous code to
<code>#version 410

layout(location = 0) in vec4 vposition;
layout(location = 1) in vec3 vnormal;
</code>
fixed the application.
Now, I am not really sure why this works, but I remember reading somewhere that OpenGL assigns locations as it sees best, so maybe in my code the location for the normal was not the same as the enabled vertex attrib array. I let someone more experienced clarify this.
Comment: You can use glGetAttribLocation("vposition"); also to get the location without needing assignment in the shader. Although be careful with that, if your attributes are never referenced in your shader the entire attribute may be optimised away and you won't be able to get its location.


DecorationView gets resized when AutoSizing cells are enabled in UICollectionViewFlowLayout

Question: Environment:
UICollectionView that looks like UITableView
Custom UICollectionViewFlowLayout subclass to define the frame of the DecorationView
Self-Sizing cells enabled
Expected behavior:
A DecorationView that should be placed as a background for every section of the UICollectionView

Observed Behavior:
The DecorationView collapses to an arbitrary size:

Seems that UICollectionView tries to calculate an automatic size for the DecorationView. If I disable Self-Sizing cells, the decoration view is being placed exactly at the expected place.
Is there any way to disable Self-Sizing for DecorationView ?
In my UICollectionViewFlowLayout subclass I simply take the first and last cells in the section and stretch the background to fill the space underneath them. The problem is that UICollectionView does not respect the size calculated there:
override func layoutAttributesForDecorationView(ofKind elementKind: String, at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
    guard let collectionView = collectionView else {
      return nil
    }

    let section = indexPath.section
    let attrs = UICollectionViewLayoutAttributes(forDecorationViewOfKind: backgroundViewClass.reuseIdentifier(),
                                                 with: indexPath)
    let numberOfItems = collectionView.numberOfItems(inSection: section)
    let lastIndex = numberOfItems - 1

    guard let firstItemAttributes = layoutAttributesForItem(at: IndexPath(indexes: [section, 0])),
      let lastItemAttributes = layoutAttributesForItem(at: IndexPath(indexes: [section, lastIndex])) else {
        return nil
    }

    let startFrame = firstItemAttributes.frame
    let endFrame = lastItemAttributes.frame

    let origin = startFrame.origin
    let size = CGSize(width: startFrame.width,
                      height: -startFrame.minY + endFrame.maxY)

    let frame = CGRect(origin: origin, size: size)
    attrs.frame = frame
    attrs.zIndex = -1

    return attrs
}

Comment: Could you post a demo on GitHub?
Answer: It's possible that the frames of your decoration views are not being updated (i.e. invalidated) after the frames of your cells have been self-sized. The result is that the width of each decoration view remains at its default size.
Try implementing this function, which should invalidate the layout of the decoration view for each section every time the layout of an item in that section is invalidated:
override func invalidateLayout(with context: UICollectionViewLayoutInvalidationContext) {
    let invalidatedSections = context.invalidatedItemIndexPaths?.map { $0.section } ?? []
    let decorationIndexPaths = invalidatedSections.map { IndexPath(item: 0, section: $0) }
    context.invalidateDecorationElements(ofKind: backgroundViewClass.reuseIdentifier(), at: decorationIndexPaths)
    super.invalidateLayout(with: context)
}

Comment: While I haven't tested your solution yet, it looks like the most promising, I'll definitely give it a try.

Because of this problem, I decided not to go with the self-sizing cells for now.


Ubuntu server 15.04: remote access MySql

Question: I install the MySQL from the Ubuntu server CD (15.04). When installation is finished, I found that the configure files under /etc/MySQL/, such as my.cnf and MySQL.cnf are all empty.
So I want to access my database from other terminals, I did the following job:

Created a user for host % with all privileges;
Made firewall utw  allowing MySQL;
Insert a line in the my.cnf with: bind-address = 0.0.0.0;
Restarted the MySQL service.

It has no effect. Remote connections are still denied.
I checked the variables in MySQL, the bind_address variable shows binding with 127.0.0.1. And the netstat command shows that port 3306 is only bound with 127.0.0.1.
I don't know why the configure information in my.cnf has no effect?
The configuration file shows below:
[mysqld]
bind-address = 0.0.0.0

Any one can help me?
Answer: In Ubuntu 15.04 the MySQL Server configure file is in:
/etc/mysql/mysql.conf.d/mysqld.cnf

You can find bind-address here. Comment it (by inserting # at the start of it), and restart your MySQL Server using:
service mysql restart

Then you can access your MysqlServer from other computer. If you can't, perhaps you need grant some right to the user.
You can see MySQL Server bind-address using:
netstat -tap | grep mysql

So you know whether the configuration has taken effect.
Comment: Thanks for this. I was looking in my.cnf which no longer contains the bind-address
Answer: Line 59 of my.cnf says:
bind-address        = 127.0.0.1

You'll probably need to change this instead of inserting a new line at the end of the file.
That being said, I recommend, if possible, using SSH with port forwarding to access MySQL remotely instead of opening up your MySQL port to the world.


On statefull processing how should you deal with data that was not processed due to never reach buffer size?

Question: I'm doing some aggregations on keys, on a global window. I'm buffering events to batch process only when reaches the buffer size, in order to reduce the number of iterations.
But, some keys never reach the buffer size, and aren't calculated.
Here is some pseudo-code:
<code>DoFN<> {
  @StateId("count")
  private final StateSpec<ValueState<Integer>> countState = StateSpecs.value();
  private static final int MAX_BUFFER_SIZE = 1000;
     @ProcessElement () {
       int count = firstNonNull(countState.read(), 0);
       count = count + 1;
       countState.write(count);
       if (count >= MAX_BUFFER_SIZE) {
           (...)
           countState.clear();
       }
     }
  }
</code>
That works good, but i'm losing some data, since some keys never reach 1000 records to trigger the batch processing.
Answer: I think proper solution here will be a to add a FinishBundle method and finalize keys that did not reach buffer size at the finalizeBundle() method.


Problems With Reduce Function

Question: I have been trying to create an example problem for testing out the reduce function in javascript. the program it is intended to a single object from a set of input lines.
function generateInputs(){
  var inputLines = Math.floor(Math.random() * 100)

  var arr = [];

  arr[0] = inputLines;

  var userIDs = ["a","b","c","d","e"]

  for(i=0; i<inputLines; i++){
      let userID = userIDs[Math.floor(Math.random() * userIDs.length)]
      let usage = Math.floor(Math.random(600))

      arr.push(userID + " " + usage)
  }
  return arr;
}

let inputs = generateInputs()

function parseInput(line){
  return line.split(" ");
}

let list = inputs.reduce(function(accumulator,inputLine){
    if(typeof inputline === "string"){
        let parsedInput = parseInput(inputLine);
        accumulator[parsedInput[0]] = parsedInput[1];
    }
}, {})

console.log(list)

it keeps returning undefined and I have been through it several times. the only thing I have found it a problem with the "if" statement which I wasn't able to remedy. do you see any solutions?
Comment: You're not `return`ing the accumulator after the `if`.
Comment: If you put the return statement inside the if, then your function will implicitly return `undefined` when the if statement doesn't execute. There needs to be a `return` statement for every branch of the code, or else the `accumulator` will get set to `undefined` on the next iteration.
Comment: why does the return statement have to be after the if statement, if I may ask? because I tried to return the accumulator in the if statement and it didn't work. I think there is something about the syntax that I am missing:/
Answer: You have to return the accumulator (or return something different depending on use case) in reduce() callback.
Otherwise the next iteration of the reduce loop accumulator will be undefined
Comment: You beat me to it twice in a row haha +1

Problems With Reduce Function


How to read data from XNode

Question: How can I read data from XNode.
Here is my XNode I got from another query.
<claim kind="national" sequence="1">
  <country>UK</country>
  <number>66</number>
  <date>20080602</date>
</claim>
<claim kind="national" sequence="3">
  <country>TH</country>
  <number>61</number>
  <date>20090316</date>
</claim>

I want to get the country and date value.
Any help would be really appreciated.
Thanks.
Answer: Try,
var list = from ele in XDocument.Load(@"c:\file.xml").Descendants("claim")
           select new
            {
              Country=(string)ele.Element("country"),
              Date=(string)ele.Element("date")
             };
 foreach (var t in list)
 {
    Console.WriteLine(t.Country + " "+ t.Date );
 }

EDIT:
string country=(string)((XElement)xNodeObj).Element("country");

Comment: Thx for your reply. How should I try since this xml is already in XNode (not from a file).
Comment: XDocument.Descendants is exactly what i was looking for to grab the nodes as XElements, cheers m8!  foreach (XElement node in XDocument.Parse(xmlString).Descendants("filter"))
Answer: Here is a way to do it using XPath:
string xml = "<claim kind=\"national\" sequence=\"1\"> <country>UK</country> <number>66</number>  <date>20080602</date></claim><claim kind=\"national\" sequence=\"3\">  <country>TH</country>  <number>61</number>  <date>20090316</date></claim>";
XDocument doc = XDocument.Parse(xml);
doc.XPathSelectElement("//claim[country = 'TH']/number").Value.Dump("xpath stuff");

How to read data from XNode


Overwrite php builtin functions?

Question: How to overwrite php default/builtin functions like gethostname(), die() etc..?
if we call a php function gethostname like echo gethostname(); it will return localhost or whatever the host of the machine is. Instead of that, I want to pass hostname as host1.
I want to pass a custom host name whenever gethostname is called.
Comment: Download the PHP source code written in C, make changes you need, compile, done.
Comment: Possible duplicate of [Redefining PHP function?](https://stackoverflow.com/questions/2640958/redefining-php-function)
Comment: what type of C source code?
Comment: https://github.com/php/php-src
Comment: http://php.net/get/php-7.2.6.tar.xz/from/this/mirror
Comment: Also note that you would need to repeat this process every time a new PHP version is released. This sounds like an [x-y problem](http://xyproblem.info/) though.
Comment: It's probably **way** easier to just rename your host in Apache's httpd-vhosts.conf file...
Answer: You could override the function and write the functionality on your own:
http://www.php.net/manual/en/function.override-function.php

Overwrite php builtin functions?


Why image in VirtualBox 5.2.18 doesn't work with latest VirtualBox 6.0.8?

Question: In Ubuntu, VirtualBox installation via apt install virtualbox only offers the old version v5.2.18.
user@linux:~$ apt show virtualbox
Package: virtualbox
Version: 5.2.18-dfsg-2~ubuntu18.04.5
Priority: optional
Section: multiverse/misc
Origin: Ubuntu

Initially, I was using this version for a while.
Then, I decided to download and install the latest one (v6.0.8) available here.
user@linux:~$ sha256sum virtualbox-6.0_6.0.8-130520~Ubuntu~bionic_amd64.deb
17f1a24848dcf8ec1025790d35281f7f38b2c98740ddbccac6259a0f4c1786f7  virtualbox-6.0_6.0.8-130520~Ubuntu~bionic_amd64.deb
user@linux:~$

Initially, I was not able to install the latest one.
user@linux:~$ sudo dpkg -i virtualbox-6.0_6.0.8-130520~Ubuntu~bionic_amd64.deb
[sudo] password for user:
Selecting previously unselected package virtualbox-6.0.
dpkg: considering removing virtualbox in favour of virtualbox-6.0 ...
dpkg: no, cannot proceed with removal of virtualbox (--auto-deconfigure will help):
 virtualbox-qt depends on virtualbox (= 5.2.18-dfsg-2~ubuntu18.04.5)
  virtualbox is to be removed.

dpkg: regarding virtualbox-6.0_6.0.8-130520~Ubuntu~bionic_amd64.deb containing virtualbox-6.0:
 virtualbox-6.0 conflicts with virtualbox
  virtualbox (version 5.2.18-dfsg-2~ubuntu18.04.5) is present and installed.

dpkg: error processing archive virtualbox-6.0_6.0.8-130520~Ubuntu~bionic_amd64.deb (--install):
 conflicting packages - not installing virtualbox-6.0
Errors were encountered while processing:
 virtualbox-6.0_6.0.8-130520~Ubuntu~bionic_amd64.deb
user@linux:~$

Removing VirtualBox 5.2.18 fixed the issue
user@linux:~$ sudo apt remove virtualbox
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libgsoap-2.8.60 virtualbox-dkms
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  virtualbox virtualbox-qt
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
After this operation, 108 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 229334 files and directories currently installed.)
Removing virtualbox-qt (5.2.18-dfsg-2~ubuntu18.04.5) ...
Removing virtualbox (5.2.18-dfsg-2~ubuntu18.04.5) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for desktop-file-utils (0.23-1ubuntu3.18.04.2) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for shared-mime-info (1.9-2) ...
Processing triggers for gnome-menus (3.13.3-11ubuntu1.1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
user@linux:~$

Then, I proceed with the installation again without any problem.
user@linux:~$ sudo dpkg -i virtualbox-6.0_6.0.8-130520~Ubuntu~bionic_amd64.deb
(Reading database ... 229023 files and directories currently installed.)
Preparing to unpack virtualbox-6.0_6.0.8-130520~Ubuntu~bionic_amd64.deb ...
Unpacking virtualbox-6.0 (6.0.8-130520~Ubuntu~bionic) over (6.0.8-130520~Ubuntu~bionic) ...
Setting up virtualbox-6.0 (6.0.8-130520~Ubuntu~bionic) ...
addgroup: The group `vboxusers' already exists as a system group. Exiting.
Processing triggers for systemd (237-3ubuntu10.23) ...
Processing triggers for ureadahead (0.100.0-21) ...
ureadahead will be reprofiled on next reboot
Processing triggers for gnome-menus (3.13.3-11ubuntu1.1) ...
Processing triggers for desktop-file-utils (0.23-1ubuntu3.18.04.2) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Processing triggers for shared-mime-info (1.9-2) ...
user@linux:~$

Unfortunately, none of my previous image work with the new VirtualBox.

Failed to open a session for the virtual machine Ubuntu-18.04-Server.

The virtual machine 'Ubuntu-18.04-Server' has terminated unexpectedly during startup with exit code 1 (0x1).

Result Code: NS_ERROR_FAILURE (0x80004005)
Component: MachineWrap
Interface: IMachine {5047460a-265d-4538-b23e-ddba5fb84976}

What happened and how to fix this issue?
Answer: I had the same problem installing virtualbox 6 while having virtualbox 5 already installed. Before installing virtualbox-6.0, I just tried
sudo apt remove virtualbox

and then
sudo apt install virtualbox-6.0

but when trying "apt upgrade" lead to:
The following packages have unmet dependencies:
virtualbox-6.0 : Conflicts: virtualbox
                 Conflicts: virtualbox-qt but 5.2.18-dfsg-2~ubuntu18.04.5 is to be installed

so I realized there was some package not correclty removed.
sudo apt autoremove --purge virtualbox*
sudo apt install virtualbox-6.0

finally worked for me.
Answer:
"The Virtualbox kernel module does not match this version of
  virtualbox"

I think that is explained quite well.
Your installed virtualbox kernel module is still the 5.x.x one. But your installed virtualbox version is 6.x.x. There is a mismatch.
Unload the modules
You can manually unload the module(s).
sudo modprobe -r vboxpci
sudo modprobe -r vboxnetadp
sduo mdoprobe -r vboxnetflt
[...]
sudo modprobe -r vboxdrv

Note: don't mind if modprobe reports module not found
Then relaunch virtualbox.
Reboot
... or (not and) you can simply reboot.


Change order of html element depending on screen size

Question: How do you change the order of html elements based on the size of the screen?
For example, on large screen like desktops, the order would be like this:

element1 element2 element3

However, when seeing this on phone, it wouldn't fit the width of the screen. So, I would like it to look like this:

element2
  element1
  element3

Since Div2 is the main div, I would like it to be on the middle on large screens and on top on smartphone screens.
I am using Foundation as the framework for the website.
Here's an example code:

I have spent a lot of time learning html and css so that's all I really know to make a website. I have been planning to learn javascript so it would be fine if the solution requires it.
Comment: can you use bootstrap?
Answer: Here's the CSS way, using flexbox (take a look at this guide to help you get started with flexbox):
flex-direction is either row or column (depending on how you want your elements to flow)
Change their order with order (using order: 1 on #element2 will put it at the end)

#container {
  display: flex;
  flex-direction: column;
}

#element2 {
  order: -1;
}

    #1

    #2

    #3

Comment: When I tried this, it does make element2 the first element when it is vertical. However, now it is always vertical, even when the screen is wider.
Comment: add it in a [media query](https://css-tricks.com/snippets/css/media-queries-for-standard-devices/), `@media screen and (max-
width: 640px) { }`
Comment: Yes, this is perfect. Thank you so much.
Answer: Here's one way you could do it:
In CSS you can use a media query to display or hide content:
@media (max-width:632px){
    #computer{
        display: none;
    }
    #phone{
        display: block;
    }
}

You can then have 2 x html sections for both computers / smartphones for example (If you'd like to have big differences in structure etc. between devices)
Good read on media queries - http://www.adobe.com/devnet/archive/dreamweaver/articles/introducing-media-queries.html
Answer: You just simply use class  medium-up-12 instead of class on container ID.
Goo Luck.

    #1

    #2

    #3


I just made a welcome and goodbye message for my discord.js bot but it doesn't send the messages to the required channels

Question: Here's my code,
Welcome message:
client.on('guildMemberAdd', async member => {
if(member.guild.id !== "737222740305641472")return;
const channel = guild.channels.cache.get("750952211659620413")
if (!channel) return;

   let data = await canva.welcome(member, { link: "https://imgur.com/a/BPTpkDT", blur: false })

const attachment = new Discord.MessageAttachment(
  data,
  "welcome-image.png"
);

channel.send(
    "Welcome message here",
  attachment
);
});

And my goodbye message's code:
client.on('guildMemberRemove',(member) => {
if(member.guild.id !== "737222740305641472")return;
guild.channels.cache.get('781737515421138984').send(`Goodbye message here`);
});

I'd like to make it clear that I dont get any error's in my console and that I've given the bot all the perms it needs to send messages.
Also, I've already declared my guild before, so that isn't supposed to be the problem.
Can anyone tell what I'm doin wrong?
Comment: Have you enabled privilliged intents? and what is your discord.js version?
Comment: What are privileged intents? My discord.js version is v12.5.6
Comment: I recon you haven't enables intents then, since you do not know what they are I would post it as an answer.
Comment: Ummmm, sure ig.
Comment: Wait, do I enable it via the discord dev portal?

Edit: I just enabled the Server members intent from the dev portal, lemme try it out
Comment: And It didnt work, is there anything I need to add to my index.js file after enabling privileged intents?
Comment: Nope! consider using `try/catch` in that case! maybe your bot is lacking permissions in the VERY SPECIFIC CHANNEL, everything would be appearent with a single line of code add this: ```channel.send(
    "Welcome message here",
  attachment
).catch((e) => console.error(e))
```
Answer: As directed by this comment, it is appearent that you have not enabled privilliged intents for your application. For your application to listen to events such as guildMemberAdd and guildMemberRemove you would have to enable to Members Intent from the Discord Developer Portal. Here is what you would be looking for:

This can be found under
Your Application > Bot > ( Scroll down ) Privilleged Gateway Intents > Server Members Intent ( toggleable ).

This was a change introduced in the Discord API version v8  for the intents to be mandatorily enabled for such API requests.
Comment: I just enabled it, it still doesnt work...
Edit: I'm tryin it again
Comment: THANKS A ZILLION DUDE, IT FINALLY WORKSSSS!!
You're awesome!
Comment: No issues! Make sure to accept the answer with the ✓ button and upvote it with the  button if it helps


Continuity of measure and integration: Prove $\int_{A}f \, d\mu \geq 0 \implies f \ge 0$

Question: Suppose that f is a measurable function $(\Omega, \mathfrak{F}, \mu)$ such that $\int_{A}f \, d\mu \geq 0 \forall A \in \mathfrak{F}$. Prove that $f \geq 0 \ \mu$-almost surely.
Hint: Let $A_n = (\omega \mid f(\omega) < \frac{-1}{n})$, and don't forget continuity.
Attempt:
$\forall n \in \mathbb{N}, A_n \subseteq A_{n+1}$
where $A_n$ is measurable since f is measurable (I think?).
By continuity of measure, lim$\mu(A_n)$ = $\mu(\bigcup_{n=1}^\infty A_n) $ where $\bigcup_{n=1}^{\infty} A_n = (\omega \mid f(\omega) < 0)$.
By monotonicity of measure, $0 \leq \mu(A_n) \leq \mu(A_{n+1})$.
Since we want to show that $\mu(\bigcup_{n=1}^\infty A_n) = 0$ (that is equivalent to $f \geq 0 \ \mu$-almost surely right?), and $(\mu(A_n))$ is a nonnegative increasing sequence, we must show that $\mu(A_n) = 0\ \forall n \in \mathbb{N}.$
I think the entire argument relies on the relationship between $\mu(A_n)$ and $\int_{A_n}f \, d\mu = \int_{\Omega}f*1_{A_n} \, d\mu$. What is it? Does nonnegativity of the integral mean that $\mu(A_n)= 0$? I am not quite sure that that necessarily follows.
Answer: Assume $\mu(A_n) > 0$. As $A_n \in \mathfrak{F}$, we then have that $\int_{A_n} f d\mu < -\frac{1}{n} \int_{A_n} d\mu = - \frac{1}{n} \mu(A_n) < 0$, which contradicts the assumption that $\int_A f d\mu \geq 0$ for all $A \in \mathfrak{F}$. Conclude that $\mu(A_n) = 0$ for any $n \in \mathbb{N}$.
Comment: For any $\omega \in A_n$, $f(\omega) < -\frac{1}{n}$, and then integrate this expression over $A_n$.
Comment: Ya pretty much. Glad to help!
Comment: Often times that can work yes, though I would be hesitant to say that it is `the trick' of measure theory.
Comment: How do you know the first inequality holds? Thanks
Comment: msteve, you mean you just replaced f with $\frac{-1}{n}$ and the new integral is greater than the original integral by monotonicity of integration? thanks so much!
Comment: msteve, whenever I relate integrals and measure, is the trick then to compare the original integral with an integral of an indicator function?


Performing actions on form1 from form2

Question: I have this sub on form1:
  Public Sub PlayMaskVideo(filePath As String)
      If File.Exists(filePath) Then
          If MaterialTabControl2.SelectedIndex = 0 Then Mask0Img.Visible = False

          If libVLC Is Nothing Then
              Core.Initialize()
              libVLC = New LibVLC()
          End If

          mediaPlayer = New MediaPlayer(libVLC)
          Mask0VLC.MediaPlayer = mediaPlayer

          media = New Media(libVLC, filePath, FromType.FromPath)
          media.AddOption("input-repeat=65535")
          mediaPlayer.Volume = 0
          mediaPlayer.Play(media)
      End If
  End Sub

This code works as expected if called on Form1, it plays a video in the vlcsharp player on the form.
What I'm trying to do is call it from form2 like this:
Form1.PlayMaskVideo(outputPreview)

I'm expecting the video to play in the form1 video player however nothing happens. I thought maybe its an issue with vlcsharp, but even this line doesn't execute:
If MaterialTabControl2.SelectedIndex = 0 Then Mask0Img.Visible = False

Am I missing something?
Comment: Having said that, if Form1 is your startup form then it should be the default instance, so maybe it's some other issue. This is why you need to debug your code first, before asking a question. If you don't know how to debug, stop what you're doing and learn now.
Comment: "Form1.PlayMaskVideo(outputPreview)" <- is 'Form1' the name of your form, or the name of an instance of your form? Possibly you're falling foul of the default instance in vb.
Comment: Yep, its called Form1. I also just tried removing the FileExists condition and still no go.
Comment: But do you instantiate an instance of the form before calling the method? Or just call it like your code shows? You need to "dim f as new Form1" -> "f.PlayNaskVideo..."
Comment: So I changed the code to this:
        'Dim f1 As New Form1
        f1.PlayMaskVideo(outputPreview)'.

Still not working, I'd think at least this line should fire?

'If MaterialTabControl2.SelectedIndex = 0 Then Mask0Img.Visible = False'

What is strange is that I put a msgbox("test") in the PlayMaskVideo(outputPreview) sub and that DID fire. it just seems like the controls are inaccessable?
Comment: The code you have showed is referring to the default instance of Form1. If the instance already displayed is not the default instance then you're not referring to that form object, so you won't see anything happen in that form object. If you call the method on a different object that you can't see, that's why you won't see anything happen. If you actually debug your code, you'll likely see that the code is executed but in a different instance of Form1. You can identify the instance using a random number assigned to a field.
Comment: Default instances are a way for new VB.NET developers, especially those coming from VB6, to "cheat" and ignore OO principles where forms are concerned. They really shouldn't be used anyway. I'm guessing that this Form1 instance is creating and displaying the Form2 instance in the first place. In that case, Form2 should be raising an event that Form1 can handle and then call its own method itself. If this is happening when Form2 closes after calling ShowDialog, you don't even need that. All you'd need would be a property in Form2.
Comment: I agree with jmcilhinney, I think it would be good for you to set a breakpoint and step through your code. Here's a video on how to do that: https://youtu.be/EceKLMxzE_8?si=dTlCoFR7RTImFfgH
Comment: @jmcilhinney Using an EventHandler fixed the issue for me. Worked perfectly. Thank you.
Comment: If you have solved your own issue, you should post an answer to your question that demonstrates that solution. SO is not just a place to get help yourself but also to help others with the same problem. It may also be that others can help you improve the solution if it is not optimal.
Answer: Here's an example of how I accomplished the issue I was having. Instead of using form1.something = value I used an eventhandler. Like this:
' Form1.vb
Public Class Form1
    ' Declare an instance of Form2
    Private WithEvents form2 As Form2

    Private Sub btnOpenForm2_Click(sender As Object, e As EventArgs) Handles btnOpenForm2.Click
        ' Create an instance of Form2
        form2 = New Form2()

        ' Show Form2 as a dialog
        form2.ShowDialog()
    End Sub

    ' Event handler for the event raised in Form2
    Private Sub Form2ValueEntered(value As String) Handles form2.ValueEntered
        ' Update the text on Form1 with the value entered in Form2
        lblForm1.Text = "Value entered in Form2: " & value
    End Sub
End Class

Then on Form 2:
    ' Form2.vb
Public Class Form2
    ' Define an event that will be raised when a value is entered
    Public Event ValueEntered As Action(Of String)

    Private Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
        ' Get the value entered by the user
        Dim enteredValue As String = txtValue.Text

        ' Raise the event and pass the entered value
        RaiseEvent ValueEntered(enteredValue)

        ' Close Form2
        Me.Close()
    End Sub
End Class

So when you enter a value on Form2 and click Submit, the value in the textbox will be sent to the Form1 label.
Comment: That certainly implements the appropriate principles. Personally, I would stick more closely to the existing conventions for events, so the event would be type `EventHandler` and then the data would be retrieved from a property, or else it would be type `EventHandler(Of TEventArgs)`, where `TEventArgs` is some type of your own that inherits `EventArgs` and adds a property for the data. See [here](http://jmcilhinney.blogspot.com/2009/11/defining-and-raising-custom-events.html) for more info.
Comment: In this case, you didn't actually need the event at all. You are calling `ShowDialog` so the first form can simply get the data from the second form when that returns. Instead of raising the event, simply set a property. In the first form, just get that property value after `ShowDialog` returns. No need to raise or handle an event. It's much like you would get the `FileName` property after showing an `OpenFileDialog` or `SaveFileDialog`. If you need to distinguish between the user clickong `OK` or not, set the `DialogResult` instead of calling close, then check what `ShowDialog` returns.

Performing actions on form1 from form2


13.10 login Background without unity

Question: I want to change my login screen background (and keep the dots). But I upgraded to cinnamon 2.0 a day ago and then to 13.10 earlier today. I recently became aware of the issue with cinnamon 2.0 and unity on 13.10. This normally would not matter to me since I use cinnamon instead but the only way I know of to change the login screen background is to change unity background. Also all of my backgrounds are jpgs not pngs (in case anyone was gonna say the replace /usr/share/backgrounds/ubuntu-warty.png) and for some reason gimp has issues so converting them is not currently possible for me.
Answer: Hope Ubuntu-Tweak will solve your issue

First install latest ubuntu-tweak 0.85 by execute this command in terminal:
<code>sudo add-apt-repository ppa:tualatrix/ppa
sudo apt-get update
sudo apt-get install ubuntu-tweak
</code>
Once installed open it from dash and go to Tweaks tab.
Open Login Settings option under Startup.
First click Unlock button located top-right side, give password.
After Unlock it will clear to you what to do. i,e If you want to set same login background as the current desktop background you have to click : Set the background as the current desktop background button. or else if you want to change a different one you have to click the big square button above to it.

Hope it will help you to resolve your issue.. Reply if something goes wrong..

13.10 login Background without unity


Should I remove a back button from the UI considering every Android phone has a hardware back button?

Question: I've published my android app where in every screen I've put a back button in the actionBar. Now considering that every android phone has a back hardware button, should I remove this button or is it okay if it stays as-is even though I guess it will be hardly used?
Answer: If you added this back button, to make the app work like an iOS app you should indeed remove these.
Android does suggest adding an arrow (home) action to the action bar on the left hand corner, this however should direct to the parent activity, does not have to be the same functionality as the hardware back button.
And yes, it's available on all devices since forever ;).
maybe usefull, the droid docs and the example I mentioned is on top.
http://developer.android.com/design/patterns/actionbar.html
If you have more questions about the android UI, these docs handle most things you would wish to know, give it a read!


Why is there no forEach method on Object in ECMAScript 5?

Question: ECMAScript 5's array.forEach(callback[, thisArg]) is very convenient to iterate on an array and has many advantage over the syntax with a for:

It's more concise.
It doesn't create variables that we need only for the purpose of iterating.
It's creates a visibility scope for the local variables of the loop.
It boosts the performance.

Is there a reason why there is no object.forEach to replace for(var key in object) ?
Of course, we could use a JavaScript implementation, like _.each or $.each but those are performance killers.
Comment: This is a question better suited to people involved in the discussions of ES5/ES6.
Comment: Why does `for-in` need replacing? And why wouldn't an `Object.forEach` also be a performance killer? The hit mainly comes from invoking the callback function.
Answer: Well, it's pretty easy to rig up yourself.  Why further pollute the prototypes?
Object.keys(obj).forEach(function(key) {
  var value = obj[key];
});

I think a big reason is that the powers that be want to avoid adding built in properties to Object.  Objects are the building blocks of everything in Javascript, but are also the generic key/value store in the language.  Adding new properties to Object would conflict with property names that your Javascript program might want to use.  So adding built in names to Object is done with extreme caution.
Array is indexed by integers, so it doesn't have this issue.
This is also why we have Object.keys(obj) instead of simply obj.keys. Pollute the Object constructor as that it typically not a big deal, but leave instances alone.
Comment: But having `Object.forEach` (not in prototype) would be nice.
Comment: Its not poluting IMHO. It's called consistency.  Other languages have it, JS is one of worst on that board. Simmilar actions and transformations done on diff kind of types work logically different and have totally diff syntax. One fo biggest bullshits you have to eat if you are organized in head, JS will screw you over
Comment: "Why further pollute the prototypes?" Why improve things? This answer is not helpful.
Answer:
.forEach does create variables just for the purpose of iteration... Just not ones you create, yourself.
If you're using a shim, then they're JS variables in a closure, else they're likely in C++, or whatever the browser's native implementation is.
ES6 is getting for ... of which will iterate through whatever you pass it.
ES6 is also getting block-level variables (rather than function-scoped), using let, instead of var
You will be able to add iterators to specific kinds of objects in ES6 (ie: the objects you build to support iterators).

But the problem here is that ES5 was meant to preserve most of the syntax of ES3 (few new keywords, and no new keywords in regular-use).
Most of the additional functionality had to be method calls (prototyped, typically).
And arrays needed plenty of work, given how much more use JS has seen since ES3 launched.
Objects don't need a .map() / .reduce() ability, unless you're building VERY SPECIFIC objects, in which case, you're implementing those yourself.
Comment: `for...in` iterates over anything. As for `for...of`, it will only iterate over [Iterables](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol)
Comment: @theFreedomBanana Yes, the expected behaviour of `for...of` has changed a lot since this answer was written, half a decade ago. This was written when a lot of people were still using `obj.hasOwnProperty(key)`. Initial talks of `for...of` were to cover arrays and objects, and just do the right thing with both of them.

I'll look at updating it, some time tonight.
Answer: You have to remember that every object in javascript inherits from Object. Not every object in javascript needs to have it's properties iterated. Those are mostly confined to data model objects. Adding the forEach method will only bulk up the prototype of every object unnecessarily.
If you currently see the Object and it's methods, they are present only to identify the object, or to distinguish one object from another.


I reset my laptop and now Steam games are all missing

Question: I reset my pc and didn't expect anything to happen to my Steam account. I had a ton of games on there that were very expensive. I re-downloaded Steam on my now-reset laptop. When I looked at my profile and Steam purchase history, it was empty. I don't know how to recover the games and money I had on there.
--
As a little update I've done research about this over the weeks and recovered the old steam files I had but still wasn't able to get them on the account. I logged into all the steam accounts I have and all of them don't have a purchase history or friends. I will just save up the money and start up fresh and try to get the progress I had back as well. Thanks to everyone who tried to help but nothing is really working so I just give up.
Comment: When you "Reset" the PC, exactly what did you do?
Comment: @RobbieGoodwin probably Reset as in Recovery Options: [How to refresh, reset, or restore your PC](https://support.microsoft.com/en-us/windows/how-to-refresh-reset-or-restore-your-pc-51391d9a-eb0a-84a7-69e4-c2c1fbceb8dd).
Comment: @RobbieGoodwin What do we know? OP did something called "Reset" and had to re-download Steam, and the games are missing. What I posted fulfills that description. Resetting the PC as in Recovery Options, and I quote the linked article "reinstall Windows but delete your files, settings, and apps—except for the apps that came with your PC." - Now, I cannot know for certain. For all I know OP is telling lies. And this conversation devolves in whether or not knowledge at posteriori is possible and if whether or not there is any value in arguing. Which is all off-topic, of course.
Comment: Reset can be an ambiguous translation in some languages, for example in Portuguese (not likely the case here but just making the point it can happen), "reset" is often translated to "reinicializar", but that word is more commonly used to mean "restart", so it could mean either reset or restart when translated from PT back to English. Point being asking clarification on what is meant by "reset" would be totally valid on the internet even if it isn't ambiguous in English.
Comment: Can we presume your copies of the game were purchased and licenced to yourself on that hardware in a regular manner? And that those licences are still valid? Just askin'...
Comment: @Theraot You do not know that OP did something called "Reset"… only that OP described something as "I reset my pc".

If you think "reset" has only one meaning, why not explain? You Posted an assumption based on guesswork. My Post might seem strange to your mind-set but rather than assumptions or guesses, it sought to find out what actually happened.

If "this conversation devolves in whether or not knowledge at posteriori" worked in English or pig-Latin, I'd still hope everyone saw both what you don't know and what kind of thinking led you to speculate "For all I know OP is telling lies."
Comment: @Theraot How about "probably" whatever you like, on your own machine?  Meanwhile if you're certain that's what 김수민 meant, why not explain how you know that?
Comment: @RobbieGoodwin i resetted it deleting all files because i had alot of probloms with my computer, i didn't think steam would've deleted all my games so i can't get them back. I tried to get files back and even then i can't add the games then.
Comment: @Theraot i resetted the whole pc leaving no apps because i had alot of problems for some reasons. I didn't know it would make me lose the games(which was honestly stupid of me) but i'm not lying and was very upset about this because i'm a teenager and can't get them.
Answer: Here are some possibilities:

You are signed into the wrong account (unlikely but can't leave this
out)
You have filtered out games that are not ready to play (click the
small play icon above the game list to toggle this)
You were previously accessing games via Steam Family Sharing and need
to re-authorize your computer to access those games
I notice your username is Korean. It seems unlikely but possibly, all the games you had have been region-blocked (Korea is particularly strict with games)

If those are not the case, have a look at this Steam guide for more options.
Comment: Since they mentioned that the _purchase history_ is empty, I would strongly suspect tuer first option. This can help even with experienced users! Family-shared games would have no reason ever showing there either.
Comment: @JoshuaBizley thank you for the help but the last option won't be the case because i currently don't live in Korea
Comment: As for the fourth possibility, that wouldn't happen. Even if any game got region blocked **after** steam user purchased the game, they would still be able to download and play without any issue. I've experienced enough to know this... sadly.
Comment: @Kroltan no i'm sure it's my account but il look into this again.
Answer: When a steam game has been unresponsive and a reset on the computer is necessary, this may set the steam settings back to defaults.
Therefore, If you had configured steam to have a custom Library folders where some of your games are installed, this will not be seen by steam.
You can recover the games back by going to:
Settings > Downloads > Steam Library Folders
Then just add your old custom Library folders which contains the other games.
Comment: I don't see how this explains the missing purchased games.


Prove that $BXOY$ is cyclic with spiral similarity over a midpoint

Question:
Let $O$ be the circumcenter of triangle $ABC$. Line $CO$ intersects the altitude from $A$ at point $K$. Let $P,M$ be the midpoints of $AK$, $AC$ respectively. If $PO$ intersects $BC$ at $Y$, and the circumcircle of triangle $BCM$ meets $AB$ at $X$, prove that $BXOY$ is cyclic.

My Progress: Since this was from a spiral similarity handout, I am using spiral similarity.

Note that $XM$ is anti parallel to $BC$. Now since $AK$ and $AO$ are isogonals and $AK\perp BO \implies AO \perp XM$.
Now define $AO\cap XM=U$ , $M'$=reflection of $O$ wrt $M$ , $A'$= antipode of $A$ wrt $(ABC)$ , $W=AC\cap A'K$ , $Z=A'M' \cap (ABC) .$
I observed that there is a spiral similarity (say $\gamma $ ) centred at $X$ taking $M'M$ to $AK$ , and hence $O$ to $P$ . So I am trying to prove that observation. Here is what I got.

$ACA'Z$ is a rectangle : as $A-O-A'$ and $Z-O-C$ are collinear
$MM'A'C$ is a rectangle : as $M$ and $M'$ are midpoint of $AC$ and $ZA'$
$MUM'A'C$ is cyclic : Note that $\angle MUA'=\angle MM'A'=90$

So by the above claims  , we get  $\angle XAK =\angle MAO=\angle OA'M'= \angle UA'M'= \angle UMO=\angle XMM'$.
Now after this I want to prove

$\angle MXM'= \angle AXK $

After this we will be done, because then we will have $\gamma : M'M \rightarrow KA \implies \gamma : O \rightarrow P \implies \Delta POX \sim \Delta AMX \implies \angle POX = \angle AMX=\angle ABC $
Thanks in advance!
Comment: Here's the diagram link https://www.geogebra.org/geometry/m8tyakgn
Answer: Nice observations and almost there!
So, as you have already shown that $\angle XAK = \angle XMM'$, its enough to show that $\angle AXP =\angle MXO$ (Notice that instead of $\gamma: MM'\mapsto AK$, I'm trying to show $\gamma: MO\mapsto AP$ and the reason for this is because as you observed $XM\perp AO$, showing angles $AXP$ and $MXO$ same would be equivalent of showing center of $\odot(AXO)$ lies on $XP$ and thus, this is a more natural way of approaching the problem.)
Anyways, lets move on...
Note that as $\angle AUM = \angle AMO =90,$ we get, $\angle UMO =\angle OAM=\angle OCA\overset{Thales'}{=}\angle AMP$. Further note that $\{AP,AO\}$ are isogonal lines with respect to $\triangle XAM$ and by the fact that $\angle UMO =\angle AMP$ we conclude that points $\{P,O\}$ are isogonal with respect to $\triangle XAM$ and thus, $\angle PXA =\angle OXM$ and we are done!$$\tag*{$\blacksquare$ ::&}$$
Comment: Thank you so much :) actually point M' was looking good , that's why I chose this way .. Thanks again ::@
Comment: @SunainaPati You're welcome :) and about the point M' its a really nice choice to introduce it :) ::&


Communicate that an object in the toolbar cannot be added to the document a second time

Question: I'm working on a toolbar containing objects that can be dragged into documents. You can also click on these objects to add them to the document. Some of these objects have restrictions and can be added just once. We show tooltips while hovering the objects that show these restrictions. The app manages many documents and you can browse them while the toolbar stays fixed on the right side of the window.
Once you added the object with restrictions (Blue button), is it better to disable it in the toolbar and show a tooltip on hover (picture A) or to keep the object active and show a message when you try to use it again (picture B)?
Answer: See each button as a stack of buttons of the same kind. When you drag an instance from the stack, the next one appears. But when it is the last one there is no next button underneath.
Comment: That's a good approach. What could happen though is that you'll have different toolbars configurations for different documents. And since you will change documents often it might not be good.

Do you know any app that uses the approach you suggested?
Comment: No exampls comes to mind currently, but if the toolbar doesn't show how it relates to each specific document, than that is a problem in general, not just for this approach. It is a matter of making the toolbar look less general, design it in a way that it looks connected to the document itself. You can also set the title in the toolbar specifically for the document like "Available buttons for document #1".
Answer: I think the technique in your Picture A, disabling the button and showing a tooltip when you can place no more, looks fine. It is very similar to how the video game Super Mario Maker 2 handles this same problem.
Super Mario Maker 2's UI for parts with limits
Super Mario Maker 2 is a game that lets you build custom levels by adding parts to your level from the library or from the toolbar. The toolbar is automatically populated with items you have recently placed. You can either select a part first, then tap the level to place it, or drag a part from the toolbar to the level.
Most parts can be added without limit, but some have a limit. For example, only one Checkpoint Flag may be placed. Here's what it looks like when you select the Checkpoint Flag from the library of parts:

After confirming your selection, the Checkpoint Flag is selected in the toolbar (at the top right), ready to be placed:

After tapping the level to place the Checkpoint Flag, that part gets added to the right side of the toolbar, as it is the most recently used item. Also, since you have placed the maximum number of that part allowed, the square for that part turns gray to show it can't be placed again:

Tapping on the screen to place another Checkpoint Flag or trying to drag a copy of that part from the toolbar does nothing but play a wood clunk sound effect.
If you open the library again, the Checkpoint Flag is grayed out there too. If you select it, the tooltip now includes "Part limit reached" in addition to the part name:

I found Super Mario Maker 2's UI pretty clear when I built levels in it. However, the game assumes input with either an analog controller or a 6-inch touch screen. A UI for a desktop computer that requires a mouse may require some changes.
Still, for your specific design, I don't see any flaws in your Picture A. It seems a fine way to communicate why you can't place any more of a part and which part it is you have run out of.


Does the order of add_action and function matter?

Question: In many instances, I see a function followed by the add_action command.
But in terms of the visual flow, I always move the add_action underneath the function, and it still works.
I would like to know firstly, if it matters which order they appear in, and why most instructions seems to include the function last?
add_action( $hook, 'foo', $priority, $accepted_args );
function foo() {
    // Function code
}

or
function foo() {
    // Function code
}
add_action( $hook, 'foo', $priority, $accepted_args );

Wouldn't it make more sense to use the latter as the function has already been read?
Comment: Whether it matters or not depends on what `add_action` does exactly… Generally: if it works, well, apparently it *doesn't* matter.
Comment: Given that both function declarations are anonymous (they have no name), this example doesn't make a whole lot of sense.
Comment: It's just an example to visually show the order. They would be named accordingly, and referenced in the add_action.
Answer: The order doesn't matter.  The PHP interpreter uses a 2-pass approach. The functions are defined in the first pass, and your function is only run later when it's called by do_action( $hook ).
A little more about this here: Does PHP interpret code in the same way that JavaScript does?
Comment: This is only true for "flat" function declarations. Function declarations within a function or other conditional statement like an `if` can very well produce errors if you try to call them before they're defined.


Jinja2 getting endif error even tho the tag is clearly ended

Question: I'm trying to append to a list during a loop.. I am getting an error about my {% if %} tag not being closed and encountering unknowntag 'hidden'. What am I missing here?
{% set hidden = [] %}
{% for row in packages %}
{% if row.hidden %}  #OPEN
{% hidden.append(row.id) %} #APPEND
{% endif %} # CLOSED
{% endfor %}
{% if hidden[0] %} # If my list isn't empty, show the next line
View Packages (Click here to show hidden)
{% else %}
View Packages # If list is empty show this line
{% endif %}

Any thoughts?
Comment: show full error message and full template in question. If you use `extends` in template then show base template too.
Answer: For some reason my hidden.append had to be inside another if statement..
{% set hidden = [] %}
{% for row in packages %}
{% if row.hidden %}  #OPEN
{% if hidden.append(row.id) %}{% endif %} #APPEND #THIS LINE
{% endif %} # CLOSED
{% endfor %}
{% if hidden[0] %} # If my list isn't empty, show the next line
View Packages (Click here to show hidden)
{% else %}
View Packages # If list is empty show this line
{% endif %}

Answer: Jinja2 is based on tags like an if tag or a set tag, but tags and python code is not the same. Especially you can not take any python code, put it in {% %} and expect it to work. Instead use the do tag
{% for row in packages %}
{% if row.hidden %}  #OPEN
{% do hidden.append(row.id) %}
{% endif %} # CLOSED
{% endfor %}

Your version with if worked because if executes the code and looks at the returnvalue. But you are not interested in the return value, so use a do tag.
The do expression is a extension so you need to load that for it to work.


how to get previous month or last two month data in oracle

Question: how to get previous month or last two month data in oracle.
My date format is YYYY,MM,DD.
from google search i got those solution,
select * from IM_LAPTOP
where ADD_DATE >= add_months(sysdate, -12);

select *
  from IM_LAPTOP
 where ADD_DATE between add_months(trunc(sysdate,'mm'),-1) and last_day(add_months(trunc(sysdate,'mm'),-1));

But its showing not a valid month
Comment: Is `add_date` actually defined as a `date`?  Or as a `varchar2`?  Or as a `number`?  If you're storing dates, you really ought to use the proper data type (`date`).  But the error seems to imply that you're using the wrong data type.
Answer:
My date format is YYYY,MM,DD

Unless you are using a string to store dates then, no, it is not; a DATE is a binary data type (consisting of 1-byte for each of: century, year-of-century, month, day, hour, minute and second and it always has those components) and it has no format.

how to get previous month or last two month data in oracle

To get the data from 2 months before this instant in time (i.e. if it is now 2021-04-05 16:39:24 and you want it from 2021-02-05 16:39:24, two months prior) then:
SELECT *
FROM   your_table
WHERE  date_column >= ADD_MONTHS( SYSDATE, -2 )

To get the data starting from midnight on the 1st day of last month:
SELECT *
FROM   your_table
WHERE  date_column >= ADD_MONTHS( TRUNC( SYSDATE, 'MM' ), -1 )

If you only want the data from the preceding month then:
SELECT *
FROM   your_table
WHERE  date_column >= ADD_MONTHS( TRUNC( SYSDATE, 'MM' ), -1 )
AND    date_column <  TRUNC( SYSDATE, 'MM' )

If your "date" is actually a VARCHAR2 column with the format YYYY,MM,DD then you should change it to a DATE column but if for some reason you cannot then at least the characters are in order of highest-to-least significance and you can perform an alphanumeric comparison and just wrap the right-hand side of the filters in TO_CHAR:
SELECT *
FROM   your_table
WHERE  date_column >= TO_CHAR( ADD_MONTHS( SYSDATE, -2 ), 'YYYY,MM,DD' )

Comment: SELECT *
FROM   your_table
WHERE  date_column >= TO_CHAR( ADD_MONTHS( SYSDATE, -2 ), 'YYYY,MM,DD' )

this query showing all of data, not showing last month or last two month data. please help
Comment: This query work for me.. Thank you

select *
  from IM_LAPTOP
 where to_date(add_date,'yyyy/mm/dd') between add_months(trunc(sysdate,'mm'),-2) and last_day(add_months(trunc(sysdate,'mm'),-2))


Outputting an element when a clicked element's id equals object element

Question: I am trying to display the appropriate input for the correct icon displayed. I structured all of my elements as an object and created the key to match the id of the matching icon. I then created the element to the appropriate input to match.
My issue is, when I click on the icon, nothing outputs. I do not get any errors, my console.log is showing me the looped results.
Does anyone see what I am doing wrong? If you click on the blue Zillow icon, then the input with the placeholder "Zillow" should appear. The same thing with the Realtor one, except it be associated with the Realtor input/icon.

var reviewInputs = {
  "zillow-review": '<input type="url" id="zillow-input" placeholder="Zillow">',
  "realtor-review": '<input type="url" id="realtor-input" placeholder="Realtor">'
};

$('.review-icon-select').click(function() {
  $('#review-site-edit-wrap').addClass('active');
  var reviewIconClicked = $(this).attr('id');

  $.each(reviewInputs, function(key, element) {
    console.log('key: ' + key + '\n' + 'value: ' + element);
    if (reviewIconClicked == reviewInputs) {
      reviewInputs.forEach(function(site) {
        $('#review-site-edit').append.reviewInputs[element];
      });
    }
  });

  //$(reviewIconClicked':contains("SomeText")').each(function () {
});

Answer: You just need to check if the id of the clicked element is a property of your object.
No loop needed.

var reviewInputs = {
  "zillow-review": '<input type="url" id="zillow-input" placeholder="Zillow">',
  "realtor-review": '<input type="url" id="realtor-input" placeholder="Realtor">'
};

$('.review-icon-select').click(function() {
  //$('#review-site-edit-wrap').addClass('active');  // Maybe used...
  var reviewIconClicked = $(this).attr('id');

  if(reviewInputs.hasOwnProperty(reviewIconClicked)){
    $('#review-site-edit').find("input[type='url']").remove();
    $('#review-site-edit').append(reviewInputs[reviewIconClicked]);
  }
});

Comment: Perfect... I appreciate it!
Comment: It isn't doing the same as in the snippet ?
Comment: What do you mean by *«added to the DOM»* ?
Comment: Is it that you want only ONE input... So the previous should be removed ?
Comment: Any other way besides the `empty()` method? That is wiping out my submit button.
Answer: Instead of using
if (reviewIconClicked == reviewInputs) {

try
reviewInputs['reviewIconClicked']


Joint probability mass problem

Question: Additional information: Let $q_x$ denote the probablity of a $x$ year old person who's going to die within 1 year. Explain cumulative distribution function of $X$ is given by:
$$F(x)=P(X\leq x)=1-\prod^{x}_{y=0}(1-q_{35+y})$$
letting $q_x$ denote the probablity of that a $x$ year old person is going to die before the person is able to become $x+1$ year old. That means that the chance of the person surviving this year is $1-q_x$. Notice that vi can write
$$F(x)=P(X\leq x) = 1-P(X>x)$$
where $P(X>x)$ is the probablity for that the person is becoming older than $x$. This means that the person has survived up till $x$ years. We're interested in when they are over 35 years.
$$\prod^x_{y=0}(1-q_{35+y})$$
$$\therefore{F(x)=1-P(X>x)=1-\prod^x_{y=0}(1-q_{35+y})}$$
Question: How do I show that the join probabilty mass function is given by
$$F(x)=P(X\leq x)=1-P(X>x)$$
for $x=0,1,2,3,...71$
is this any correct?
$$F(x)-F(x-1)=P(X\leq x) - P(X\leq x-1)$$
$$=1-\prod^x_{y=0}(1-q_{35+y})-1-\prod^{x-1}_{y=0}(1-q_{35+y})$$
$$-\bigg(\prod^{x}_{y_0}(1-q_{35+y})+\prod^{x-1}_{y_0}(1-q_{35+y})\bigg) $$
and im stuck here, what do i do next?
Answer: We are not told what is $X$, but we are given a formula for its CDF. Hence, we should try to figure out what does $X$ measures.

$q_t$ is the probablity of that a $t$
year old person is going to die before the person is able to become $t+1$
year old.
$q_{t+y}$ is the probablity of that a $t+y$
year old person is going to die before the person is able to become $t+y+1$
year old.
$1-q_{t+y}$ is the probablity of that an $t+y$
year old person is not going to die before the person is able to become $t+y+1$
year old.
$1-q_{35+y}$ is the probablity of that an $35+y$
year old person is not going to die before the person is able to become $35+y+1$
year old.
Hence $\prod_{y=0}^x(1-q_{35+y})$ is the probablity of that an $35$
year old person is not going to die before the person is able to become $35+x+1$
year old.
Hence $1-\prod_{y=0}^x(1-q_{35+y})$ is the probablity of that an $35$
year old person is  going to die before the person is able to become $35+x+1$
year old.
That is, $P(X \le x)=1-\prod_{y=0}^x(1-q_{35+y})$ is the probablity of that an $35$
year old person is  going to die before the person is able to become $35+x+1$
year old.
$X$ measures how many more times a person of $35$ years old gets to celebrate his own birthday.

Though the original question didn't ask for the pmf, but if one is interested
\begin{align}P(X=x)&= F(x)-F(x-1) \\&= \left(1-\prod_{y=0}^x(1-q_{35+y}) \right) -\left(1-\prod_{y=0}^{x-1}(1-q_{35+y}) \right)
\\&=\prod_{y=0}^{x-1}(1-q_{35+y}) - \prod_{y=0}^{x}(1-q_{35+y}) \\
&=q_{35+x} \prod_{y=0}^{x-1}(1-q_{35+y})
 \end{align}
i.e. the person gets to celebrate $x-1$ birthday but not the next one.
Comment: Oh, i forgot to mention that $X$ is a sthocastic variable that denotes the persons remaining lifespan/lifetime after he hits 35 years old
Comment: Yeah, that would have saved Siong Thye Goh a lot of effort. @user8700908

Joint probability mass problem


Lubuntu window geometry - force window to always open in the same location?

Question: I'd like my Chromium window to open with the same size and in the same place every time. I thought I'd be able to make this happen by editing lubuntu-rc.xml like this:

chromium-browser --geometry=140x40+0+0

But it doesn't seem to make any difference.
Chromium does remember the last size, but never the last location.
Comment: Does chromium always open in unoccupied space?
Comment: OP may be wanting to open the browser every time in a specific position with a specific size, whether or not other applications are open? I guess what you're pointing out is that the window manager tries to display windows so that they don't overlap (or overlap minimally); is that right?
Comment: Please explain where you place this `chromium-browser --geometry=140x40+0+0` in lubuntu-rc.xml. If you wish, you may edit your question to include this information. Also, just in case you aren't aware, you need to refresh "openbox" after you edit lubuntu-rc.xml by running `openbox --reconfigure` in a terminal. If you just get back your prompt, it means your file is in good shape.
Answer: Here's a way to get Google Chrome (and presumably Chromium) to always open with the same size and in the same screen position in a default installation of Lubuntu 12.10:
Part 1:
Back up ~/.config/openbox/lubuntu-rc.xml.
Open ~/.config/openbox/lubuntu-rc.xml in a text editor.
Just above the line that contains only </keyboard>, paste the following (modified as per requirements):
<keybind key="W-C">
  <action name="Execute">
    <command>/opt/google/chrome/google-chrome --window-size=675,725 %U</command>
  </action>
</keybind>

Part 2:
Just above the line that contains only </applications> (near the end of the file),  paste the following (modified as per requirements):
<application name="google-chrome">
  <position force="yes">
    <x>-0</x>
    <y>0</y>
  </position>
</application>

Save the file and exit the text editor.
Open a terminal and run openbox --reconfigure to register the changes made to lubuntu-rc.xml.
Launch Google Chrome by pressing Super+C.
Notes:

the window-size=w,h switch and other switches can be found here: List of Chromium Command Line Switches.
C, S, A, W stand for Control, Shift, Alt, and Super (or Windows) keys, respectively.
The combination of <x>-0</x> and <y>0</y> forces the upper right corner of the Google Chrome window to be positioned in the upper right corner of the screen.
A combination of <x>0</x> and <y>0</y> would force the left upper corner of the Google Chrome  window to be positioned in the upper left corner of the screen.
The comments in the Applications section of lubuntu-rc.xml have further details on window placement.


Ion-nav-bar for a view

Question: I'm working on an Ionic 1 project. I'm trying to have a nav-bar with a back button inside one of the views, but its not appearing. I inspected on Chrome, and saw that the class of the back button became hide. Is there anyway I can make it appear?
Here's my code:
<ion-view ng-controller="GuDetailCtrl">
 <ion-nav-bar class="bar-positive">
<ion-nav-back-button class="button-icon ion-arrow-left-c show">
</ion-nav-back-button>
 </ion-nav-bar>
 <ion-content class="padding">

    Name
    {{hotel.name}}

    Locality
    {{hotel.locality}}

    Amenities
    {{hotel.amenities}}

<button class="button button-positive" ng-click="modal.show()">
  Create Booking
</button>

 </ion-content>
</ion-view>

Answer: You can try this code.The header has a class by default, if you don't explicitly specify one, then the back button won't show up. you can use bar-light or bar-royal in your class.
<ion-nav-bar class="bar-royal">
    <ion-nav-back-button>Back</ion-nav-back-button>
</ion-nav-bar>

for more, You can see here
Comment: This page is navigated to from another page. The parent page does not have a nav bar, so I can't have a common nav bar class. I tried using `bar-royal` in my code. The colour changed, but the back button still doesn't show up.
Comment: ok, I think you need to see this [link](https://stackoverflow.com/questions/32598893/how-to-force-ionic-display-back-button-on-certain-page) hope its help you.
Comment: I'm glad you got the solution.

Ion-nav-bar for a view