I need to come up with a formula that I could use and replace values

The problem is as follows:

”Let’s say a company ran a pre-launch and generated 5,000 leads on their level 1 over a period of 30 days. Meaning, all of those leads came into the company directly from their own marketing efforts.

But throughout the well-executed pre-launch, there were multiple viral components and content released that those 5,000 people shared.

That 5,000 could balloon to 6,000… then 9,000… then 13,000, then 20,000…. throughout the launch.

In this example, using the 20,000 number, that’s 15,000 extra leads that the company had zero acquisition cost.

To drill deeper, let’s say the average CPA (cost-per-acquisition) was $ 4.00 per enrollment into the pre-launch for the company.

The company spent $ 20,000.00 on marketing (5,000 X $ 4.00) to obtain those 5,000 leads.

But thanks to the viral nature of a pre-launch, they had an extra 15,000 leads that came in.

So that brings down their overall cost per lead to just $ 1.33.”

My question is… how did they come up with the result of $ 1.33 CPA.

Thanks in advance for the help!

Hector

Using ‘replace’ for URLs in Search Results display template?

I am building a work-around for an issue I’ve encountered with a product catalog. For some reason, the CSWP and Search Results web part are displaying spaces in the managed metadata term at the end of the friendly URL with ‘%20’ instead of hyphens. I’m admittedly not a developer, but I’m learning my way around…

That said- is there a script that I can add to the Search Results “Item-Default” template that would take ‘ctx.CurrentItem.Path’ and replace the ‘%20’ with a dash? I’ve tried piecing together similar scripts from other sites, but the URL never changes. Any assistance would be greatly appreciated!

Replace media inside word / powerpoint file as zip container

I received several Powerpoint presentations with (unnecessarily) very large movies embedded, resulting in files even over 1Gb.

I mean to reduce the file size. I tried the File -> Reduce media size (or the like, my Office is in Spanish) way, and it barely changed file size.

Since newer Office files are simply zip containers with a different extension, I:

  1. Changed that to .zip,
  2. Extracted file media1.mp4,
  3. Copied it into media2.mp4,
  4. Replaced file media2.mp4 inside the .zip with this alternative file (simply click and drag),
  5. Checked that the movie was effectively replaced in the animation.

Is it expected that this works generally, even when replacing original media with reduced versions?

How can I replace static file and media links in content with their equivalent entity references?

I imported content from another system. So, for example, the body has typical html, like this:

<img src="/images/image.jpg />

All of the media assets that are referenced as static html, those files were already imported into Drupal and show up in the Files / Media tabs, so, using the WYSIWYG editor I can find that file and embed it and the Drupal link / entity reference for the same file looks like:

<drupal-entity   data-embed-button="media_images"   data-entity-embed-display="view_mode:media.image_w_caption"   data-entity-type="media"   data-entity-uuid="114cf23d-a3fc-465e-aa25-b25f0919e57b"> </drupal-entity> 

Is there a way to retroactively go through and replace all the static link references with their Drupal 8 entity reference equivalents, maybe by looking up the unique filename? Or is there a way to achieve this on initial import / re import?

I also need to do this for internal links.

Should We Replace Link Attributes/Values When We Prevent Default Link Action?

There are times when I, a custom theme, a contributed module or library, prevents the default action of an <a> tag. This is not uncommon and needed when implemented.

Something like e.preventDefault().

Now when you hover over the link, browsers will still show the innate link href value, even though the click event is intercepted. Same for bots, scrapers, scripts, anything that reads the DOM.

Examples:

  1. Change href to '#'
  2. Change title attribute (‘account-menu-list-activator’)
  3. Add aria-label(s)
  4. Or otherwise, alter the link to match it’s new UX role.

Does this matter?

`void` function to replace if-else with short circuit expression

It’s about the “code in question” in the following code:

const s = "waterrfetawx"; const del = 2; function palindromePossible(str, deleteAtMost) {   const set = new Set();   for (let i = 0, len = str.length; i < len; i++) {     const char = str[i];     void(set.delete(char) || set.add(char)); // <-- code in question   }   return set.size <= deleteAtMost + 1; } 

The code in question can also be written like this:

if (set.has(char)) {   set.delete(char) } else {   set.add(char) } 

I’m not too convinced myself whether void(...) is considered “clean”, i.e. readable, maintainable, and clear because it only wraps an expression into a statement. How would have you written it better?

How to replace a variable with another variable? [on hold]

Let’s say I have a string like below.

{% set myvar = 'Hello World' %}

{% set firstvar = 'Hello' %}

{% set secondvar = 'Test' %}

If I want to replace Hello with the test below code doesn’t work.

{{ myvar|replace({"{{firstvar}}":"{{secondvar}}"}) }} 

My expected output is : Test World

What is the wrong with the code. I ve searched everywhere but I couldn’t find it.