If the_title starts containing the same characters as the_content then

Right now I have a post that the_title and the_content starts with same text: "Hello world, we are WordPress…".

The above is just an example, every post has a different text.

What I want to do is basically, check if post content starts with the same few words as the title.

Then //do this.

else // do this.

I guess I need to use reggex here?

I would probably need to write how much of the first characters should match?

Maybe someone had the same situation could help me out.


How to show same company’s different office address in google based on the user’s country?

our company has five offices in five countries , once the user search in google, I need to show the office address based on the user’s country, for example if the user search from US , I need google to show US office address automatically, also if the user search a specific office address then the search result will show that country office address, for example, the user search "ABC UK or ABC UK office address " then the search result shows the UK office address. How can I do that?

OptionValue doesn’t work if a local variable has the same name as the function itself

The following innocent-looking code results in error.

Options[add] = {number -> 1}; add[x_, OptionsPattern[]] := Module[{add},    x + OptionValue[number] ]; add[1] 

The error is

OptionValue::optnf: Option name number not found in defaults for add$  2832. 

What triggers the error is the fact that a local variable declared by Module has the same name as the function, add. (For simplicity, I’ve shown an example where this local variable isn’t actually used in the code, but this doesn’t make a difference.)

Is this a bug in Mathematica, or some known quirk of OptionValue[]?

How do I join rows from the same table with slightly different info?

We have a new sector of our company that is being put into our employee record feed. However this sector is listed as contractors as there are still parts of the sector that need access to systems that require domain access… so…

I have:


EmpID, email, INFO1, INFO2, INF03…

and for Tom Smith 5763, tom.smith@co1.com, blah blah, blah blah, blah blah…

and also for Tom Smith ZZ98401, tom.smith@co2.com, null, null, null…

Not everyone on the feed is like this, only about 10%. Most are in case number 2.

What I am looking for is the easiest way to equate the two rows associated with Tom and fill in as much info on Tom as I can because some fields come from one account and other fields come from the other. The only thing that can accurately make the two rows common is the beginning of the email address – this is standardized. So there should be a few thousand people (rows of duplicates) on my feed that I can combine if it can be done right.

I would also like to capture both EmpIDs somehow in the same row and both email addresses.

How to route players in the same “room/match” to the same server?

I have a system where clients are connected to one of many servers sitting behind a loadbalancer with WebSockets. No matter which backend server clients are connected to, I am using a messaging platform (something similar to Apache Kafka) to relay actions from one client to all other clients in other servers who are supposed to be in the same room/match.

Ideally, if all clients from the same room/match can be connected to the same host, I can get rid of this inter-host messaging layer overhead and simply handle data relays within the server, which can substantially lower latency and also reduce complexity.

My question is, how can I make clients be connected to the same host?

Do I have to forego any kind of reverse proxy or load balancer, but expose server IP/Port directly for each game? (I am using a load balancer/reverse proxy which randomly distributes clients to one of the available servers in the backend.) Or can I use a load balancer with special rules (e.g. HAProxy with special rules) that route players from the same room to the same backend server instance?

For instance, Fornite can have millions of active players at any given time, but only up to 100 players are needed to be grouped together for each match.

Situation when the same page has different Statuses: Canonical and Canonicalised when crawled from the different countries

I need to show different content to the visitors from USA. I am using the following code in .htaccess to capture CloudFlare Geolocation data and append "/?country=US" to my URL once visitor came from USA:

SetEnvIf CF-IPCountry "(.*)$ " Country=$ 1
RewriteCond %{ENV:Country} ^(US)$
RewriteRule ^(.*)$ $ 1?country=%{ENV:Country} [R,L,QSA]

So basically all Americans seeing https://example.com/?country=US while rest of the world seeing: https://example.com/

Everything works as planned, the only concern I have …

US based bots (Google Search Console) now seeing this page as following:

  • https://example.com/ – StatusCode: 302, Status: Found, Indexability: Non-Indexable, Indexability Status: Redirected
  • https://example.com/?country=US – StatusCode: 200, Status: OK, Indexability: Non-Indexable, Indexability Status: Canonicalised

For the rest of the world:

  • https://example.com/ – StatusCode: 200, Status: OK, Indexability: Indexable, Indexability Status: Canonical

As you may see from above "https://example.com/" now has TWO different Responses when crawled in the US and outside of US.


  • Do you see any danger from SEO perspective? Is there any way to avoid this situation when the same page (https://example.com/) has TWO different Statuses: Canonical and Canonicalised when crawled from the different countries?
  • Will you recommend a different approach to this problem, maybe by avoiding the use of a querystring?

Thanks a lot! OZ

Is Postgres insert performance the same in the replica

We’ve got a Postgres database with a table that takes heavy select, update and inserts that needs some tuning (it has too many indexes).

We have a read replica, and I’m wondering if moving all of our SELECT queries over to the replica will be a quick win while we sort out the indexes performance. (Our application can be switched over to a replica fairly easily while sorting the indexes is going to take longer).

My understanding is that pointing read operations at the replica probably won’t improve performance in this case, but wanted to check my understanding.

My understanding is that:

  1. INSERT and UPDATE operations will return once they’re committed to memory (which is then written to the WAL asynchronously), so they’ll be not much faster.
  2. The replica will stream the WAL and will have to update it’s own copy of the tables and indexes. So SELECT operations on the replica will have to contend with the same IO and CPU demands that those updates impose on the primary, so will gain no performance.

If our app were simply streaming inserts, then I could see a performance improvement for the inserts, but in practice since the clients are performing SELECT/INSERT together, I can’t see a real performance gain here in this use case?

Is this correct, or have I missed something?

How to obtain the same result of the same system if I write the system in different ways (NDSolve)?

I did program where I solved a system when I organized in matrix form, this is the code

Clear["Global`*"]  SeedRandom[1234]  Nmax = 5; (*Number of sites*)  tini = 0; (*initial time*)  tmax = 200; (*maximal time*)  \[Sigma]2 = 0; (*Variance*)  n0 = 5; (*initial condition*)  ra = 1; (*coupling range*)  \[Psi]ini = Table[KroneckerDelta[n0 - i], {i, 1, Nmax}];  RR = RandomReal[{-Sqrt[3*\[Sigma]2], Sqrt[3*\[Sigma]2]}, Nmax];  Z = Table[     Sum[KroneckerDelta[i - j + k], {k, 1, ra}] +       Sum[KroneckerDelta[i - j - k], {k, 1, ra}], {i, 1, Nmax}, {j, 1,       Nmax}] + DiagonalMatrix[RR];  Clear[\[Psi]]  usol = NDSolveValue[{I D[\[Psi][t], t] ==      Z.\[Psi][t], \[Psi][0] == \[Psi]ini}, \[Psi], {t, tini, tmax}]  Plot[usol[t], {t, tini, tmax}] 

Now, I´m trying to solve the same system but writing the equations

Clear["Global`*"]  tini = 0;  tmax = 200;  usol = NDSolveValue[{I x1'[t] == x2[t], I x2'[t] == x1[t] + x3[t],      I x3'[t] == x2[t] + x4[t], I x4'[t] == x3[t] + x5[t],      I x5'[t] == x4[t], x1[0] == 0, x2[0] == 0, x3[0] == 0, x4[0] == 0,      x5[0] == 1}, {x1, x2, x3, x4, x5}, {t, tini, tmax}];  Plot[usol[t], {t, tini, tmax}] 

Why the second code doesn´t give me the same result if I write the same system?