Draw into Fullscreen GL Context

Question: Ok this is a little tricky. I'm detecting when an application goes into fullscreen mode (captures the display) and then i need to draw occasionally some stuff into the captured displays context for notification purposes (like Growl notifications, but has to work in fullscreen mode too).
Is there any way to modify another apps GL/CG context (For example Fraps on Windows does inject the FPS counter into OGL apps)? The shielding window overlay method unfortunately doesn't work when a display is captured. Any ideas?
Answer: The GLFullscreen sample application shows the old way and the 10.6+ way of creating fullscreen windows (and contexts). The new way is just a screen-sized window above most other things, while the old way is a special fullscreen mode that doesn't let anything else draw above it, with CGL. So if the application is using the new, simplified mechanism it may make a difference. I'm guessing you can't with the old way but might be able to with the new way.
Comment: Yes but that's not the question. The question is how i can modify ANOTHER applications captured screen contents.
Comment: I know, and I'm saying it might depend on which way that OTHER application creates its fullscreen context.
Comment: I tried the deprecated `CGLSetFullScreen` and it seems to work (the `CGLSetFullScreenOnDisplay` doesn't) even if the screen is already captured, so I might be able to render something on top. But i don't really want to use a deprecated function :(. I'll try getting it to work with the AGL calls (http://developer.apple.com/mac/library/documentation/GraphicsImaging/Reference/AGL_OpenGL/Reference/reference.html)
Comment: Don't you mean NSGL? AGL is for Carbon.
Answer: You can in fact draw over the screen with plain OpenGL and the Quartz Display Services. There are some drawbacks tough that i don't know how to work around.

The CGLSetFullScreen is deprecated and CGLSetFullScreenOnDisplay won't work with captured displays.
The drawing flickers because the other GL context interferes with this one

.
CGOpenGLDisplayMask displayMask = CGDisplayIDToOpenGLDisplayMask(displayId);
CGLPixelFormatAttribute attribs[] = {
    kCGLPFAFullScreen,
    kCGLPFADisplayMask,
    displayMask,
    0
};

// Create gl context
GLint numPixelFormats;
CGLPixelFormatObj pixelFormatObj;
CGLChoosePixelFormat(attribs, &pixelFormatObj, &numPixelFormats);

CGLCreateContext(pixelFormatObj, NULL, &glContext);

CGLDestroyPixelFormat(pixelFormatObj);
CGLSetCurrentContext(glContext);
CGLSetFullScreen(glContext);

do {
    glLoadIdentity();

    glBegin(GL_TRIANGLES);

    glColor3f(1.0f, 0.0f, 0.0f);
    glVertex3f(0.0f, 1.0f, 0.0f);
    glColor3f(0.0f, 1.0f, 0.0f);
    glVertex3f(-1.0f, -1.0f, 0.0f);
    glColor3f(0.0f, 0.0f, 1.0f);
    glVertex3f(1.0f, -1.0f, 0.0f);

    glEnd();
    glFlush();

} while (!invalid);

Draw into Fullscreen GL Context


How to disable internet on a PSP?

Question: I'm not allowed to get a PSP unless my parents can disable the internet, and preferably if there is a password for my parents to use. Is there a parental control panel with internet restrictions? And if not, is there another way to permanently block internet access?
Comment: It displays absolutely no research, nor effort beforehand.  PSP 2000's have been out for seven years now; there's lots of documentation out on them, so doing a little bit of research is to be expected before asking.
Comment: Is there something wrong with this post that I'm missing?
Comment: There are no parental controls, but your parents can block the WiFi Access via the MAC of the PSP (unique adress of the network device, not to be mistaken for IP).
Comment: The could always just super-glue the wireless switch to off. O.o
Answer: While you cannot disable Internet connectivity as a whole, you can disable the Internet browser using parental controls.
You'll need to go to Settings > Security Settings, set a parental controls password (0000 being the default), then enable Internet Browser Start Control.
Source: Playstation Knowledge Center
Answer: Wanted to make comment can't sorry
They could also use OpenDNS to shield all devices in you home as it will handle filtering for them.
Link:
http://www.opendns.com/home-internet-security/parental-controls/opendns-familyshield/

How to disable internet on a PSP?


Replacements for isNullOrUndefined and isNumber utils methods after AngularJS v0.11.3 onwards

Question: The isNullOrUndefined and isNumber util methods have been deprecated since AngularJS v0.11.3. How can I implement these methods instead?
Comment: I believe you can use isNaN() function to check if it is a number, and for isNullOrUndefined, why just not use if(!someVariable), it will check for empty string,null,undefined.. or you need something different?
Comment: i need to check if the parameter is null or undefined. to prevent null exception error
Comment: I mean, if (!someVariable) should do that
Comment: Possible duplicate of [check null,empty or undefined angularjs](https://stackoverflow.com/questions/36124986/check-null-empty-or-undefined-angularjs)
Answer: Solution:
For isNullOrUndefined use:
value === undefined || value === null

For isNumber use:
typeof value === 'number'

Just to give a little background as to why it has been deprecated:
1. All the deprecated util.is*() function has some corner cases which are not covered.
2. Core modules shouldn't contain functions which are heavy or can be easily written by user. Core modules should be as light as possible.
Example for corner cases:
util.isObject() returns false for a function. When it should actually return true.


When aligning the logo using float the header goes wonky HTML

Question: So I'm extremely new to html and css and I want to create a website. But when I use float: left; to make my logo stay to the left, the header goes wonky.
https://jsfiddle.net/bm0dynw6/

.logo {
  float: left;
}

  <button
    id="Home"
    class="tablink"
    onclick="window.location.href='[Redacted]'"
  >
    Discord invite
  </button>

Answer: You can use
.header::after {
    display: block;
    clear: both;
    content: "";
}

or
.header {
    display: flex;
    justify-content: space-between;
}

and remove the float:left from logo
Answer: USE THIS
.header {
    display: flex;
    align-items:flex-start;
}


Need to match a unique string from a file, then remove the entire encapsulated text

Question: Good Day Everyone,
I'm currently trying to write a routine that will examine a file for a particular unique string, then delete the entire encapsulated text as follows:
define service{
    use                     generic-service,srv-pnp
    host_name               MEVIE.COM
    service_description     NSClient++ Version
    check_command           check_nt!CLIENTVERSION
    }

There's many instances of define service { ... } in the file.  So I can't just search on define service, I have to search on the unique string then delete the entire define service { ... } encapsulation.
For example:

Find the string "NSClient++ Version" in the file...
Delete EVERYTHING within define service{ .... }
Delete define service { .... } tags as well.

I really hope my goal is clear.
I've tried: sed -n '/NSClient+++ Version/{H;g;p};H' MEVIE.bak|tail -n5 > mevie.fil .. it returns everything except the last '}'
Comment: Can there be `{}` nesting inside `define service`?
Comment: @nhahtdh - No, there will be no nested {}
Comment: Google for "sed multi-line"
Comment: @user1883592 - No, do NOT google for "sed multi-line" unless it's to get a chuckle at the syntax. sed is an excellent tool for simple substitutions on a single line but for any other text manipulation needs you should use awk.
Answer: awk '
/^define service{/ { inBlock = 1; block = "" }

inBlock {
   block = block $0 ORS
   if (/}/) {
      if (block !~ /NSClient\+\+ Version/)
         printf "%s",block
      inBlock = 0
   }
   next
}

{ print }
' file

Comment: that is awesome Ed.. I will try it out shortly.  Keep you in the loop
Answer: Here's one way using sed. Run like:
sed -f script.sed file

Contents of script.sed:
:t
/define service{/ , /}/ {
    /}/! {
        $! {
            N;
            bt
        }
    }
    /NSClient++ Version/d;
}

Alternatively, here's the one-liner:
sed ':t /define service{/ , /}/ { /}/! { $! { N; bt } }; /NSClient++ Version/d }' file

Answer: There are shorter solution, but I used to do it this way:
awk '/^define service/ {
  if ( $0 ~ "}" ) {
    block=$0
  } else {
    block=$0
    while ( block !~ "}" ) {
      getline nl
      block=block "\n" nl
    }
  }
  if ( block !~ "NSClient\\+\\+ Version" ) { print block }
}' INPUTFILE > OUTPUTFILE

See here in action.

on every starting (define...) line check if it contains }, and if so, save the line as block
else read until the next line with } and add the lines to block
finally check if we want to print it out
Comment: The above will fail in various ways given various input files and will be difficult to enhance in future, all courtesy of getline. See http://awk.info/?tip/getline. It also won't print the file contents between blocks and is unnecessarily using a string RE in the RE comparison, hence the need to escape the "+"s twice.
Answer: One way with perl:
perl -0pe 's/define service[ \t]*\{[^{}]*?NSClient\+\+[ \t]+Version[^{}]*?\}//gs' filename


How to visualize Air Quality Index on physical widget to be easily recognized by pedestrians

Question: I plan to develop a network of physical widgets all over the city to inform pedestrians about current Air Quality Index in their neighborhood. This is needed to improve people conscious about their environment pollution to start them acting against.
I need to create that widget to visualize current AQI, so information like here:

This is:

one of 6 colors
and up to 3 digits number

It should be possibly cheap and easily recognized form moving vehicles (target: public transport) and from some distance.
I plan to put those widgets in friendly venues (shops, offices, even flats).
Just for reference, here http://www.livinglightseoul.net/ is an example of such installation.
Comment: Do you only want to show the current index - or a card with all the possible indexes?
Comment: updated question to be more precise
Answer: I would suggest a series of simple smiley face graphics for the rating.  Advantages:

Instantly recognizable
No problem for color blind people.
More likely to stand out as unique in a street setting.  Something based on green/yellow/orange/red colors would be competing with many other signs and lights that use these colors to communicate information.

If you need six levels, you could use something like:

Wide smile
Slight smile
Indifferent (straight line mouth)
Slight sad face
Very sad face
Face that looks ill (tongue sticking out)

A simple graphic like a smokestack next to this may communicate the meaning.
Comment: I agree, _index_ is misleading. Is 0 better than 100? How much? What's that number?
Comment: I think this is why information is normally given in two ways: those who are not "AQI literate" will recognize color but the number is quite useful for people who know a little bit about the subject and want to know precisely "where we are at the scale 0-500".
Comment: From the pit of my ignorance I'd say very few people will recognize what 500 is. I'd even guess they will think, _"WOW, air quality is 500. It's better than that poor people with just 400 (higher quality index is better)..."_.
Comment: You're right, especially that people who recognize what 500 is are most probably able to check that 500 online somewhere.
Comment: I've found similar approach implemented in Shanghai, check those pokemon style children http://www.semc.gov.cn/aqi/home/English.aspx
Answer: Given that you want people to recognise what it is from vehicles - you need to have one icon that is instantly recognisable as air quality.
Then combine it with the colour and number, or possibly easiest to show is the opposite - air pollution.
The noun project has lots of icons for pollution

