D8- replacing hook_boot() : using an Event Subscriber vs settings.php

OK, I’m trying the best way to handle this:

On a Drupal 7 site I had a poor man’s URL shorter. I create a slug by encoding a node’s NID using an algorithm that wouldn’t contain a vowel. In hook_boot I’d test to see if there was a vowel and in the URL’s path. If there wasn’t I’d decode the slug and redirect to /node/nid otherwise Drupal would continue doing its thing. Since all the content is in English any aliases would contain vowels so I was OK. It worked well and would redirect before Drupal fully bootstrapped, saving some cycles.

I’m thinking about porting this to Drupal 8. I’ve been debating between building a module with an event subscriber and just putting the code at the top of settings.php. Any thoughts or advice?

Replacing the initial conditions for a PDE

The problem

The PDE I am working with is given by $ \left(\partial_a^b \leftrightarrow\frac{\partial^b}{\partial a^b}\right)$

$ $ \partial_t \psi = i \partial_x^2 \psi$ $ $ $ \psi(x,t=0) = \psi_0(x)$ $ $ $ \psi:\mathbb{R}^2\rightarrow \mathbb{C}$ $

Let $ F:\mathbb{R}^2 \rightarrow \mathbb{R}_{\ge 0}$ be a function such that for a solution $ \psi$ of the above mentioned PDE, then $ F=|\psi|^2$ . The solutions $ \psi$ that interest me have to be square-integrable.

At this point I am interested in computing $ \psi$ for a known $ F$ , which from my point of view, should be equivalent to replacing the initial condition $ \psi_0$ with the now known function $ F$ .

I have not been able to prove this, but I consider this approach to not hold on for a general case, in the sense that there might not be solutions of the PDE that are compatible with the choice of $ F$ . This is why I have changed the condition. However this is only an assumption, so if I can be proven wrong it’ll be great.

The second attempt is as follows. For a solution $ \psi$ of the PDE consider the curves given by $ |\psi|^2 = a$ , where $ a \in [0,\max(|\psi|^2)]$ is a constant. I label this curves as $ \Gamma(s)=\left(g(s), h(s)\right)$ where $ g,h:\mathbb{R} \rightarrow \mathbb{R}$ . Since $ |\psi|^2$ is constant on a curve $ \Gamma$ , then it is true that

$ $ \nabla_{x,t}|\psi|^2 \perp T_{\Gamma}$ $

where $ \nabla_{x,t}|\psi|^2=\left( \partial_x |\psi|^2, \partial_t |\psi|^2\right)$ and $ T_{\Gamma}(s)=\left(\partial_s g, \partial_s h\right)$ is the tangent of the curve $ \Gamma$ .

This condition becomes

$ $ \nabla_{x,t}|\psi|^2 \cdot T_{\Gamma}=0$ $

or explicit

$ $ \partial_s g \cdot \partial_x |\psi|^2 + \partial_s h \cdot \partial_t |\psi|^2 = 0.$ $

This is a transport equation which defines, by the choice on $ g$ and $ h$ the curves on which $ |\psi|^2$ is constant, independent of the actual value of $ |\psi|^2$ on that curve. Unlike the first attempt where I enforce $ F$ and then look for the solution (if possible), here I enforce the curves on which the solution has the same amplitude. This should not be as restrictive as the first approach, but it might also be too little to allow for computing $ \psi$ .


For the eventual questions about why do I want to formulate the problem in such a manner, or what is the purpose of it, I will try to give some pre-emptive answers.

There is a solution for this PDE, which although not square-integrable, satisfies the condition $ F(x,t) = F(x-t^2)$ . More about this here. Following this result, square-integrable versions of this solution have been developed that qualitatively satisfy the same condition, but only for $ t<t_{max}\in \mathbb{R}$ .

These results do not give an algorithm for generating solutions that have a particular behavior, it is more of a guessing game, where one pluggs an initial condition in the PDE and then hopes to get an oddly interesting solution. This is the reason why I want to replace the initial condition with something similar to what I have presented above.

My attempts

Following the article I have mentioned in the Context section, the choice I made for $ g$ and $ h$ has been

$ $ g(s) = x_0 + \frac{s^n}{n!}$ $ $ $ h(s) = s$ $

where $ n\in \mathbb{N}$ . For $ n = 2$ a rescaled solution similar to the the one in the article should be obtained. Because of the choice on $ g$ and $ h$ , I can replace $ s$ with $ t$ . The condition becomes

$ $ t \partial_x F + \partial_t F = 0$ $

At this point I considered writing $ g$ as

$ $ g(t) = \sum_{n=0}^{\infty} \frac{t^n}{n!} \partial_t^n g(t=0)$ $