Icon credit: Amelia Wattenburger
Update - here's another version as the 200 won't mean much
And potentially modify the amount of smoke coming out as an extra visual clue.
Answer: If you want to make these statistics visible to motor vehicles I would take a page from the US Forest Service which already implemented a very similar scale for signs warning of risk of forest fires:

You can of course include the numbers and labels but what really matters is where the current level is pointing into relation to the scale of values and the color indicating good/bad. At a quick glance a car driving by can see that if the "pointer" is at the far right of the scale in the red zone then the emission level is high.
Comment: This is a good suggestion.  One possible downside: it takes a lot of space to show the whole scale, so it might not work so well in urban areas.
Comment: Yeah it will be rather difficult to fit it.


Cannot set IndexMemory and DataMemory on MySQL Cluster

Question: I am in the process of setting up a MySQL Cluster (version 7.2.4) on 64-bit Debian Linux.  The cluster has two management/SQL nodes and two data nodes.  Each server has the following in /var/lib/mysql-cluster/config.ini:
<code>[NDBD DEFAULT]
NoOfReplicas=2
DataDir=/var/lib/mysql-cluster
DataMemory=256M
IndexMemory=64M

[MYSQLD DEFAULT]

[NDB_MGMD DEFAULT]

[TCP DEFAULT]

# Management node 1
[NDB_MGMD]
NodeId=1
HostName=192.168.25.10
DataDir=/var/lib/mysql-cluster

# Management node 2
[NDB_MGMD]
NodeId=2
HostName=192.168.25.11
DataDir=/var/lib/mysql-cluster

# Storage node 1
[NDBD]
NodeId=3
HostName=192.168.25.12

# Storage node 2
[NDBD]
NodeId=4
HostName=192.168.25.13

[MYSQLD]
NodeId=5
HostName=192.168.25.10

[MYSQLD]
NodeId=6
HostName=192.168.25.11

[MYSQLD]
[MYSQLD]
</code>
The documentation and my own research on Google leads me to believe that this will set the data memory to 256 MB and the index memory to 64 MB.  However, when the cluster is started using this configuration, these settings are not honored:
<code>mysql> SELECT node_id, memory_type, total FROM ndbinfo.memoryusage;
+---------+--------------+----------+
| node_id | memory_type  | total    |
+---------+--------------+----------+
|       3 | Data memory  | 83886080 |
|       3 | Index memory | 19136512 |
|       4 | Data memory  | 83886080 |
|       4 | Index memory | 19136512 |
+---------+--------------+----------+
4 rows in set (0.03 sec)
</code>
For each node, the data memory is 80 MB and the index memory is 18 MB, which are the default values according to the MySQL Cluster documentation.
I've tried a few minor tweaks, such as changing the [NDBD DEFAULT] to [ndbd default], but nothing has worked.  Does anyone know why I'm not able to change these two settings?
As always, any help will be greatly appreciated.  Thanks!
Comment: I believe I did solve this, but I honestly don't remember how.  Shortly after I posted this, we had a serious server failure and spent a few days recovering from it, so I never documented the MySQL Cluster like I wanted to.  Try the suggested fix in Bernd's comment below.  If it works, I'll mark that answer as accepted.
Comment: Good question. Did you ever find a solution? I'm having the exact same problem even after restarting the manager with -reload and -initial.
Comment: Thanks for the response Dave. I got this working now after realizing that these were Data-Node rather than SQL-Node metrics. For my case I removed one of the Data Nodes and increased the Memory of the remainder, then restarted NDBD with the --initial flag, which is needed when these parameters change.
Answer: when starting both management servers with the new configuration: did you restart the management nodes with --reload to actually load the new configuration from the config file? If --reload is not used the cached version of the pervious valid configuration will be used. In order for the configuration to be picked up by the data nodes also they have to be restarted.
Bernd


How to find curve C given by the equation?

Question: Consider the curve C given by the following equation
$$
\sqrt{x}+\sqrt{y}=\sqrt{a}
$$
 where $a$ is a constant with the condition $a > 0$.
Let $(x_0, y_0)$ with  be a point on C such that $x>0$ and $y>0$.
Now,  assume that $(x_1, 0)$ and $(0, y_1)$ be considered $x$ and $y$ such that intercepts of the tangent line to C at $(x_0, y_0)$.
My question: How to proof that $x_1 + y_1 = a$?
My try:
Currently I just found the derivative using implicit differentiation, and used the slope for its tangent line, but now I'm lost and not sure what to don.
Thanks for any suggestion.
Comment: What have you tried? And what does "0 following" mean? Were you going to write more?
Comment: If you've already done all that, why didn't you say so in your question? That kind of details and calculation is what separates a mediocre (or even bad) question from a good one. Also, please consider using [MathJax](https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference) for formatting math text. It looks a whole lot nicer.
Comment: Currently I just found the derivative using implicit differentiation, and used the slope for its tangent line, but now I'm lost and not sure what to do.
Comment: My bad, I'm still new to this website! Thanks for the heads up
Answer: Let $x=a\sin^4\theta$ and $y=a\cos^4\theta$ be a perametrization of this curve. Then $\dfrac{dy}{dx}=-\cot^2\theta.$
In order to find $x_1$ and $y_1$, first we need the equation of tangent line through $(x_0,y_0)$ which is easily followed by the point-slope form $$\dfrac{y-a\cos^4\theta_0}{x-a\sin^4\theta_0}=-\cot^2\theta_0,$$ where $\theta_0$ is the corresponding parameter. From here find $x_1$ and $y_1$ by substituting $y=0$ and $x=0$ respectively.
Answer: By intrinsic differention show $dy/dx = -\sqrt{y/x}$.
The tangent line at $(x_0,y_0)$ is $y - y_0 = -\sqrt{y_0/x_0}(x - x_0)$.
Can you now find the intercepts and finish the problem?


Email notification on automatic snap upgrades

Question: Apt can send you emails for automatic (aka unattended) upgrades.
How should snap be configured to achieve the same result?
Answer: I couldn't find any documentation about emailing of changes.
But if you are an advanced user, you may able to make a snap that does that using snapd-control interface.

interface source code: https://github.com/snapcore/snapd/blob/master/interfaces/builtin/snapd_control.go
documentation: https://snapcraft.io/docs/snapd-control-interface


Examples (or characterization) of conditionally complete vector lattices

Question: Are there examples of conditionally complete vector lattices that are not subsets of measurable functions (with order induced by cone of non-negative functions)?
I ask, because there are results in this direction: every Hilbert lattice is isomorph to some $L^2$ with order induced by pointwise inequalities, every lattice on a Hilbert space with self-dual positive cone is isomorph to $L^2$.
Are there similar results that say: a conditionally complete lattice with some extra structure is isomorph to some $L^2$?
Answer: There are conditionally order complete vector lattices (even conditionally order complete Banach lattices) which are not isomorphic to an $L^2$-space. For instance, for every measure space $(\Omega,\mu)$ and for $p \in [1,\infty)$ the space $L^p(\Omega,\mu)$ is conditionally order complete. If $(\Omega,\mu)$ is $\sigma$-finite, then $L^\infty(\Omega,\mu)$ is conditionally order complete, too.
If an $L^p$-space is infinite-dimensional and $p \not=2$, then it is not Banach space isomorphic to an $L^2$-space. Hence, it is not vector lattice isomorphic to an $L^2$-space, either (since each vector lattice isomorphism between two Banach lattices is automatically a Banach space isomorphism).
On the other hand, there are various representation theorems on how Archimedean vector lattices can be represented as sublattices of certain function spaces. An overview over many such representation thereoms can be found in Chapter 7 of the classical book "Riesz Spaces I" (1971) by Luxemburg and Zaanen.
In particular, every Archimedean vector lattice is a sublattice of a space of functions (but these functions might take the values $\infty$ and $-\infty$ on a "small" subset of their domain). This is the content of [op. cit., Section 44 in Chapter 7].
Comment: Thank you for your answer! I did not realize that $L^p$ is order completefor $p<\infty$ without $\sigma$-finiteness. I am right in assuming that a normed space with continuous lattice operations is an Archimedean vector lattice?
Comment: @daw: Indeed, for a normed space which is lattice ordered, you have the following implications: the lattice operations are continuous $\Rightarrow$ the cone is closed $\Rightarrow$ the space is Archimedean. (Both implications are straightforward to prove.)
Comment: Then these are isomorphic to some space of functions. Thank you again.


How to fire block/draft block large gaps in the basement?

Question: Coming up on my inspection and I am unsure what to use to fire-block/draft stop parts of my basement.
The framing around the perimeter sits between 4" to 6" away from the poured concrete. I'm using this spray foam to fill smaller gaps and holes (It says it's fire rated on that link)

I was thinking of using either faced or unfaced insulation such as this product for the vertical draft stopping every 8 to 10'. Staple it to the wood and then use tape to fasten the other side to the radient barrier.
Would that be sufficient or do I need to consider a different product?
Comment: Why are your 2x walls so far away from the concrete in the first place? Seems like a lot of wasted floor space. Or are you using that space for Scooby Doo style secret passages?
Comment: The framing was partially completed when we moved in and felt like it wasn't worth it to redo it. The wall pictured has the waste sewage lines running on it. the other walls are more like 2-3" away from the concrete.
Answer: Fireblocking is required at 10' on center both vertically and horizontally. (See R602.8)
Acceptable materials are 2x material or 1x material with joints backed up, or one layer of 23/32 structural panels (plywood), 3/4" particleboard, 1/2" gypsum board, 1/4" cement based mill board, but must be secured. Batts and blankets of mineral wool or glass fiber installed in a secure manner. (See R602.8.1)
Loose fill insulation is not approved.
Comment: It has nothing to do with being "fire rated". This is about "fireblocking".  So it has to do with stopping (or containing) air flow and limiting it to 10' vertically and horizontally.
Comment: So a material says that's it's fire-rated, that's good enough?


Compatibility of a metric for a given topological space.

Question: It is indeed a very easy question but I am not %100 sure about it.
Assume you are given a topological space $(X,\tau_x)$ with base $\mathcal B$.
And you are given a metric on $X$. We know that $d$ induces a topological space with base $\mathcal B_d=\{B(x,\epsilon)|x\in X, \text{for some}\quad  \epsilon>0 \}$
Is the problem showing $d$ is compatible with given $(X,\tau_x)$, actually showing the given topological space is equivalent to the induced by $d$?
Comment: Yes. [Comments must be at least 15 characters in length.]
Comment: Yes. And a topological space $(X,\tau)$ is called metrizable if there is a metric $d$ on $X$ which is compatible with $(X,\tau)$..... And  $(X,\tau)$  is called completely  metrizable  if there is a complete metric $d$ on $X$ which is compatible with $(X,\tau)$.
Answer: Yes, $\mathcal{B}$ induces the  topology $\mathcal{T}_X$ (the original topology on $X$),by taking unions, and a metric $d$ induces a base $\mathcal{B}_d = \{B(x,r): x \in X; r>0\}$.
Your task is then indeed to show that the topology induced by $\mathcal{B}_d$ is also exactly $\mathcal{T}_X$, or any $B \in \mathcal{B}$ is metric open and vice versa. So you need
$$\forall B \in \mathcal{B}: \forall x \in B: \exists r>0: B(x,r) \subseteq B\tag{1}$$
and also
$$\forall x \in X: \forall r>0: \exists B \in \mathcal{B}: x \in B \subseteq B(x,r)\tag{2}$$