I know the values of $ \partial_t^n g(t=0), \forall n \in \mathbb{N}$ since I chose $ g(t) = x_0 + t^2/2$ , so I can derivate the condition with respect to $ t$ in order to get to each $ \partial_t^n g(t=0)$ term after I evaluate the expresion at $ t=0$ .

By evaluating the condition as it is, it gives

$ $ \partial_t|\psi(x,t =0)|^2 = 0$ $

Derivating once and evaluating it gives

$ $ \partial_x|\psi|^2(x, t=0) + \partial_t^2 |\psi(x,t=0)|=0$ $


$ $ \partial_t^n |\psi|^2(x,t=0) = 0, \forall n>2.$ $

These conditions, I thought, could be used in order to compute an initial condition. Since there are an infinite number of such conditions, I thought that in the worst case scenario, if this approach works, I should be able to use a finite number of them in order to get an approximate initial condition that satisfies qualitatively the condition I emposed by choosing $ g$ and $ h$ . As it turns out, the computation is not as simple as would have hoped, since the evaluation of the temporal derivatives can only make use of

$ $ \partial_t |\psi|^2 = i\left(\partial_x^2\psi \cdot \psi^* – \psi \cdot \partial_x^2 \psi^*\right)$ $ .

Although I wasn’t able to actually compute an initial conditions from conditions for $ n \le 2$ , I did manage to validate the result by plugging in the initial condition from the article. I did not try for $ n>2$ since even using Wolfram Alpha it still was difficult to follow the expressions.

Conclusion and questions

I am interested in validating this approach by answering to these questions:

  • Can I solve the PDE (numerical methods will do) without imposing other conditions, and if not, why is that? I looked for methods of proving that a problem is well-posed, but my background is in engineering and physics, not mathematics so I did not really know where to look for.
  • Does this approach already exist and I just didn’t look where I had to in order to find it?

Any Pitfalls in Replacing gcc and g++ With GNU Versions?

I understand that Clang is the default and recommended compiler for MacOS. My question:

What are the possible issues if I replace the default gcc and g++ binaries with the GNU versions installed via brew?

By default apple places copies in /usr/bin/ which are same as clang and clang++. I want to either overwrite these or change the path variable to make the GNU gcc and g++ the default gcc and g++ binaries.

P.S. I don’t understand why apple has to masquerade clang as gcc in the first place creating this complication!

Replacing Edge with Chromium in UWP PWA design

I’m working on a UWP project which originally adopts UWP PWA. However, Microsoft Edge is planning to replace its core with the Chromium, which may halt the current progress of full PWA support (it now, 2019/01, supports only ‘fetch’ API).

So I’m planning to take a step back with Project Centennial: the new UWP app wraps a Win32 application which embeds the CEF in order to take advantage of Chromium PWA.

Is this a good plan? Any security concerns (e.g. service working caching) I should be aware of?

Word macro for replacing images with numbered index and moving the image to the end of document

I would like to create a Word macro to separate text and images. The macro should insert the text at first place and move the images inside the text to the end of the document and replace the image with an index showing the number of the image, starting from the first image to the last image. I would appreciate if someone could help with this.

I have looked in many sites and I have developed the following code. This code simply replaces any image in the document with a text which is a kind of index. For example, it replaces the first image with just simple index as “image1.jpg” and so on. But my problem is that I don’t want to just replace the image with a numbered text index. My goal is also to move for example the image 1 to the end of the document. This should happen for the second image in the document which is replacing the 2nd image with a numbered index and then moving the image to the end of the document (after the first image) and so on for other images. I guess that this code must be added with some other code to make this happen. if someone could help, it will help a lot for making web pages suitable for printing on papers using Microsoft word macro. because sometimes it is not always necessary to print the images in the document and the text alone would be enough.

Dim oILShp As InlineShape Dim ILShpIndex As Integer For Each oILShp In ActiveDocument.InlineShapes ILShpIndex = ILShpIndex + 1 ‘insert text in place where InlineShape is located ActiveDocument.Range(oILShp.Range.Start, oILShp.Range.End).Text = _ “[Image” & ILShpIndex & “.Jpg]” ‘delete picture is not needed – it was simply replaced with text


Replacing top LCD screen and protector on EOS 80D?

I’ve just bough EOS 80D with shattered top LCD screen for fraction of the cost of a used one in perfect condition. I’ve already ordered replacement LCD screen and glass/acril protector from aliexpress for around 30$ . Has anybody tried to replace these parts by on its own? If so, are there any good videos explaining the process, any tips on what should i pay extra attention etc?