How do I programatically open an application and check when it's closed?

Question: I've been able to use a winforms application to open another winforms application using:
Rhino4.Application oRhino = (Rhino4.Application)Activator.CreateInstance(Type.GetTypeFromProgID("Rhino4.Application"));
But how do I check if it gets closed? Is it possible to create an event that will get fired when the user closes the application?
EDIT
Process[] pr = Process.GetProcessesByName("Rhino4");

                for (int i = 0; i < pr.Length; i++)
                {

                    if (pr[i].MainWindowTitle != null)
                    {
                        if (pr[i].MainWindowTitle.Length > 4)
                        {
                            if (pr[i].MainWindowTitle.Substring(0, 4) == "wall")
                            {
                                pr[i].Exited += new EventHandler(caseInfoMenu_Exited);

                            }
                        }
                    }

                }

void caseInfoMenu_Exited(object sender, EventArgs e)
        {
            MessageBox.Show("Window closed");
        }

I've managed to identify the process using this code. But the Exited-event doesn't fire when I close the program.
Comment: Windows or Console? The two are different to achieve what you wish.
Comment: I have updated my answer with some further thougts about your problem.
Answer: Its maybe not the most elegant solution but indirectly you could do this by checking if the process exist or not and then do this repeatable. This is of course if you do not already have a handle to the process.
void checkProcess()
{
    Process[] processes = Process.GetProcessesByName("NameOfProcess");
    if (processes.Length == 0)
    {
         // No such process
    }
    else
    {
         foreach (Process proc in processes)
         {
            // do something with proc
         }
    }
}

Edit: Some thoughts on this after reading the posts in Abdul's answer plus your own question. This is by no means an answer, but maybe it can help you on your quest.
Firstly, Activator.CreateInstance calls the best fitting constructor on the object type that you give to it and returns a handle to that object. It does create the threads/processes itself and thus it has not knowledge about them. The (9) processes you'll see in your list are probably created by the Rheno4 class itself. There is a discussion about this here.
Secondly, according to msdn the EnableRaisingEvents property should be set to true when the process is created for the Exited event to function correctly. This leaves me wondering what happens when you attach the event after the process is already created?
You could of course iterate over all matching processess before and after calling CreateInstance to extract all new instances of Rheno4 that has been created. But this is far from a bulletproof solution and the risk is that you are fetching processes that are created by someone else or that not all processes are retreived (in case there is a delay in creating the other object). Depending on your needs, however, this maybe is appliable.
Another thought. The processes returned from the GetProcessesByName has a rich set of properties. Maybe you can look though these and find a common denominator for the processes returned. The ones I would start to investigate are: Threads, StartInfo, MainModule.
Comment: von Plan - This has given me a lot to work with. Thanks. I'm gonna look into the properties, I think you're right. One of these must contain some information which I can use.
Answer: What about catching Exited event
myProcess.Exited += new EventHandler(myProcess_Exited);

private void myProcess_Exited(object sender, System.EventArgs e)
    {

        eventHandled = true;
        Console.WriteLine("Exit time:    {0}\r\n" +
            "Exit code:    {1}\r\nElapsed time: {2}", myProcess.ExitTime, myProcess.ExitCode, elapsedTime);
    }

Source msdn.
Comment: @Abdul Muqtadir - how do I get the process from the Application. The reason why I use Activator.CreateInstance is because I need to control the application. I start a script after opening the application and need to know if the user closes it.
Comment: Can't get you, can't you launch the process?
Comment: Nope, cause then I have no control of the lauched application. But perhaps i can combine the Exited-event you mention with Process.GetProcessByName?
Comment: @Bildsoe: Look at the code in the MSDN example Abdul provided. If you start the application in code and you can save a handle to the process, then I think you should go for this approach as it gives you the most control of the process. If you do not posess control of the process (ie, its started by windows/user/etc) then I would recommend the GetProcessByName approach, i use it myself and I belive it to be rock solid. I see no point in mixing the two of them.
Comment: @Tele von Plan - My problem is that I need to create the application instance by application.createInstance inorder to access the scripting module of the application. How will I get the handle of the current process? When I try to access process.handle access is denied. Do I use mainWindowTitle then? cause I tried this, and it returned nothing.
Comment: @Tele von Plan - I tried using processName, but 9 processes has the same name as the one I'm trying to reference.
Comment: Hmmm - I'm kinda stuck. I found that the Exited-event applied to the process identified by the windowMainTitle, didn't fire, if I however applied the event to all 9 running process, it does fire. But how will is it possible to control, that it is the correct window which has been closed ie. if there are more instances of the same application?
Answer: If you want to start the application again after closing then :-
I think you need to crearte a Windows Service which will keep checking the process running and if it is closed then start the application again
As far as events are concern then "Closing" and "Close" events are there in Windows App which fires when user shutdowns the app.
Comment: If you create a windows service of this kind, be aware that you cannot easily start gui applications as a system service. It is possible, but not always recommended, see http://stackoverflow.com/questions/267838/how-can-a-windows-service-execute-a-gui-application for more infor on the subject.


Parse XML to UL

Question: I am trying to use JQuery to parse a sitemap.xml to look like this HTML: http://astuteo.com/slickmap/demo/
After working on it for a few hours I decided I really need some help in the right direction.
the main template it has is this, where each indent is a different directory level:

Home

Services

Graphic Design

Web Development

Internet Marketing

Social Media

Search Optimization

Google AdWords

Copywriting

Photography

I am using a google sitemap.xml which looks like this:
http://meyers.ipalaces.org/sitemap_000.xml
<url>
  <loc>http://meyers.ipalaces.org/</loc>
  <lastmod>2011-02-26T09:32:18Z</lastmod>
  <changefreq>hourly</changefreq>
  <priority>0.4</priority>
</url>
<url>
  <loc>http://meyers.ipalaces.org/meyers/photos/Explorer</loc>
  <lastmod>2011-02-26T09:31:33Z</lastmod>
  <changefreq>hourly</changefreq>
  <priority>0.2</priority>
</url>

The method I came up with avoids setting everything exactly how it is on the css template, but instead I just focused on getting it to have the correct levels:
What it does is takes the level of a URL goes through each level trying to create the list based on the previous level. So with the example www.example.com/brand/model/product/:
it gets the first [0] element, www.example.com this is level 1 so it checks is there a ul[id=1], if not then run create_ul and append it to #content. Now attach a li to the ul it just made..level 1 is "special" because it has to be created first, thats why I have a lot of if level==1 in the code.
For the next element [1] it gets brand which is level 2. This time it checks
is there a li[id=www.example.com] ul[id=2] if there exist, it will create one and then attach a li to the ul.
This method isn't working out for me at all, it also messes up if say level 8 has the same id and something from level 4. I just need a new idea on how to approach this.
Here is my functions as of now, but im sure I should just scrap most of the code:
function create_ul(level, id, prev_id) {
        var ul = $('
',{
            id: level
        });

        if(level==1) {
            $('#content').append(ul);
        } else {
            $('ul[id='+(level-1)+'] li[id='+prev_id+']').append(ul);
        }
}

function create_li(level, id, prev_id){
    if (level ==1){
        if ($('ul[id='+level+']').length == 0) {
            create_ul(level, id, prev_id);
        } else if ($('ul[id='+level+'] li[id='+id+']').length > 0) {
            return;
        }

        var li = $('
',{
            id: id
        });

        var a = $('',{
            text:   level + " - " + id,
            href:  "nothing yet"
        });

        $('ul[id='+level+']').append(li);
        return;
    }
    // If there is no UL for the LI, create it
    if ($('li[id='+prev_id+'] ul[id='+level+']').length == 0) {
        create_ul(level, id, prev_id);
    } else if ($('ul[id='+level+'] li[id='+id+']').length > 0) {
        return;
    }

    var li = $('
',{
        id: id
    });

        var a = $('',{
            text:   level + " - " + id,
            href:  "nothing yet"
        });

    li.append(a);

    $('li[id='+prev_id+'] ul[id='+level+']').append(li);
}

$.ajax({
    type: "GET",
    url: "/sitemap_000.xml",
    dataType: "xml",
    success: parseXml
});

function parseXml(xml) {
    URLS = new Array(new Array(), new Array(), new Array());
    $(xml).find("loc").each(function(){
        var url = $(this).text();
        URLS[1].push(url);

        url = url.replace("http://", "")
        var url_array = url.split("/");

        URLS[0].push(url_array);

        var rawLastMod = $(this).parent().find('lastmod').text();
        var timestamp = rawLastMod.replace(/T.+/g, '');
        var lastMod = formatDate(timestamp);

        URLS[2].push(lastMod);
    });

    $(URLS[0]).each(function(i, url_array){
        $(url_array).each(function(index, fragment){
            var level = index+1;
            var id = fragment;
            if(index!=0) {
                var prev_id = URLS[0][i][index-1];
            } else {
                var prev_id = null;
            }

            if(id != "") {
                create_li(level, id, prev_id);
            }
        });
    });
}

I have decided to reply on a PHP solution instead of Javascript. I am using this PHP script: http://www.freesitemapgenerator.com/xml2html.html
Answer: This is my try to it.
Basically it uses an array to store all the urls' pieces.
For example, the url mytest.url.com/sub1/othersub2.html is handled as:
var map = ['mytest.url.com']['sub1']['othersub2.html'];

This is possible because javascript allows you to index arrays using strings.
Full code (just replace your parseXml function and test it on chrome or firefox with firebug):

Comment: Someone can explain to me why it is not highlighting the code correctly as "javascript"? *EDIT*: Ok, tricked it by adding the `

Parse XML to UL


How to read this PDA?

Question:
This is an old HW question where I had to find out how many times the q\loop state was visited for each given string:
bb: 5
abab: 0
abba: 8
babbab: 11
I understand how the 1st string visits the state 5 times and the 2nd string is not accepted, but I don't know the process for the 3rd and 4th strings. I would really appreciate it if someone could just walk through the states visited for the 3rd or 4th string because I keep getting stuck
Answer: This PDA matches palindromes. How does it do it? It looks for P on the stack and replaces it with either aPa or bPb, then matches a on the stack with a in the input. Likewise for b. It replaces P nondeterminstically.
Let's walk through #3. We'll focus on Q_loop, which I'll just call L for simplicity. The top of the stack will be the rightmost character.

The first time we get to L, the input is abba and the stack is $P. We will nondeterministically follow the e,P->a transition.
The input is abba, the stack is $aPa. We will follow the a,a->e transition.
Input: bba, stack: $aP. Follow e,P->b.
Input: bba, stack: $abPb. Follow b,b->e.
Input: ba, stack: $abP. Follow e,P->e.
Input: ba, stack: $ab. Follow b,b->e.
Input: a, stack: $a. Follow a,a->e.
Input: e, stack, $. Follow e,$->e and accept in the next state.

How to read this PDA?


How to inject the Presenter class which has an interface as its constructor parameter in the Activity class using dagger 2?

Question: I need to inject the Presenter class inside the activity using Dagger2 but to instantiate the Presenter class, I need to pass an interface as a parameter from Activity.
Without using dagger2 :
<code> Interface interface;
 interface = this;
 Presenter presenter = new Presenter(interface);
</code>
How to achieve this using Dagger2 ?
Answer: You should provide Activity in your @Provides method. How to make your activity actually available there depends on how you implemented DI with Dagger.
If you use @ContributesAndroidInjector, then you have automatic access to your activity in your @Module and you can just name it in your @Provides method arguments. Remember tou use your exact Activity class.
Provide presenter like this:
<code>@Provides
Presenter providePresenter(YourActivityName activity) {
    return new Presenter((Interface) activity);
}
</code>


ReactJS: componentWillReceiveProps is called on state change?

Question: Im trying to solve a scenario, where parent would include a Module and when a button is clicked inside parent, Module will appear.
Now, there will be a close button in Module, clicking on which will hide the Module. Next time parent button is clicked, Module should appear again, and so on.
Code so far:
var Parent = React.createClass({
  getInitialState(){
    return{
      showModule: false
    };
  },
  render(){
    return(

          Click me to show module
          <Module show={this.state.showModule}/>

    );
  },
  _showModule(){
    this.setState({
      showModule: true
    });
  }
});

var Module = React.createClass({
  getInitialState(){
    return{
      show: this.props.show
    };
  },
  componentWillReceiveProps(nextProps){
    console.log('componentWillReceiveProps is called');
    this.setState({
      show: nextProps.show
    });
  },
  render(){
    return(
      (this.state.show?

          Click me and I will disappear myself

 : null
      )
    );
  },
  _hide(){
    this.setState({
      show: false
    });
  }
});

The problem here is, whenever I call the hide function in Module (which hides itself by changing state.show to false), componentWillReceiveProps gets called.
Shouldn't it get called only when Parent is passing new props? How and why would state change in child Module invoke componentWillReceiveProps?
JsBin http://jsbin.com/cunuci/edit?js,console,output
Answer: When you click on the "Click me and I will disappear myself" you actually click on the Parent and called Parent._showModule handler.
Change

  Click me to show module
  <Module show={this.state.showModule}/>

to

Click me to show module

   <Module show={this.state.showModule}/>

http://jsbin.com/naloxafile/1/edit?js,console,output


Aligning list groups of varied height horizontally (Bootstrap 3)

Question: I'm trying to horizontally align my list groups, which currently act like this:
https://i.stack.imgur.com/S2m6H.png
What I want is for the list groups to display on the next line, directly below the list-group above with the biggest height.
They are all placed on the same row, with 6 columns each. My code looks like this:

Soveværelser

Nr. 1: Dobbeltseng(e) (2 Sovepladser)

Nr. 2: Enkeltseng(e) (2 Sovepladser)

Toiletter

Nr 1: WC. Varmt og koldt vand

I would like to avoid created a new row for every 2nd list group, as I need this implemented in a CMS system. Is there a smarter way to set up a grid? Having the list groups align below each other, while eliminating white space could also work, but I'm not if that is possible.
Edit: Added code changes.

Soveværelser

Nr. 1: Dobbeltseng(e) (2 Sovepladser)

Nr. 2: Enkeltseng(e) (2 Sovepladser)

Toiletter

Nr 1: WC. Varmt og koldt vand

Andre faciliteter

Køkken: varmt og koldt vand

Gas/elkomfur

Opvaskemaskine

Udenfor

Terrasse el. lignende

P-plads på grunden: 3

Havemøbler

Grill

Answer: The way i think this could be done is like this :
i changed col-sm-6 to col-sm-12 , and then i added col-sm-6 to  the list-group

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

Soveværelser

Nr. 1: Dobbeltseng(e) (2 Sovepladser)

Nr. 2: Enkeltseng(e) (2 Sovepladser)

Toiletter

Nr 1: WC. Varmt og koldt vand

Comment: I tried making the changes, but now my layout looks like this: http://i.imgur.com/R3ZTlrQ.png
Comment: I made some changes to your code, which returns the desired look, but will be difficult to implement in a CMS system. See edit.
Comment: isnt this what you wanted?
Comment: I might have explained it badly. I want 2 list groups on each line with the same width, while aligning the list groups horizontally on each line. There can be any number of list-groups.
Comment: now i think i understand ... unfortunately  i think the right way of doing that is by adding a row every 2 list grups ... Any other solution i can think of is somehow a hack to bootstrap...
Answer: I'm not exactely sure if thats what you are looking for, but u might do it with tables?

Soveværelser

Nr. 1: Dobbeltseng(e) (2 Sovepladser)

Nr. 2: Enkeltseng(e) (2 Sovepladser)

Toiletter

Nr 1: WC. Varmt og koldt vand

Answer: hi you can try css flexbox here
CSS
  .row.flex-row{display: -webkit-box;display: -ms-flexbox;display: flex; -ms-flex-wrap: wrap; flex-wrap: wrap;}
    .row.flex-row > div{margin-bottom: 15px;}
    .row.flex-row .list-group{margin-bottom: 0;}
    .row.flex-row .list-group,.row.flex-row .list-group .list-group-item{height: 100%;}

HTML

Soveværelser

Nr. 1: Dobbeltseng(e) (2 Sovepladser)

Nr. 2: Enkeltseng(e) (2 Sovepladser)

Toiletter

Nr 1: WC. Varmt og koldt vand

Toiletter

Nr 1: WC. Varmt og koldt vand

Nr 1: WC. Varmt og koldt vand

Nr 1: WC. Varmt og koldt vand

Nr 1: WC. Varmt og koldt vand

Toiletter

Nr 1: WC. Varmt og koldt vand

Toiletter

Nr 1: WC. Varmt og koldt vand

Comment: Thanks, this works perfectly! I'm not familiar with CSS Flexbox, but I will look into it. As I understand it, each list-group on each line will stretch its height to match the highest height on that line. My layout looks like this now: http://i.imgur.com/KjXH4WW.png


What protocols support screen sharing on Empathy?

Question: I am trying to follow the directions here  but so far have not found a working protocol so I was wondering if anyone knew of a working protocol that works?
Answer: Actually, I just answered that in the original question...  ;-)
It currently only works in one of the Jabber/XMPP protocol implementations that exist for Telepathy; the one in the telepathy-gabble plugin.
Answer: XMPP/Jabber is the main protocol. This means Google Chat, Facebook and normal Jabber accounts should work.
Comment: Have you tested the Facebook & Google Chat account options in Empathy?  It's not entirely clear to me whether they use the Gabble plugin or the libpurple plugin (the one that re-uses Pidgin)?
Answer: According to this. Its xmpp protocol.


Hot/Cold water lines not set in between studs Tub/shower removal

Question: I removed a tub/shower insert and noticed the hot/cold lines are not set in between the studs, how can I tile around them? I don't have a plumber available.
Comment: The vent pipe seems to be the problem.  If comfortable with losing about 3/4 inch floor space, then adding 1x2 or 1x3s to the wall should be enough to miss the pipes.
Comment: Are you intending to turn this space into a tiled shower?
Comment: What are you putting back in place of the tub/shower?
Answer: You need to fur out the studs with furring strips so that you can install cement backer board evenly.
Be careful when screwing board into that corner so that you don't hit those water lines.


Which batteries are compatible with the DeWalt DW9107?

Question: I have a DeWalt battery charger model# DW9107.  Which batteries can I charge in it? It says 14.4volts
I have a DeWalt hammer drill model# DCD950B.  Will the battery for it, DC9096 work with my charger? It says 18volts.
Comment: Vote to put on hold, off topic.
Comment: @WarLoki is there a more appropriate StackExchange to ask this question?
Comment: Have you tried contacting DeWalt?
Comment: I have submitted a ticket with them but have not heard back.
Answer: From DeWalt support:
Unfortunately it looks like the battery charger will not charge a 18 volt battery that will work with the DCD950b. The charger charges up to a 14.4 volt battery and the DCD950 will take a 18 volt battery. The battery and charger you will need for the DCD950 is  Charger 388683-12 and battery DC9096.
Answer: FYI, I tried the same thing. I have a dw9107 charger, and the 18v battery won't fit. I modified the battery casing a little and it charged the 18v battery just fine. I don't recommend this as I'm sure isn't recommended by Dewalt! just a little personal experience. 14.4 is only 3.6v from 18 so what the heck it worked.
Comment: Plus one for obsoleting planned obsolescence.
Comment: These are NiCd batteries, so the worst that would happen is you might trash the battery. Don't try something like this with Lithium batteries; the worst could be a serious fire.


Elevated Deck over concrete Patio

Question: I'm building a deck over a walkout basement.  I want to put a concrete patio below.  Can I dig the footers (3 total) to depth of 30" below the frost line and then do a monolithic pore of the concrete for footers and slab?  I plan to use simpson post base over the footer location imbedded in the concrete.  The other option is to use the concrete tubes and do the footers/concrete piers first and then poor the slab around, but trying to save time.
Thanks
Comment: Hello, and welcome to Home Improvement. Interesting question; let's see if you get a good answer. And, you should probably [take our tour](//diy.stackexchange.com/tour) so you'll know how best to participate here.
Comment: draw two pictures, plan and elevation (just draw by hand and take a picture).  I am unclear on the walkout basement, is there a patio attached to the walkout door and a staircase the comes up to grade?  How large is that patio?  How high up would the deck over this space be, I picture more than 8' in elevation?  The concrete slab would be the patio?  and the footings are just for the 3 posts that will support the deck above?  3 because the walkout wall is serving as one of the supports?  30" below your new frost line which uses the surface of the patio?  The slab will heave and pull footings.
Answer: Since you're not making your concrete patio as deep as the footers, your patio will be subject to frost heaving. This means that if you mechanically connect (e.g. build in a single pour) footers and patio, you'll make your footers subject to frost heaving as well, even though they reach below the frost line.
I believe heaving of the patio might be mitigated if you pour it over a bed of crushed stone, like basement and garage slabs are done, but I don't have experience with this.
Side note: you should use concrete tube forms regardless, as they will make your footers relatively smooth, making it much harder for anything subject to heaving to "catch" them and jack them up.
Comment: Hello, and welcome to Home Improvement. Thanks for the answer; keep 'em coming. And, you should probably [take our tour](//diy.stackexchange.com/tour) so you'll know how best to contribute here.

Elevated Deck over concrete Patio


Propagate all arguments following nth argument in a zsh script

Question: If I have a script like
curl --socks5-hostname "127.0.0.1:${2-1080}" $1

I can do:
purl bing.com 1081

Meaning:
curl --socks5-hostname "127.0.0.1:1081" bing.com

Now I want to dynamically add new arguments like:
purl bing.com 1081 --connect-timeout 1

How would I be able to do it?
If I use
curl --socks5-hostname "127.0.0.1:${2-1080}" $1 "$@"

Then it would end up as:
curl --socks5-hostname "127.0.0.1:1081" bing.com bing.com 1081 --connect-timeout 1

This is not the desirable outcome...
I would like:
curl --socks5-hostname "127.0.0.1:1081" bing.com --connect-timeout 1

Comment: This would be a relatively straightforward use of `shift 2` to drop the host and the port from `$@` before using it, except for the fact that `$2` is optional. Should I assume that if there are two or more arguments, the port is always specified?
Comment: @chepner yes. But good point, can we check if the $2 is a number, if not then we assume the port is not specified and use `shift 1` instead of `shift 2`?
Comment: We could. I'll write that up (and another idea I had).
Answer: Use
curl --socks5-hostname "127.0.0.1:${2-1080}" $1 "{@:3}"

or
host=$1
port=${2:-1080}
shift 2
curl --socks5-hostname "127.0.0.1:$port" $host "$@"

Comment: This will give unexpected results with something like `purl bing.com --connect-timeout 1`; I asked the OP to clarify if that's a possible use-case.
Comment: `shift` also fails to shift anything if there is only one argument, so the `$host` would be duplicated.
Answer: you can change your script into:
p=("$@")
curl --socks5-hostname "127.0.0.1:${p[1]-1080}" ${p[0]} "${p[@]:2}"

Comment: If you have array support, you almost certainly have the ability to slice `$@` itself without needing the array.
Answer: You can use shift to "consume" the host and optional port, so that the remaining arguments can be passed on to curl.
host=${1:-Missing host}  # Exits if *no* arguments available.
shift

if [[ $1 =~ ^[0-9]+ ]]; then
    port=$1
    shift
else
    port=1080
fi

curl --sock5-hostname "127.0.0.1:$port" "$host" "$@"


Trigonometry - Limits yet again

Question: I am having the solution, but don't know why it works:
\begin{align*} \quad \lim_{x \to 0}\frac{\tan(2x)}{x}&=
  \lim_{x \to 0}\frac{\sin(2x)}{x\cos(2x)}\\
&= \lim_{2x \to 0}\frac{\sin(2x)}{2x} \cdot \lim_{x \to 0}\frac{2}{\cos(2x)}\\
&= 1 \cdot 2\\
&=2 \end{align*}
I don't understand why I am allowed to turn \begin{align*} \lim_{x \to 0} \end{align*} into \begin{align*} \lim_{2x \to 0} \end{align*} I am learning this on my own for a entry exam for university and feel a bit lost...
Comment: Because as $x\to0$, $2x$ also tends to $0$.
Comment: Because the function $x\mapsto 2x$ is continuous (and invertible).
Answer: Ok I'm trying to justify the conversion with just logic.Suppose x is negligibly small even 2x will be negligibly small,and for that matter any nx is negligibly small where n is a natural number (unless n tends to infinity),so the conversion you stated is valid.
Answer: We can prove this works. Consider the $\delta$-$\epsilon$ definition of limit
as found, for example, at
https://www.math.ucdavis.edu/~kouba/CalcOneDIRECTORY/preciselimdirectory/PreciseLimit.html
Now suppose you have already shown that
$$\lim_{2x \to 0}\frac{\sin(2x)}{2x} = 1.$$
Then (by the definition of limit)
you know that for any positive number $\epsilon$,
there is a number $\delta$ such that
$\left|\frac{\sin(2x)}{2x} - 1\right| < \epsilon$
whenever $0 < 2x < \delta$.
But if $0 < x < \frac\delta2$, then $0 < 2x < \delta$,
so you have just proved the following statement:
For any positive number $\epsilon$,
there is a number $\frac\delta2$ such that
$\left|\frac{\sin(2x)}{2x} - 1\right| < \epsilon$
whenever $0 < x < \frac\delta2$.
But that's just what the definition of $\lim_{x \to 0}\frac{\sin(2x)}{2x} = 1$
says, except that the last paragraph says there is a number $\frac\delta2$
instead of a number $\delta$.  The definition doesn't actually "care"
how you write each number as long as you use the same value wherever the
definition uses the same value, so you have shown that
$$\lim_{x \to 0}\frac{\sin(2x)}{2x} = 1.$$
As noted in comments, you can generalize this to a limit taken as some
continuous, invertible function of $x$ goes to zero,
where the function $x\mapsto2x$
is just one example of the more general fact.
Answer: Functions $ \sin x, \tan x $ are straight for small values of $x$, they can be approximated by x as they behave like $y=x$ in the neighborhood of x=0.So,
$$ \dfrac{\sin 2 x}{x} \approx 2,\, \dfrac{\tan 3 x}{\tan 7 x} \approx \frac37  $$
A function like $$ \dfrac{\sin 3.2 x + \tan 6.8 x}{2.5 x} \approx 4.$$
Answer: $$\lim_{x \to 0}\frac{\tan(2x)}{x}=
  \lim_{x \to 0}\frac{\sin(2x)}{x\cos(2x)}$$
You have to make a change of variable. Let's say $y=2x$ or $\displaystyle x= \frac{y}{2}.$
when $x \to 0$ also $y \to 0$.
So we have the following limit:
$$\lim_{y \to 0}{\frac{\sin y}{\frac{y}{2}\cos y}}$$
$$\lim_{y \to 0}{\frac{2 \sin y}{y\cos y}}.$$
Is it OK?

Trigonometry - Limits yet again


Ordering entities based on other entity content

Question: My problem is that I don't know how to write this query.
I have a entity Conversation
   public class Conversation : Entity
    {
        protected Conversation() { }

        [Required]
        public DateTime CreationDate { get; protected set; }

        public virtual HashSet<Message> Messages { get; set; }
}

and an entity message
public class Message : Entity<long>
    {
        protected Message()
        { }

        public DateTime CreationDate { get; protected set; }

        [Required]
        public string Msg { get; protected set; }
}

I want to retrieve the conversations ordered by the most recent message written on it.
By most recent I mean the most closely written on the conversation.
Somebody can help me here?
Comment: Why are you using a `HashSet` (especially since `Message` doesn't override `Equals` or `GetHashCode` that you've shown)?
Comment: I override it on the generic implementation of the entity. But that is not my problem.
Answer: Just look at the max message creation data for each conversation:
var query = conversations.OrderByDescending(c => c.Messages.Max(m => n.CreationDate))


Proof without induction : $(n+1)! < n(1!+2!+\cdots +n!)$

Question: Prove that :
$(a)\;\; (n+1)! < n\big(1!+2!+\cdots +n!\big)$
$(b)\;\; (n+1)!>(n-1)\Big(n!+(n-1)!+\cdots \cdots +1!\Big)$ $ \forall n \geq 3$
Without using induction method
Attempt: for first part, $(n+1)!=(n+1)\cdot n\cdot (n-1)! = n\Big((n-1)!+n!\Big)$
for second part, $(n+1)!=(n+1)\cdot n\cdot (n-1)(n-2)! = (n-1)\Big((n^2+n)(n-2)!\Big)$
Could someone help me how to go further?
Thanks.
Answer: $$n(1!+2!+...+n!)=n(n-1)!\left(\frac{1}{(n-1)!}+\frac{2}{(n-1)!}+...+1+n\right)>$$
$$>n(n-1)!(n+1)=(n+1)!$$
$$(n-1)(1!+2!+...+n!)=(n-1)n!\left(\frac{1}{n!}+...+\frac{1}{n}+1\right)<$$
$$<(n-1)n!(n+1)=(n+1)!$$
Comment: @Durgesh Tiwari See now, please.
Comment: OP already solved the first part.
Comment: @ Michael Rozenberg , help me to prove for second part, thanks
Comment: thanks  Michael Rozenberg got it.
Answer: Notice that we have
$$
1+\frac1n+\overbrace{\underbrace{\frac1{n(n-1)}}_{\frac{(n-2)!}{n!}}+\underbrace{\frac1{n(n-1)(n-2)}}_{\frac{(n-3)!}{n!}}+\dots+\frac{0!}{n!}}^{\le(n-1)\cdot\frac1{n(n-1)}=\frac1n}\le\frac{n+2}n\tag1
$$
Since the last $n-1$ terms are no greater than $\frac1{n(n-1)}$, their sum is no greater than $\frac1n$. Thus, the sum of all the terms is no greater than $\frac{n+2}n$.
Therefore,
$$
\begin{align}
\sum_{k=0}^nk!
&=n!\left(1+\frac1n+\frac1{n(n-1)}+\dots+\frac{0!}{n!}\right)\tag{2a}\\
&\lt\frac{(n+1)!}{n-1}\tag{2b}
\end{align}
$$
Explanation:
$\text{(2a)}$: factor $n!$ out front
$\text{(2b)}$: apply $(1)$ and note that $\frac{n+2}n\lt\frac{n+1}{n-1}$ for $n\ge2$

$$
\begin{align}
\sum_{k=0}^n\frac{k!}{n!}
&=1+\frac1n+\overbrace{\color{#C00}{\frac1{n(n-1)}}}^{\frac{(n-2)!}{n!}}+\overbrace{\color{#090}{\frac1{n(n-1)(n-2)}}}^{\frac{(n-3)!}{n!}}+\dots+\color{#00F}{\frac{1!}{n!}+\frac{0!}{n!}}\tag{3a}\\
&\ge\left(1+\frac1n+\color{#C00}{\frac1{n^2}}+\color{#090}{\frac1{n^3}}+\dots+\color{#00F}{\frac1{n^{n-1}}+\frac1{n^n}}\right)+\left(\color{#C00}{\frac1{n(n-1)}-\frac1{n^2}}\right)\tag{3b}\\
&=\frac{n-\frac1{n^n}}{n-1}+\frac{\frac1{n^2}}{n-1}\tag{3c}\\[6pt]
&\ge\frac{n}{n-1}\tag{3d}
\end{align}
$$
Explanation:
$\text{(3a)}$: expand the sum
$\text{(3b)}$: split apart the $k=2$ term (in red)
$\phantom{\text{(3b):}}$ use $\frac{(n-k)!}{n!}\ge\frac1{n^k}$ for the rest
$\text{(3c)}$: use the sum of a geometric series
$\text{(3d)}$: $n\ge2$
$$
\begin{align}
\sum_{k=1}^n\frac{k!}{n!}
&=1+\frac1n+\color{#C00}{\frac1{n(n-1)}}+\color{#090}{\frac1{n(n-1)(n-2)}}+\dots+\color{#00F}{\frac{1!}{n!}}\tag{4a}\\
&\ge\left(1+\frac1n+\color{#C00}{\frac1{n^2}}+\color{#090}{\frac1{n^3}}+\dots+\color{#00F}{\frac1{n^{n-1}}}\right)+\left(\color{#C00}{\frac1{n(n-1)}-\frac1{n^2}}\right)\tag{4b}\\
&=\frac{n-\frac1{n^{n-1}}}{n-1}+\frac{\frac1{n^2}}{n-1}\tag{4c}\\[6pt]
&\ge\frac{n}{n-1}\tag{4d}
\end{align}
$$
Explanation:
$\text{(4a)}$: expand the sum
$\text{(4b)}$: split apart the $k=2$ term (in red)
$\phantom{\text{(3b):}}$ use $\frac{(n-k)!}{n!}\ge\frac1{n^k}$ for the rest
$\text{(4c)}$: use the sum of a geometric series
$\text{(4d)}$: $n\ge3$
Therefore, for $n\ge2$, $(3)$ says
$$
\sum_{k=0}^nk!\ge\frac{n\,n!}{n-1}\tag5
$$
and for $n\ge3$, $(4)$ says
$$
\sum_{k=1}^nk!\ge\frac{n\,n!}{n-1}\tag6
$$


Get last 3 months data with case statement

Question: I would like to create a derived column by using a case statement or any other better suggestions.
My ask needs to set a flag if the sale has started in the last 3 months as New Sale and also exclude forward order book sale eg: sales done to start in the future.
I have the below script but complete yet.
SELECT
 SaleID,
 SaleStartDate,
 [Is New Move-In] =
CASE WHEN SaleStartDate >= DATEADD(MONTH, -3, GETDATE())  THEN 'Yes'
            ELSE 'No'END
FROM [dbo].[Sale]

This is giving me the last 3 months but also sales in the future also which are not needed.
Comment: What's your dbms? could you provide some sample data and expect result?
Comment: `... WHERE SaleStartDate <= GETDATE()` ?
Comment: What is a *flange*?
Answer: SELECT
 SaleID,
 SaleStartDate,
 [Is New Move-In] =
CASE WHEN SaleStartDate >= DATEADD(MONTH, -3, GETDATE()) AND SaleStartDate < GETDATE()
     THEN 'Yes'
     ELSE 'No'
     END
FROM [dbo].[Sale]


how to find out root password

Question: I just installed ubuntu desktop 13.04
I need the root access and need to know the root password
During installation, I left it blank.
How can find out my root password ?
Thanks.
somner
Comment: @Radu Nope, not a duplicate. While the title might be misleading, the OP never actually set one.
Comment: @IanCarroll I said possible, I didn't decided that is it :)
Comment: @IanCarroll the answer on the duplicate is still 100% accurate, because that answer will answer here.  If they need root, they can use `sudo` to run commands as superuser, when using the user that was configured at installation time.  The duplicate status is accurate and correct as a result.
Comment: Ok, fair enough.
Answer: Simple answer : You can't find the root password, If you could it would break the security model.
Also, by default root does not have a password which prevents you from logging in as root.
If you want to enable root login see this post.
How to enable root login? However its not recommended see here
If you have lost the password of all Administrative users see this post on how to fix:
How do I reset a lost administrative password?
Another option is sudo -i with your password which runs a session as root
Also take a look here RootSudo
Answer: Root login is disabled by default in ubuntu. You can switch to root with
sudo bash

and then give it your personal password.
Comment: sudo bash gives you a new shell and therefore a new command history - keeping my normal work separate from those run as "root". If the user had enabled the root account AND changed the shell being used by root then it's unlikely they would be asking this question. As is often the case, mileage may vary but sudo bash would provide root access as well as allowing the user to enable and set a password for the real root user.
Comment: -1, this is a bad practice. What if the user uses a different shell? Or, what if root uses a different shell than the user? It's neither uncommon nor a bad idea. `sudo su`, as mentioned by @StackExchange User, or `sudo -s` are much better alternatives. (thank you for coming to my ted talk).
Comment: Fair enough. You provide some good points, so to each their own!
Answer: While the answer given by A J is technically correct, you should use sudo su to switch to the root user. If for some reason you must use his answer, please do sudo bash --login
Comment: Why? I need some arguments.
Comment: `--login` will present you with a login-type shell instead of something simulated.

how to find out root password


What is the most effective way to kill my wife?

Question: I don't like my current wife so I need to get rid of her. What would be the most effective way to replace her? What other ways are there?
Comment: Wow that title. Lucky I didn't find this on the parenting SA site^^
Comment: Better call Saul :)
Comment: And a big hello to our friends at the FBI.
Comment: I guess I should emphasize that **this is for a strategy game**, where killing your kin is a way to survive.
Comment: NSA spider bot inc.
Comment: @ventic, so jst like in real life?
Comment: Oh boy, now I really need to get this game.
Comment: If you find out, let me know. I'm always looking for a better way!!!
Answer: There are three main ways to get rid of your wife:

Assassinate her. If this fails, your wife may be lethally annoyed at you.
Start a plot against her, from the Intrigue screen. This plot will always be available when you are married. Again, if your wife finds out (due to one of your fellow plotters spilling the beans), your wife may let her displeasure be known in similarly-lethal ways.
If you're Catholic, you can ask the Pope for a divorce. It costs 50 piety, and you'll need the Pope to like you, but otherwise it has no drawbacks; you can re-marry immediately after a divorce.


Can I just paint over my existing vinyl wrapped MDF kitchen cabinets?

Question: My kitchen cabinets (doors and sides of pantry) have a dated vinyl finish. I'd like just plain matte white cabinets and have been looking online but white vinyl wrapped ones seem to be around $50 per door.
Considering the vinyl is in reasonable condition, would there be any issue if I just painted the existing cabinets, vinyl and all, with white paint and a roller (or even spray paint)?
Answer: Realistically, no if the vinyl has held up well so far, but it also shouldn't be too much work to peel off the vinyl to prep for refinishing. That said, depending on the cabinets, you could have particle board or MDF underneath, which you wouldn't want directly exposed for painting due to porosity. In that case, lightly scuffing the vinyl with any abrasive, priming, then painting should suffice to give a good coating.
The only real concern I know of with painting over vinyl is the potential for bubbling or warping issues with the vinyl transferring through the painted surface. Like I said, though, if the vinyl has held up well for a good amount of time, I can't foresee any of those issues happening easily.
Comment: There are vinyl paints that would be better than trying to remove the vinyl.
Answer: I'll venture a couple of hints without having seen the cabinets. First of all you'll need to degrease them with a good washing. Even though they're in the pantry and not the kitchen you want to minimize surprises later. I'd also consider abrading the vinyl by running a fine sandpaper over it; The small scratches will give better adhesion while being invisible under the paint.
Primer is mandatory with a questionable surface. Primers have a higher concentration of resins, hence better adhesion than paints. I'd shy away from anything purporting to be paint+primer in one can though. Ditto for the "house brand" primers in hardware stores, get one you know will adhere to plastic.
If appearance is especially important your best bet is a paint store, which generally features better advice and products than hardware stores. Make sure you tell them you're painting over vinyl so you get the correct primer.
If cost is paramount, it's off to the hardware store. I know Rustoleum markets a bunch of specialty coverings, notably XIM high-adhesion primers. (Including a "bonder" intended for plastic.) I'd try a coat of that or the local equivalent under the paint of your choice.


Recursive definition of $\mathcal{L}$-terms in model theory

Question: Let $\mathcal{L}$ be a language. In David Marker's Model Theory: An Introduction, the set of $\mathcal{L}$-terms is defined to be the smallest set $\mathcal{T}$ containing all of the constant symbols of $\mathcal{L}$, the variable symbols $v_1$, $v_2$,... and such that for each function symbol $f$ (in $\mathcal{L}$) and $t_1,...,t_{n_f}∈\mathcal{T}$ (where $n_f$ is the positive integer associated to $f$), we must have that $f(t_1,...,t_{n_f})∈\mathcal{T}$.
Usually when one enlarges a set by including more and more points until it is in some way 'complete', it is contained in some larger set (e.g. smallest topology containing a given collection of subsets), which ensures that there are no weird 'Russell's Paradox' type issues, such as the final construction being a proper class, rather than a set.
But here there is no suggestion of any larger set. I can see that it follows by induction that any string that can be obtained by a finite number of applications of function symbols to the constant and variable symbols must be a set. Must these strings, by definition, only involve a finite nesting of function symbols i.e. $(v_1\cdot v_2)\cdot v_3$ or can it contain infinite ones such as $(((v_1\cdot v_2)\cdot v_3)\cdot v_4\cdot....))))$?
Many thanks
Comment: But of course there is a larger set: $\mathcal{L}^{<\omega}$, the set of all finite sequences ("strings") of the language's symbols.
Comment: Such an infinite string is not in the *least* set containing the initial terms and closed under forming terms with function symbols. You can omit it from a set and the remaining members will still have the required closure.
Another way to proceed is to define this set recursively "from below", in $\omega$ stages, then show that the union of those stages is in fact the smallest set satisfying the conditions.
Comment: @thewonderfulwizardofoz Read Atticus's second-to-last comment.
Comment: @BrianO How can you rule out the possibility of there being an infinite nesting e.g. $(((v_1\cdot v_2)\cdot v_3)\cdot v_4 .....))))$? That would not be a finite string.
Comment: @Atticus Stonestrom I thought the variable symbols were not 'symbols of $\mathcal{L}$', they are independent of the language $\mathcal{L}$? In which case, $X$ does not satisfy $P$.
Comment: Does [this old answer of mine](https://math.stackexchange.com/a/3035858/28111) address your question?
Answer: Upgrading my comments to an answer. I agree that Marker's definition appears slightly vague at first glance; what does the "smallest set" with that property mean? Let me flesh out this kind of construction a bit more generally. Given some property $P$, we often want to construct a set $\mathcal{T}$ that is the "smallest" set satisfying $P$. We mean by this that we want the following two things to hold:

$\mathcal{T}$ satisfies $P$.
If $Y$ is any set satisfying $P$, then $\mathcal{T}\subseteq Y$.

Note that such a set is necessarily unique; indeed, suppose $\mathcal{T}'$ is another set satisfying both of these conditions. Since $\mathcal{T}$ satisfies condition $2$ and $\mathcal{T}'$ satisfies condition $1$, we have $\mathcal{T}\subseteq\mathcal{T}'$, and since $\mathcal{T}'$ satisfies condition $2$ and $\mathcal{T}$ satisfies condition $1$, we have $\mathcal{T}'\subseteq\mathcal{T}$. In other words, $\mathcal{T}=\mathcal{T}'$ as claimed.
Now, how do we actually "construct" this set $\mathcal{T}$? The idea is to take $\mathcal{T}$ to be the intersection of all sets satisfying property $P$. Now, this is not necessarily well-defined; for instance, if there does not exist a set satisfying $P$, then we cannot do this, since the intersection of the empty set is not defined. (Why not?) So we need for there to exist at least one set satisfying $P$; in practice, there is often a somewhat "natural" choice for this. Suppose for the purpose of the discussion that we have a set $X$ in mind that satisfies property $P$. By condition $2$ above, our desired set $\mathcal{T}$ will necessarily be a subset of $X$. So, in order to construct $\mathcal{T}$, it suffices to think exclusively about subsets of $X$. In particular, we can define $\mathcal{T}$ as the intersection of all subsets of $X$ that satisfy property $P$.
Now, does $\mathcal{T}$ satisfy condition $1$? Unfortunately, not necessarily; for instance, if $P$ is the property of being non-empty, then the intersection of all subsets of (say) $\mathbb{N}$ satisfying $P$ will itself be empty and hence not satisfy $P$. There is an implicit assumption lurking in the background; namely, that $P$ is stable under intersections. In other words, if $(A_i)_{i\in I}$ is a family of sets satisfying $P$, then $\bigcap_{i\in I}A_i$ also satisfies $P$. So, suppose $P$ is stable under intersections. Then we immediately have that $\mathcal{T}$ satisfies property $P$, since by definition it is an intersection of sets satisfying $P$! So we're done with condition $1$.
Does $\mathcal{T}$ also satisfy condition $2$? Indeed; let $Y$ be any set satisfying $P$. Then $Y\cap X$ satisfies $P$, since $P$ is stable under intersections, and $Y\cap X$ is a subset of $X$. Thus, by definition – since $\mathcal{T}$ is the intersection of all subsets of $X$ satisfying $P$ – we have $\mathcal{T}\subseteq Y\cap X$ and hence $\mathcal{T}\subseteq Y$, as desired. So we are done!

Now let's specialize to the example of Marker. In this case, $P$ is defined by taking $Y$ to satisfy $P$ if and only if $(1)$ $v_i\in Y$ for each $i$, $(2)$ $c\in Y$ for each constant symbol $c\in\mathcal{L}$, and $(2)$ $f(t_1,\dots,t_{n_f})\in Y$ for each function symbol $f\in\mathcal{L}$ and all elements $t_i\in Y$.
Exercise: Show that $P$ is stable under intersections, in the sense defined above. $\blacksquare$
Now, to define $\mathcal{T}$ by the process above, we first need to find some set $X$ satisfying $P$. First define $\mathcal{L}'$ to be the union of $\mathcal{L}$ with the set of variables symbols and the symbols "$($", "$)$", and "$,$". Now let $X$ be the set of all finite strings (ie finite sequences) of symbols of $\mathcal{L}'$.
Exercise: Show that $X$ satisfies property $P$. $\blacksquare$
Once you have shown these two exercises, you are done! Since we can now define $\mathcal{T}$ to be the intersection of all subsets of $X$ that satisfy property $P$. In particular however, note that $\mathcal{T}\subseteq X$. Thus every element of $\mathcal{T}$ is a finite string of symbols of $\mathcal{L}'$, and so, to answer your question – no, there are no elements of $\mathcal{T}$ with infinite nesting as you describe.
Comment: Thanks for this. I assume you meant to write $\mathcal{T}\subseteq Y$ at the end of condition 2 at the top? Also for the specific property $P$ you define below the horizontal line, it must contain all of the constant symbols too to satisfy the definition of the set of $\mathcal{L}$-terms.
Comment: dear @thewonderfulwizardofoz yes, you are absolutely right on both counts! I have corrected :)


$\lim_{t \rightarrow \infty}V(\mathbf{x}(t)) = 0$ implies $\lim_{t\rightarrow \infty} \mathbf{x}(t) = \mathbf{0}$

Question: (* Note: Originally $D \subseteq \mathbb{R}^n$ is only open, boundedness is added through later discussion. Further discussion changes $D$ to be compact.)
$D \subseteq \mathbb{R}^n$ is compact. Let $\mathbf{x}:[0, \infty) \rightarrow D \subseteq \mathbb{R}^n$ be continuous, let $V:D \rightarrow \mathbb{R}$ be continuous.
Suppose $V(\mathbf{x}) = 0$ if and only if $\mathbf{x} = \mathbf{0}$, then $\lim_{t \rightarrow \infty}V(\mathbf{x}(t)) = 0$ implies $\lim_{t\rightarrow \infty} \mathbf{x}(t) = \mathbf{0}$.
I think this statement holds true to me intuitively, but I am having trouble rigorously show it using $\epsilon-\delta$ definition of continuity. Any help would be much appreciated.
Comment: Is $D$ compact? (I can't see any other way to save it)
Comment: I just did what you suggested. Hope that would make the statement a bit more clear to newcomers.
Answer: If $\lim_{t\to\infty} \mathbf{x}(t)\neq 0$, then there exists $\varepsilon>0$ and sequence $(t_n)_n\subset[0,\infty)$ with $t_n\to\infty$ such that $\lVert\mathbf{x}(t_n)\rVert\geq\varepsilon$. If $D$ is compact (as Brian Moehring suggests) then the sequence $(\mathbf{x}(t_n))_n$ is bounded, hence it has a convergent subsequence $\mathbf{x}(t_{n_k})\to x\in D$, and $x\neq 0$ by the above fact ($\lVert\mathbf{x}(t_n)\rVert\geq\varepsilon$). Therefore, by continuity of $V$, we have that $V(\mathbf{x}(t_{n_k}))\to V(x)\neq 0$ as $k\to\infty$, which contradicts the fact that $V(\mathbf{x}(t))\to 0$ as $t\to\infty$.
However, if $D$ is not compact, the result you mention does not hold anymore. Take the following example: let $V$ be a continuous function defined on $D=\mathbb{R}^n$, only vanishing at $0$, with $\lim_{\lVert{\mathbf{x}}\rVert\to\infty}V(\mathbf{x})=0$. Take $\mathbf{x}(t)=(t,0,\ldots,0)$. We have that $\lim_{t\to\infty}\mathbf{x}(t)\neq 0$, but $\lim_{t\to\infty}V(\mathbf{x}(t))=0$.
Comment: Is compactness a must-have? In the answer, you used boundedness of $D$ to show the sequence $(\mathbf{x}(t_n))_n$ is bounded. Then I believe you used Bolzano-Weierstrass Theorem to show the existence of a convergent subsequence $(\mathbf{x}(t_{n_k}))_k$? I think only bounedness of $D$ is utilized here.
Comment: @DerekPan Now that I read the question again, I see that $V$ is defined on D. Note that it was key that $x\in D$ in my argument. If $D$ is not compact (even if it is bounded but not closed), it could happen that $V(\mathbf{x})\to 0$ as $\mathbf{x}\to x\notin D$ and $V$ still vanish only at $0$. In this case, we could take $\mathbf{x}(t)\to x$ as $t\to\infty$ and hence $V(\mathbf{x}(t))\to 0$.
Comment: So closeness of $D$ is needed to make sure the limit value $\mathbf{x}$ stays within $D$. Otherwise, $V(\mathbf{x})$ would be meaningless, since $\mathbf{x}$ could be out of domain? If I understood correctly, I think it makes sense. So after all, $D$ still needs to be compact.
Comment: I agree. Again, thank you for the help and the careful observation. I appreciate it a lot.
Comment: @DerekPan Yes. There is *little* way out.


What is the correct way to add roles to existing users with Firebase authentication?

Question: I am adding admin and user roles to an existing Firebase application that already has users with authentication.
In the Authentication section there is no way to add custom roles to an existing user. The custom roles documentation states that modifying realtime database rules is the way forward, but to my knowledge I am not using realtime db.
What is the correct way to assign custom roles to existing application users?
Answer: Firebase Authentication only handles authentication, so letting the user prove that they are who they say they are. On its own it has no component that does authorization, so nothing about providing access to resources to users.
Authorization is left to the back-end services that use the information from Firebase Authentication, like in the example that you gave Firebase's own Realtime Database. If you're not using the Realtime Database, then indeed that example is not relevant to you.

The correct way to implement authorization depends on the backend service you use.
For Firebase's Realtime Database, Cloud Storage, and Cloud Firestore, the authorization is handled through the server-side security rules of those products as documented here.
If you're using Cloud Functions for your back-end, you can get the current user from the context for Callable functions and Realtime Database functions, or pass the ID token along yourself and decode/verify that for other types.
If you're using a custom backend, you'd do the same as for non-callable Cloud Functions:

Pass the ID token from your client to the custom backend over a secure connection.
Decode and verify the ID token, and determine whether the user has permission based on that.

In many of these cases, it's up to you yourself to determine how you model authorization. The two most common options for this are:

Set custom claims in the ID token itself, that are then passed along with every request.
Store the authorization information in some external data source (like the Realtime Database or Cloud Firestore), and read it from there based on the UID when needed.

Both of these are valid approaches, and neither of them is pertinently better than the other. I typically tend to use custom claims for values that don't change after they're set (i.e. marking a user as an admin), and the database for most other types (i.e. a subscription status).
Comment: Thank you for the detailed explanation, that has cleared it all up for me.


Landscape "System error" when Monitoring multiple Computers

Question: I'm using Landscape 15.11 on Ubutntu server 14.04. The server has 4 Computers registered with it, including itself.  When I use the web UI to look at a single computer, I can click Monitoring and get graphs for that computer.  However, if i select more than one computer (the check boxes shown after clicking Computers), then click Monitoring (or Activities, or Hardware or anything along the top menu) , I get  an error screen like this:

System error An unexpected error has occurred. This event has been
  logged.
We apologize for the inconvenience. Please contact Canonical Support
  for further assistance.
OOPS ID: OOPS-22c10b9e67a3ae11c623ed9032527627

If I look at /var/log/landscape-server/async-frontend.log, I see initial 200 responses for the initial POST request followed by a delayed 408 response like the below.  Any clues at how to make the front end work as expected?
<code>Mar 22 16:58:55 async-frontend-1 INFO  Consuming from queue '1bfc9353-b321-405b-be75-a261b8bf8598'

Mar 22 16:58:55 async-frontend-1 INFO  127.0.0.1 - - [22/Mar/2016:23:58:54 +0000] "POST / HTTP/1.1" 200 153 "https://bot17/account/standalone/computers" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36"

Mar 22 16:58:55 async-frontend-1 INFO  Consuming from queue '1bfc9353-b321-405b-be75-a261b8bf8598'

Mar 22 16:58:57 async-frontend-1 INFO  Consuming from queue '78ec127d-1173-4ba4-948b-644bfa55dd01'

Mar 22 16:58:57 async-frontend-1 INFO  127.0.0.1 - - [22/Mar/2016:23:58:56 +0000] "POST / HTTP/1.1" 200 153 "https://bot17/account/standalone/computers/update" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36"

Mar 22 16:58:57 async-frontend-1 INFO  Consuming from queue '78ec127d-1173-4ba4-948b-644bfa55dd01'

Mar 22 16:59:01 async-frontend-1 INFO  Consuming from queue '9c213177-9fa5-4984-8ae5-9559da35f5b4'

Mar 22 16:59:01 async-frontend-1 INFO  127.0.0.1 - - [22/Mar/2016:23:59:00 +0000] "POST / HTTP/1.1" 200 153 "https://bot17/account/standalone/computers" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36"

Mar 22 16:59:01 async-frontend-1 INFO  Consuming from queue '9c213177-9fa5-4984-8ae5-9559da35f5b4'

Mar 22 16:59:02 async-frontend-1 INFO  127.0.0.1 - - [22/Mar/2016:23:59:02 +0000] "POST / HTTP/1.1" 408 - "https://bot17/account/standalone/computers" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36"

Mar 22 16:59:08 async-frontend-1 INFO  127.0.0.1 - - [22/Mar/2016:23:59:07 +0000] "POST / HTTP/1.1" 408 - "https://bot17/account/standalone/computers/update" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36"
</code>
Comment: Can you paste appserver.log using http://paste.ubuntu.com and share the link?
Comment: Thanks @AdamCollard.  Here's the log paste: http://paste.ubuntu.com/15492829/
Comment: I'm afraid that doesn't cover the time you hit the issue, please look through the rotated logs and find one which covers the time you had the problem (or reproduce the issue again)
Comment: Here's another paste.  I re-created the problem twice in a row just before pasting, so the end (~line 389) onward should be what's helpful.
http://paste.ubuntu.com/15560696/
Comment: Hi @AdamCollard, just checking back in to see if the new paste above provides the info you needed?  Thanks for your help on this.
Answer: I was having the same issue with 16.03 and this solved it:
Landscape - Script error
It appears to be a bug where if the capitalization of the server name in the browser and configurations don't match with an error like yours:
Untrusted redirect to host ':443' not allowed.
Comment: thanks!  i've stopped using landscape since posting the problem, but I'll mark your comment as the answer because that makes sense give my hostnames.


Android Datepicker maxDate one week from today

Question: I am implementing DatePicker embedded on my activity. User must select one date between actual date until 7 days later.
I've built-in a DatePicker from Eclipse IDE by drag-and-drop feature on my activity and it already shows the datePicker on activity. However, I'm failing to accomplish one-week-from-now maxDate. Can anyone explain me? I've tried to fix MaxDate on XML file to 7, or Date().getTime() + 7 but without success.
Below, see left screen as what I want to reach and on right what I have:
Answer: What about...
Date().getTime() + 604800000

After all, 604800000 is 7 * 1000 * 60 * 60 * 24 (7 => seconds => minutes => hours => days OR, to be less talky, 7 days expressed in milliseconds)
Answer: The setMaxDate() method takes in a long. As per the documentation, that long is the milliseconds since January 1, 1970 00:00:00. Thus Date().getTime() + 7 will set the maximum date as 7 milliseconds from now.
Similarly, "7" is not valid for the maxDate XML attribute. This attribute takes in the maximum date in "mm/dd/yyyy" format.
Since you want the date to be 7 days from now, I'd recommend removing the XML attribute and sticking with setMaxDate(). You just need to correctly calculate the maximum date as a long.


Check if input value is not the same onBlur

Question: How can I check if the value of an input box is not the same after blur?
$("#username").on('blur', function() {
  $("#usertext").append("new input
");
})

Check this jsFiddle: https://jsfiddle.net/xztptsdg/
Let's think that I enter "Josh" in input and after blur, will append new input box. But, user can "re-blur" the username input, and will append other input.
I want to check if the value is the same, not append new input.
Answer: You may use change instead of blur, for example:
$("#username").on('change', function() {
    $("#usertext").append("new input
");
});

So, there is no need to check if the value changed or not because the change event is sent to an element when its value changes.
Answer: See this fiddle
You can keep a global variable to store the current value of the textbox and then check whether the entered value is the same as the previous one. If not, then append the new input text and also set the global variable with the new one. Below is the Javascript that does this.
JS
var txt = "";
$("#username").on('blur', function() {
  if (txt != this.value) {
    $("#usertext").append("new input
");
    txt = this.value;
  }
})

I would suggest you to use change(). According to the docs

The change event is sent to an element when its value changes.

See the fiddle and below is the JS code with change().
$("#username").change(function() {
    $("#usertext").append("new input
");
});

Answer: You can do it like following snippet.

var text = '';
$("#username").on('blur', function() {
  if(this.value != text){
    text = this.value;
    $("#usertext").append('new input
');
  }
});

<input type="text" name="username" id="username">


Js compress by uglify-js give error Unexpected token: name ($)

Question: I am compress my js files by uglify-js
   I want to compress Bootstrap 4 js file but it give me Error like this.
   Can I compress all js files by only uglify-js Or how can i do it.
    Parse error at src\bootstrap\alert.js:1,7
    import $ from 'jquery'
           ^
    ERROR: Unexpected token: name ($)

my package.json
"devDependencies": {
    "node-sass": "^4.6.1",
    "nodemon": "^1.12.1"
  },
  "dependencies": {
    "autoprefixer": "^7.1.6",
    "jquery": "^3.2.1",
    "postcss-cli": "^4.1.1",
    "uglify-js": "^3.1.9"
  }

Comment: try `import * as $ from 'jquery';`
Comment: @GrégoryNEUT it's not working it same error
Answer: Try using the ES6 version of uglify-js. Replace with this in your package.json
"uglify-js": "git+https://github.com/mishoo/UglifyJS2.git#harmony"
or via command line:
npm install --save uglify-js@github:mishoo/UglifyJS2#harmony
Comment: After install `uglify-js2` I am getting this error
 `throw new JS_Parse_Error(message, line, col, pos);`
Comment: You don't want `uglify-js2`
Answer: uglify-js does not support ES2015 syntax like import statements or arrow functions. Instead, use the uglify-es module:
-    "uglify-js": "^3.1.9"
+    "uglify-es": "^3.1.9"

Comment: It's give me another error `const Modal = (() => {`

`ERROR: Modal redeclared`


Continuous function approximation on manifolds

Question: I am asked to show that every cont. function from a manifold M to $\mathbb{R}$ can be approximated by smooth functions.
Try: let f be a map from M to the reals(R). Let ${s_{i}, U_{i}}$ be our atlas. Then $f(p)$ can be rewritten as $fs_{i}^{-1}$ at $s_{i}(p)$. Now, since $f$ is cont. and $s_{i}$ is a chart, their composition is cont. Now, we have $f$ represented by all these cont. maps according to the appropriate charts. But notice that $fs_{i}^{-1}$ is a map from the reals to the reals, and hence we invoke the Wierstrass approximation theorem and say there exists a polynomial $P(x)_{i}$, such that the supremum of the distance between $P(x)_{i}$ and $fs_{i}^{-1}$ is less than arbitrary $\epsilon_{i}.$
Hence, a candidate for the desired function is $\{P(x)_{i} : x = s_{i}(p)\}$. I hope this makes, its the collection of all these approximating polynomials, in accordance with the charts. Now the issue is showing that this map is smooth. I am assuming the coordinate transformations are supposed to come in here, but i am at a loss.
Thanks in advance.
Comment: In what sense do you need to approximate? (e.g. locally uniformly?) Approximating on a collection of charts is a good idea; but you will need to choose a subcollection of charts and use a partition of unity. Also, you said you have a function on the reals, when in fact it is on $\mathbb R^n$ - does your version of the Weierstrass theorem apply to this case?
Comment: doesn't necessarily need to be locally uniform. The only requirement is that its smooth.
Comment: oh yes, this version of Weierstrass theorem does apply. Could you elaborate on the need for the bump functions and taking a sub collection of charts please
Comment: but you need to define what you mean by "approximate" - what disqualifies the zero function from "approximating" your continuous function? Usually an approximation by smooth functions means you can find smooth functions that converge to your target function - you need to specify the norm/mode of convergence.
Comment: supremum|f(x)-P(x)| < $\epsilon$ for all x on the manifold.
Answer: Let $(U_i, s_i)$ be an atlas and $\eta_i$ a smooth partition of unity subordinate to $U_i$: this means

each $\eta_i$ is zero outside $U_i$
each $x\in M$ has a neighbourhood on which all but finitely many $\eta_i$ are zero
$\sum_i \eta_i(x) = 1$ for every $x$.

Now, on each $U_i$ we can approximate in the chart as you suggested - let $p_i$ be a smooth function on $s_i(U_i)$ approximating $f \circ s_i^{-1}$ to within $\epsilon$. We can use $\eta_i$ to patch all of these local approximations together into a global approximation: define $$ \tilde f (x) = \sum_i p_i (s_i(x))\eta_i(x).$$
This is smooth because it is locally the finite sum of smooth functions - if you fix an $x\in M$ and look at $\tilde f$ on the nice neighbourhood provided by the partition of unity, then there are only finitely many non-zero terms in the sum, and each is the product of a smooth function $p_i \circ s_i$ with a smooth function $\eta_i$.
As to the approximation, we have
$$\begin{align}
|f(x) - \tilde f(x)| &= \left|\sum_i \eta_i(x)\left(f(x) - p_i(s_i(x))\right)\right|\\
&\le \sum_i \eta_i(x) \left| f(x) - p_i(s_i(x))\right|
\end{align}$$ where we used $\sum_i \eta_i = 1$ to move $f$ inside the sum. Now, the uniform approximation $|f \circ s_i^{-1} - p_i| < \epsilon$ on the image of the chart $s_i$ means that $|f(x) - p_i(s_i(x))| < \epsilon$ for every $x \in U_i$, and thus we have the bound $$|f(x) - \tilde f(x)| < \sum_i \eta_i(x) \epsilon = \epsilon.$$
Comment: @sergey: Note that the "subcollection of charts" I referred to before is in a sense implicitly contained in the local finiteness condition on the $\eta_i$ - if you use a complete atlas then a vast majority of the $\eta_i$ will in fact be zero.


Incorrect keypresses on Lenovo y560p

Question: Most of the keys on my Lenovo y560p work fine usually but sometimes some of them will register incorrect keypresses.
For example, the u key will register as "volume up", the n will be "ESC".  But most of the others will be fine.  USB keyboards work fine.  Seems to happen intermittently.
Laptop: Lenovo y560p
Ubuntu: 10.04 LTS
Answer: You might have one of two issues:
Either a hardware issue and your laptop is having problems with the cable or circuit related to the keyboard or a misconfiguration of the keyboard layout when Ubuntu was installed or after it was installed.
Answer: Turns out it was a hardware issue, as I installed Windows 7 and the same keyboard issues appeared.
Was covered by Lenovo warranty. They exchanged it.
Answer: The problem actually is the keyboard ribbon that plugs into the motherboard.  Same issue happened to me.  The ribbon rubs on a sharp edge on a heat sink, eventually grounding out after some time.
Solution:  I used a small strip of electrical tape to insulate the ribbon where the heat sink rubbed it and exposed the small conductive material inside.  I haven't had an issue since.
The heat sink is a bad design flaw that Lenovo should fix!

Incorrect keypresses on Lenovo y560p