How to debug ajax in form?

Question: I have a form that uses ajax submit "method", the ajax submit handler returns ajax response with complete form(the form has ajax wrapper outside of itself so no issue there) and it is not working for anonymous users. I am using dynamic_page_cache only at this point.
I am displaying this form via field formatter that I have on an entity(imagine comment form) and I am using lazy builder.
The thing is that the form works for anonymous users if there are multiple forms like this on a single page(imagine taxonomy term page listing entities) but it is not working when there is only one form(entity page..imagine node/1). By not working I mean the form will submit but not with ajax but traditionally via normal post method.
I have checked the form structure, wrapper, drupalSettings.ajax entries, JS errors, watchdog..everything, but I just cannot figure out why the form does not utilize ajax but will submit as normal form instead. I have compared loaded JS with anonymous and logged in user, nothing significant there. The only thing that I have found that differs is missing form_token input in the form compared to logged-in user but I have checked the FormBuilder and this is on purpose + when I'm listing multiple entities with this form the ajax works just fine without it.
And so since there are no errors anywhere I have nothing to grab on to for debugging.
So my question is how could/should I try to debug this issue?
This question is a follow-up from Does caching has to be manually disabled for ajaxified forms?
Comment: Check: [How to debug Batch API more efficiently?](http://drupal.stackexchange.com/q/177923/1908) (D7) for some ideas.
Answer: Eureka!
So, I still am not sure what the issue was 100% but I am guessing that there was a name collision with multiple different forms and since Drupal uses name "op" for every submit button since the dark ages of the internet I guess the ajax was trying to get itself applied to the other form that had submit button as well(named op as well) but that did not work of course so that resulted in this weird behavior.
So the way I have fixed this was by setting the #name AND #id attributes on the submit button in my form. I have set the #id which I normally don't do in ajax forms because I would get wrong drupalSettings.ajax entry.
I didn't do this in the first place because the form was working just fine for logged-in users + just fine for anonymous users on entity listings so it didn't made any sense but hey, the more you know.

How to debug ajax in form?


Induction proof of lower bound for $\sum \sqrt n$

Question: I'm having some trouble proving the following statement using mathematical induction:
$$\frac{1}{2}n^{\frac{3}{2}} \leq \sqrt{1} + \sqrt{2} + \sqrt{3} + \sqrt{4} + ... + \sqrt{n}      ,\text{ (for all sufficiently large n)}$$
I'm sort of confused because $n^{\frac{3}{2}}$ = $n  n^{\frac{1}{2}}$ which means that there are n of the largest possible root values on the left hand side while the right hand side has values like $\sqrt{1}$, $\sqrt{2}$, etc. As n grows sufficiently large wouldn't the left hand side outgrow the right hand side no matter what the constant multiple is? If I'm thinking about this correctly just let me know, if not, any help would be appreciated.
Comment: I don't think your intuition is right. You probably know that $1+...+n = n(n+1)/2$ is quadratic and $1+...+n^2 = n(n+1)(2n+1)/3$ is cubic
Comment: Don't forget the $1/2$!  There are $n/2$ of the largest possible root values on the left, not $n$.
Comment: Are you having any particular trouble with the induction step?
Comment: Can you estimate the LHS difference $\frac 12 n^{3/2}- \frac 12 (n-1)^{3/2}$? If it is always less than $\sqrt n$ from some point, there's your induction step. (Hint: Calculus!)
Answer: You're right that $$\sum_{k=1}^n\sqrt k\le n\cdot\sqrt n=n^{3/2}\;,$$ but you can't infer from that that $\frac12n^{3/2}$ will eventually exceed $\sum_{k=1}^n\sqrt k$. Suppose that we divide everything through by $n$. Then the claimed inequality becomes
$$\frac12\sqrt n\le\frac1n\sum_{k=1}^n\sqrt k\tag{1}\;.$$
The righthand side of $(1)$ is just the arithmetic mean of the square roots $\sqrt 1,\sqrt 2,\dots\sqrt n$. You've observed (correctly) that this mean cannot be any bigger than $\sqrt n$, the largest of the $n$ numbers, but that doesn't mean that it must eventually be smaller than half of the largest number. In fact, if you draw the graph of $y=\sqrt x$ you'll see that it gets less and less steep as $x$ increases. When $n$ is large, therefore, most of the square roots in the list $\sqrt 1,\sqrt 2,\dots,\sqrt n$ are a lot closer to $\sqrt n$ than they are to $0$, and when you average them, the result is closer to $\sqrt n$ than to $0$. But that just means that it's bigger than $\frac12\sqrt n$.
To prove the theorm by induction, you have to establish a starting point ('base case') and prove an induction step. For the induction step, suppose that you know for some $n$ that $$\frac12n^{3/2}\le\sum_{k=1}^n\sqrt k\tag{2}\;;$$ this is your induction hypothesis. You want to use it to show that $$\frac12(n+1)^{3/2}\le\sum_{k=1}^{n+1}\sqrt k\;.\tag{3}$$
To get from the righthand side of $(2)$ to the righthand side of $(3)$, we've obviously just added $\sqrt{n+1}$. If we knew that the lefthand side increased by at most $\sqrt{n+1}$, i.e., that
$$\frac12(n+1)^{3/2}\le\frac12n^{3/2}+\sqrt{n+1}\;,$$ we'd be in business: we'd have
$$\frac12(n+1)^{3/2}\le\frac12n^{3/2}+\sqrt{n+1}\le\sum_{k=1}^n\sqrt k+\sqrt{n+1}=\sum_{k=1}^{n+1}\sqrt k\;,$$
showing that $(2)$ does imply $(3)$.
So how can we show that
$$\frac12(n+1)^{3/2}\le\frac12n^{3/2}+\sqrt{n+1}\;?\tag{4}$$
Let's tinker a bit. $(4)$ is equivalent to
$$(n+1)^{3/2}\le n^{3/2}+2\sqrt{n+1}\;,$$
which is equivalent to
$$(n+1)\sqrt{n+1}\le n\sqrt n+2\sqrt{n+1}\;.$$
This in turn is equivalent to
$$n\sqrt{n+1}+\sqrt{n+1}\le n\sqrt n+2\sqrt{n+1}\;,$$
which is equivalent to
$$n\sqrt{n+1}\le n\sqrt n+\sqrt{n+1}$$ and then to $$(n-1)\sqrt{n+1}\le n\sqrt n\;.\tag{5}$$
Everything in $(5)$ is non-negative, so $(5)$ is equivalent (for positive integers $n$) to the inequality that you get by squaring it,
$$(n-1)^2(n+1)\le n^3\;.\tag{6}$$
Can you show that $(6)$ is true for all positive integers? If so, working back through the chain of equivalent inequalities gives you $(4)$ for all positive integers and thereby shows that $(2)$ implies $(3)$ for all positive integers. To finish the induction, you just have to find a positive integer $n_0$ for which $(2)$ is true to conclude that $(2)$ is true for all integers $n\ge n_0$.
Added: This is the elementary way to approach the problem. If you're a bit ingenious and know your calculus, you can prove the result without induction. The sum $\sum_{k=1}^n\sqrt k$ is an upper Riemann sum for $\int_0^n\sqrt x~dx$, so $\int_0^n\sqrt x~dx\le\sum_{k=1}^n\sqrt k$. How does $\int_0^n\sqrt x~dx$ compare with $\frac12 n^{3/2}$?
Comment: Thanks this really helped, I believe I can finish the problem from here, but may take some time to really understand everything thoroughly.
Comment: There is also a pre-calculus way to do this without induction: multiply both sides by $2$ and use the fact that $\sqrt{i}+\sqrt{n-i} \ge \sqrt{n}$ (easy by squaring both sides) to show that the RHS is $\ge (n+1)\sqrt{n}$


Game stuck on first frame when triggered by onclick event

Question: I'm making a game in a webpage using the html canvas element, and I have put all of the code for my game inside of a function called playPong(), and when the code is not stored inside of a function, it works perfectly fine, but when the function is called from the onclick event, all of the elements of the game show, but nothing happens. This is my code.

<canvas id='my' width = '640' height = '480'></canvas>

<button onclick = 'playPong()'> Play pong </button>
Comment: ? there is no code in line 178.
Comment: Please send the code in line 178. I think it has a syntax bug
Answer: If you want to start game by button. You can create function playPong() to cover just tick() code line.
Like below.

<canvas id='my' width = '640' height = '480'></canvas>

<button onclick = 'playPong()'> Play pong </button>


The difference between modify and modify_key in boost multi_index_container

Question: What is the difference between modify and modify_key in boost multi_index_container. I read their documentation both and I can't seem to find the difference between the usages of both.
Link to the documentation
Answer: modify_key is a variation of modify that saves you some typing when the only part of the element you want to change is the key itself. For instance, if I define a multi_index_container such as:
struct element
{
  int x;
  int y;
};

using namespace boost::multi_index;

using container=multi_index_container<
  element,
  indexed_by<
    ordered_unique<member<element,int,&element::x>>
  >
>;

container c=...;

Then the following:
auto it=...;
c.modify(it,[](element& e){e.x=3;});

can be written with modify_key as
auto it=...;
c.modify_key(it,[](int& x){x=3;});

Comment: Thanks for your answer. I have already figured this out as I stated in my answer. Accepted for the detailed reply.
Answer: Basically the difference between the usages of both (as far as I understood is as follows):

Modify:
The functor is passed a reference to the whole object that was retrieved  and the functor can modify any of the members of this retrieved object.
Modify_Key:
The functor modifies only the key that is used in searching for and retrieving the object. For instance, using an index with the name member of a class to search the container, upon applying modify_key on the returned iterator, the name member will be changed.

Basically modify_key is a special case from modify.


Is there a carousel that uses DIV containers for separate content instead of lists?

Question: Instead of:

I would like a carousel that uses DIV containers. The reason I need this is because I'm making a Tumblr theme, which for those who don't know is a blogging network where you post content on a "Dashboard" and the content is generated dynamically from Tumblr through tags. Lists like this do not have the ability to produce new tags for new content.
Comment: you should be able to generate LIs dinamically just fine using loops in tumblr, if it still looks like Smarty.
Answer: I have used both Nivo (mentioned earlier, http://nivo.dev7studios.com) and jQuery Cycle plug-in, found at: http://jquery.malsup.com/cycle/
Both are good and work very well.
Nivo is slightly easier to set up but the thumbnails-pager option takes a bit more effort because the CSS modifications are not as clearly documented.
jQuery Cycle is more of a workhorse, and will handle not only images, but div's with structured content.
jQuery Cycle has plenty of examples to pick from, especially if you need pagers (whether index numbers or image thumbnails).
Comment: Would it be able to generate a new slide for dynamically loaded content?
Comment: And each slide would have to be able to hold things like text, music players, etc.. I need it for a Tumblr theme idea.
Comment: jQuery Cycle handles **non-image content** quite well as demonstrated at http://jquery.malsup.com/cycle/int2.html (see example towards bottom of page)
Comment: This is great, it's one of the best carousels I've come across... However, I don't see an option to place controls on the non-image content slide. I tried but it just keeps scrolling to the right. Any way to do this?
Comment: Well I figured it out, but I want the scroll right feature... It seems the scroll right is automatic. You can use the fade animation on non-image content but the scroll right animation just keeps on going. Anyway to disable this?
Comment: Nevermind! Haha wow I should read next time. It's all fixed. Wow this is definatley the best I've ever used, thanks!
Answer: Check these out:

http://slidesjs.com/
http://nivo.dev7studios.com/
Answer: Here is a simple jQuery one. You could even change it to just images and rule out divs altogether.
http://jsfiddle.net/QnkEm/4/

Updated to use the supplied images.


Dynamically loading an external JavaScript response

Question: I'm using this code to include dynamically js file in run-time:
var headID = document.getElementsByTagName("head")[0];
var script = document.createElement('script');
script.type='text/javascript';
script.src="js-debug/"+record.getId()+".js";

script.onload = function() {
      inizializeComponent();
}

For every node of menu, I include a different js file.
Now I need to intercept the event triggered when the page does not exist to show a messagebox!
How can I get it?
Comment: in script.src there is the path of js file that i dynamically include! for example, when user click on the first node of menu:          script.src = js-debug/1.js but if this page not exist i need to intrercept this event to show an error messagebox
Answer: Use script.onerror = function () { ....
Comment: thanks! it's works fine on Mozilla but not good for internet explorer! how can i use script.onerror also in Internet Explorer?
Comment: ok! now it works also in IE9 - i need of this


BareOS BackupCatalog job stuck in the Director as terminated, RunAfterJob did not run

Question: This looks very strange. I use Bacula and now BareOS for more than 10 years, but now one system experiences strange behaviour and I can't find out why and how to fix.
When it runs daily backups, it works fine, until it reaches the BackupCatalog job, which is configured to run after everything else.
This job looks like it was successfully terminated (JobStatus=T in the list jobs table):
*list jobs
...
+-------+---------------+--------------+---------------------+------+-------+----------+-----------------+-----------+
| JobId | Name          | Client       | StartTime           | Type | Level | JobFiles | JobBytes        | JobStatus |
+-------+---------------+--------------+---------------------+------+-------+----------+-----------------+-----------+
...
| 5,475 | BackupCatalog | kantor-fd    | 2019-12-04 02:56:40 | B    | F     |       21 |      27,364,860 | T         |
+-------+---------------+--------------+---------------------+------+-------+----------+-----------------+-----------+

However, in messages and in the log file I don't see the usual summary for this last job. The log file finishes like this:
19-Nov 02:32 kantor-dir JobId 5398: shell command: run BeforeJob "/usr/lib/bareos/scripts/make_catalog_backup.pl Kantor"
19-Nov 02:33 kantor-dir JobId 5398: Start Backup JobId 5398, Job=BackupCatalog.2019-11-18_23.10.00_10
19-Nov 02:33 kantor-dir JobId 5398: Using Device "FileStorage" to write.
19-Nov 02:33 kantor-sd JobId 5398: Volume "Kantor-2018-01-08_08:48:50" previously written, moving to end of data.
19-Nov 02:33 kantor-sd JobId 5398: Ready to append to end of Volume "Kantor-2018-01-08_08:48:50" size=4716094462
19-Nov 02:33 kantor-sd JobId 5398: Elapsed time=00:00:05, Transfer rate=5.663 M Bytes/second

And that's all. Note, RunAfterJob script seem to had not been executed. But if I execute it by hand, it works (the exported catalog database file gets removed). This is not the only job with RunAfterJob script, however.
I expected it to show something like this in the end. All other jobs have it:
19-Nov 02:32 kantor-dir JobId 5397: Bareos kantor-dir 16.2.6 (02Jun17):
  Build OS:               x86_64-pc-linux-gnu debian Debian GNU/Linux buster/sid
  JobId:                  5397
  Job:                    FTP.2019-11-18_23.05.00_09
...
  FD termination status:  OK
  SD termination status:  OK
  Termination:            Backup OK

19-Nov 02:32 kantor-dir JobId 5397: Begin pruning Jobs older than 1 month 10 days .
...

Also, the director status looks strange:
*status dir
kantor-dir Version: 16.2.6 (02 June 2017) x86_64-pc-linux-gnu debian Debian GNU/Linux buster/sid
Daemon started 03-Dec-19 11:10. Jobs: run=4, running=1 mode=0 db=mysql
 Heap: heap=135,168 smbytes=222,459 max_bytes=236,758 bufs=543 max_bufs=594

Scheduled Jobs:
...
====

Running Jobs:
Console connected at 04-Dec-19 09:03
 JobId Level   Name                       Status
======================================================================
  5475 Full    BackupCatalog.2019-12-03_23.10.00_08 has terminated
====

Terminated Jobs:

 JobId  Level    Files      Bytes   Status   Finished        Name
====================================================================
...
  5471  Incr      6,591    7.499 G  OK       03-Dec-19 23:15 termsrv
  5472  Incr        427    11.37 G  OK       03-Dec-19 23:44 1C
  5473  Incr          3    3.198 G  OK       04-Dec-19 02:56 Oracle
  5474  Incr      5,797    2.600 G  OK       04-Dec-19 02:56 FTP

Client Initiated Connections (waiting for jobs):
...
====

i.e. the said job listed in the "running jobs", but it says it is terminated. It doesn't listed in the "terminated jobs", as if director still has something to finish.
It hanged in this state for six hours. I also see some strangeness with times (StartTime for it in the table and in the log file differs by half of hour, however, system date and MySQL's select NOW(); are in sync).
After director restart, director status looks more appropriate:
Running Jobs:
Console connected at 04-Dec-19 09:06
No Jobs running.
====
No Terminated Jobs.

This all started two weeks ago. If I leave it hanging, all following scheduled jobs will wait indefinitely for this stuck job, meaning, no backups will be performed.
I feel this could be issue with this job's RunAfterJob script, but it is standard shipped script. If I run in by the hand, it works. The job definition itself is also standard shipped, the only modification is that I added compression=GZIP in the FileSet, but I do that every time and this never caused any problems.
What to look for? How to fix?

Update:
The problem disappeared. I don't understand, why. Backups work for at least two days. Nothing appears to be stuck.
Answer: It appears it was configured to send bootstrap file by e-mail at the end of the backup in the BackupCatalog job:
Write Bootstrap = "|/usr/bin/bsmtp -h localhost -f \"\(Bareos\) \" -s \"Bootstrap for Job %j\" root@localhost"

If e-mail sending on the server is not configured, it will stuck. If the email sending was obstructed but fixed afterwards outside the server, it will suddenly unstuck without visible indication what wat changed. That seems to be my case.
By removing this Write Bootstrap the problem is completely avoided. (The job will write the local bootstrap file as configured in the JobDefs-referenced DefaultJob template.)
This is a deficiency in the BareOS that it doesn't explain what could go wrong and doesn't log this as the problem and go further. It just stucks. That sucks. Is't a pity also it is configured that way by default.


How to get text from search field?

Question: I'm making a basic web browser to start me off and I would like to add some new features. However, I can't get the text from the urlbar (which is just a searchbar) stored in a variable. Could someone please help?
Here's my zseAppDelegate.h file:
#import <Cocoa/Cocoa.h>

@interface zseAppDelegate : NSObject <NSApplicationDelegate>

@property (assign) IBOutlet NSWindow *window;
@property (weak) IBOutlet NSSearchField* searchfield;
@end

Here's my zseAppDelegate.m file:
#import "zseAppDelegate.h"

@implementation zseAppDelegate
@synthesize searchfield,window;

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    NSString * searchf = [searchfield, stringValue]
};

@end

Answer: NSSearchField inherits from NSTextField, which is an NSControl. That implements stringValue.
So, e.g.
NSString *searchFieldValue = [searchField stringValue];

How to get text from search field?


Installing Drush on Mac

Question: I am installing Drush on my Mac following the instructions I found on https://linode.com/docs/websites/cms/drush-drupal/.
Everything works perfect, but I got stuck at the end while creating the symbolic link. Please find the error below.
Mudasirs-iMac:/ mudasir$ sudo ln -s /usr/local/src/drush/drush /usr/bin/drush

ln: /usr/bin/drush: Operation not permitted

Comment: You should look into homebrew it is a package manager for Mac. Basically, a tool for installing tools.
Comment: Another tool that you can use to install drush is composer. Which is a php package manager.
Comment: You simply don't have the permissions to `usr/bin` anymore as in earlier versions of mac. Use `usr/local/bin` instead. So the command should be adjusted to `sudo ln -s /usr/local/src/drush/drush /usr/local/bin/drush` instead.
Answer: You can't write to /usr/bin on OSX (since Yosemite).
Add your symlink to /usr/local/bin instead, and make sure that's in your path.
ln -s /usr/local/src/drush/drush /usr/local/bin/drush

Comment: True but some enterprising individual could have removed it @leymannx, was just covering all bases I guess :) Thanks for adding the command sample, I removed `sudo` as it's not required and may cause issues for some people
Comment: Thanks, how can I get to know that its in my path or how can I add this to my path
Comment: Depends, but for bash: http://stackoverflow.com/questions/11025980/how-to-add-usr-local-bin-in-path-on-mac
Comment: @Mudasir, after creating the symlink into /usr/local/bin, just try typing "dru" and hit "Tab" key to see if it completes it to "drush". Then that means that /usr/local/bin is in your path. Also you can check by typing "echo $PATH" into terminal and find /usr/local/bin there. If it's not in your path environment, then simply follow the link Clive put above and add it to your path. Make sure you do "source ~/.bash_profile" or logout/login to your mac after changing .bash_profile to get the new path variable loaded.
Comment: Hi, thanks for you guys help, when I am looking for path it shows me /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/bin:/usr/bin, I can find /usr/local/bin there, but while creating the symblink, I still have the same issue.
Comment: `usr/local/bin` is already in the path by default.

Installing Drush on Mac


Strange behaviour of media element

Question: I'm making a media player with basic functions, but it is behaving strangely, when pause play or stop button is clicked following exception occurs 'System.NotSupportedException' Additional information: Cannot control media unless LoadedBehavior or UnloadedBehavior is set to Manual.
Required code and xaml is as follows:
XAML:
<MediaElement x:Name="VideoPreview" LoadedBehavior="Manual"  UnloadedBehavior="Stop" Width="auto" Height="250"  MediaOpened="Element_MediaOpened" MediaEnded="Element_MediaEnded" Source="{Binding SelectedItem.SourceUri, ElementName=VideoList}" Margin="5,5,5,5" Stretch="Fill"/>

Code behind:
void OnMouseDownPlayMedia(object sender, MouseButtonEventArgs args)
{
    VideoPreview.Play();
}

// Pause the media.
void OnMouseDownPauseMedia(object sender, MouseButtonEventArgs args)
{
    VideoPreview.Pause();
}

// Stop the media.
void OnMouseDownStopMedia(object sender, MouseButtonEventArgs args)
{
    VideoPreview.Stop();
}

When either of the mouse events is clicked I get the exception.
Comment: I had made a mistake by writing "m" of Manual in lowercase.
Answer: The answer really is in the error text... Cannot control media unless LoadedBehavior or UnloadedBehavior is set to Manual. Therefore, your solution is to set either the MediaElement.LoadedBehavior or MediaElement.UnloadedBehavior property to a value of MediaState.Manual.
From the MediaElement.LoadedBehavior Property page on MSDN:

LoadedBehavior must be set to Manual in order to interactively control media with the Play, Pause, and Stop methods.

It's amazing what you can find out from MSDN.
Comment: thank you for reply I just had made a mistake by writing "m" of Manual in lowercase.
Comment: 9 years later thIS MICROSOFT STRANGE problem appears all of a sudden in my code, the MediaState.Manual is already in the code and it DOES NOT FIX IT.  Also audio quit playing all together, thank you MICROSOFT for trying to drive me off WPF.

Strange behaviour of media element


SQL Server Database Recovery

Question: do u have any idea , which is the best software or best way to recover corrupt database in sql 2000/2005/2008
Answer: The backup tool.
Seriously. if you have corrupt data, it is corrupt...
It cannot be recovered from the DB file - go back to your latest backup, apply it, roll forward the transaction logs.
Answer: Try to run Run DBCC checkdb with repair_allow_data_loss. if it doesn't provide any suitable result then try to restore database from last backup. otherwise the Free SQL .mdf recovery software is best option for recovering the database see here: http://www.mdfviewer.com/recovery/

SQL Server Database Recovery


Failed to create AWSConfig rule: InvalidParameterValueException: Blank spaces are not acceptable for input parameter: threshold

Question: I am trying to create an aws config rule for checking that cloudtrail alarms are enabled. I get the following error Error: Error creating AWSConfig rule: Failed to create AWSConfig rule: InvalidParameterValueException: Blank spaces are not acceptable for input parameter: threshold. when I run terraform apply. I'm not sure what the formatting issue is in the input parameters argument (see input_parameters). The apply works if I remove everything except for metricName i.e
input_parameters = "{\"metricName\":\"CloudTrailConfigChanges\"}"

Any help would be greatly appreciated.
resource aws_config_config_rule ensure-log-alarm-exists-for-cloudtrail {
  name = "ensure-log-alarm-exists-for-cloudtrail"
  description = "Checks whether cloudwatch alarm is on for cloudtrail configuration changes"

  source {
    owner = "AWS"
    source_identifier = "CLOUDWATCH_ALARM_SETTINGS_CHECK"
  }

  input_parameters = "{\"metricName\":\"CloudTrailConfigChanges\",\"threshold\":1,\"evaluationPeriod\":1,\"period\":300,\"comparisionOperator\":\"GreaterThanOrEqualToThreshold\",\"statistic\":\"Sum\"}"
}

It seems like there is an issue parsing type ints from json strings: https://github.com/hashicorp/terraform-provider-aws/issues/773#issuecomment-385454229
I get the same error even with
  input_parameters =<<EOF
{
  "metricName":"CloudTrailConfigChanges",
  "threshold":1
}
EOF

or
input_parameters = jsonencode({"metricName":"CloudTrailConfigChanges","threshold"=1})

Converting wrapping the int value in quotes does not work either.
resource "aws_config_config_rule" "ensure-log-alarm-exists-for-cloudtrail" {
  name        = "ensure-log-alarm-exists-for-cloudtrail"
  description = "Checks whether cloudwatch alarm is on for cloudtrail configuration changes"

  source {
    owner             = "AWS"
    source_identifier = "CLOUDWATCH_ALARM_SETTINGS_CHECK"
  }

  input_parameters = jsonencode({
    metricName = "CloudTrailConfigChanges"
    threshold  = "1"
  })
}

The code above produces the following error:
Unknown parameters provided in the inputParameters:

Answer: With your examples you're still specifying the threshold as an integer. Try making it a string.
resource "aws_config_config_rule" "ensure-log-alarm-exists-for-cloudtrail" {
  name        = "ensure-log-alarm-exists-for-cloudtrail"
  description = "Checks whether cloudwatch alarm is on for cloudtrail configuration changes"

  source {
    owner             = "AWS"
    source_identifier = "CLOUDWATCH_ALARM_SETTINGS_CHECK"
  }

  input_parameters = jsonencode({
    metricName = "CloudTrailConfigChanges"
    threshold  = "1"
  })
}

Comment: Thank you for your suggestion. I've updated the question to show the results of your suggestion. It did not fix the issue. Please remove your answer.
Comment: What version of the AWS provider are you using?
I have tested the above config with v3.18.0 and this works.
Answer: I ran into an error like this, and what resolved it for me was to add a condition.  I don't fully understand why this worked and why it caused this error without the condition, but I saw the condition used in an AWS example.
For example, I first tried using something straightforward like this to reference a parameter:
        "InputParameters": {
            "appNames": {
                "Ref": "ApplicationNames"
            }
        }

When my resource referenced the ApplicationNames parameter directly like this, it was giving that error.  But using Conditions and referencing the parameter this way caused it to work, as in this full template example:
{
    "AWSTemplateFormatVersion": "2010-09-09",
    "Description": "Just a stripped-down example",
    "Parameters": {
        "ApplicationNames": {
            "Type": "String",
            "Default": "This Has Spaces",
            "MinLength": "1",
            "ConstraintDescription": "This parameter is required."
        }
    },
    "Conditions": {
        "ApplicationNamesDefined": {
            "Fn::Not": [
                {
                    "Fn::Equals": [
                        "",
                        {
                            "Ref": "ApplicationNames"
                        }
                    ]
                }
            ]
        }
    },
    "Resources": {
        "SampleRule": {
            "Type": "AWS::Config::ConfigRule",
            "DependsOn": "SecurityHubCustomUpdaterFunction",
            "Properties": {
                "ConfigRuleName": "TheName",
                "Description": "It was here that I was getting 'Blank spaces are not acceptable for input parameter: applicationNames' before I added the Conditions and Fn::If to reference it",
                "InputParameters": {
                    "appNames": {
                        "Fn::If": [
                            "ApplicationNamesDefined",
                            {
                                "Ref": "ApplicationNames"
                            },
                            {
                                "Ref": "AWS::NoValue"
                            }
                        ]
                    }
                },
                "Scope": {
                    "ComplianceResourceTypes": [
                        "AWS::SSM::ManagedInstanceInventory"
                    ]
                },
                "Source": {
                    "Owner": "AWS",
                    "SourceIdentifier": "EC2_MANAGEDINSTANCE_APPLICATIONS_REQUIRED"
                }
            }
        }
    }
}

So you may want to try with Conditions usage.


One of $a^5b-ab^5,b^5c-bc^5,c^5a-ca^5$ is divisible by $8$ if $a,b,c∈\mathbb{Z}^+$

Question: Given that $a,b,c$ are there distinct positive integers, prove that among $a^5b-ab^5,b^5c-bc^5,c^5a-ca^5$, there is at least one that is divisible by $8$.
I have no clue what to do and cannot even create cases as these are three random whole numbers. What do I do? Please help me guys!!!
Even a hint is graciously accepted!!!
Answer: The three numbers are cyclic permutations of $ab(a^4-b^4)$.  Therefore, at least one of the products must be formed from either $2$ even numbers or $2$ odd numbers.
If $a$ and $b$ are both even, then so is $(a^4-b^4)$, so $ab(a^4-b^4)$ is the product of three even numbers, which must be divisible by $8$.
If $a$ and $b$ are both odd, then $a^4 \equiv b^4 \pmod{8}$ (because any odd number is a square root of $1$ (mod $8$)), so $8|(a^4-b^4)$ and therefore $8|ab(a^4-b^4).$
Comment: Thank you bro!!! Helped out a lot!!
Comment: Upvotes and acceptances are always appreciated.
Comment: I'm new so can't upvote as it says I don't have enough reputation
Comment: Try it now.  You should now have enough reputation.
Comment: Did it. Thanks
Comment: If you liked this answer, mark it as the correct one by clicking on the tick mark beside the answer.
Answer: Note that $x\equiv 0$ (mod $16$) if $x$ is even and $x\equiv 1$ (mod $16$) if $x$ is odd.
Among $a$, $b$ and $c$, at least two are of the same parity. If $a$ and $b$ have the same parity, then $a^4-b^4$ is divisible by $16$.


Maven error when doing packaging

Question: I am facing issues while trying to execute package goal in POM.xml file for my Maven application.
I am getting below error while trying to package to jar file
Failed to execute goal org.apache.maven.plugins:maven-plugin-plugin:3.2:descriptor (default-descriptor) on project codesign-maven-plugin: Error extracting plugin descriptor: 'Goal: version already exists in the plugin descriptor for prefix: getversion
[ERROR] Existing implementation is: com.ios.plugin.VersionMojo
[ERROR] Conflicting implementation is: com.ios.plugin.VersionMojo'

My project is checked out from version controlled system and there are some versioned controlled file in my project, it seems they are getting included during execution
Here are my POM.xml file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <parent>
        <groupId>com.ios.ccss</groupId>
        <artifactId>ios-client</artifactId>
        <version>3.0-Beta</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>ios-maven-plugin</artifactId>
    <packaging>maven-plugin</packaging>
    <name>ios-maven-plugin</name>
    <dependencies>
        <dependency>
            <groupId>com.ios.ccss</groupId>
            <artifactId>ios-lib</artifactId>
            <version>3.0-Beta</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-plugin-api</artifactId>
            <version>2.0</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-plugin-plugin</artifactId>
                <version>3.2</version>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
                <executions>
                    <execution>
                        <id>default-descriptor</id>
                        <goals>
                            <goal>descriptor</goal>
                        </goals>
                        <phase>process-classes</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <packagingExcludes>**/.ade_path/**</packagingExcludes>
                    <excludes>
                        <exclude>**/.ade_path/**</exclude>
                    </excludes>
                    <testExcludes>
                        <exclude>**/.ade_path/**</exclude>
                    </testExcludes>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                            <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                        </manifest>
                    </archive>
                    <appendAssemblyId>false</appendAssemblyId>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>

                        <phase>package</phase>

                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <finalName>ios-maven-plugin</finalName>
    </build>
</project>

Comment: Have you tried deleting build/target directories?
Comment: Yes I did all the cleanup before triggering for package task
Answer: Problem
Have just faced the same problem, after adding the @Mojo annotation to the MyMojo (a class derived from the AbstractMojo class).
The problematic part of the source code:
/**
 * Goal which touches a timestamp file.
 *
 * @goal touch
 *
 * @phase process-sources
 */
@Mojo(name = "touch", defaultPhase = LifecyclePhase.COMPILE)
public class MyMojo extends AbstractMojo {

Please, note both the Javadoc and the @Mojo annotation.
Solution
The solution is to remove the Javadoc for the MyMojo class and use only the @Mojo annotation.
The resulting source code:
@Mojo(name = "touch", defaultPhase = LifecyclePhase.COMPILE)
public class MyMojo extends AbstractMojo {

Source: jigger mast: Creating a maven plugin with java 5 annotations rather than javadoc tags.

Maven error when doing packaging


JTextArea vertical scrollbar showing up when not needed

Question: I need a vertical scrollbar in my JTextArea to only appear when it's needed, and for that I know I need to use Vertical Scrollbar As Needed. But the scrollbar keeps showing up, like this:
enter image description here
even when it's clearly not needed. What am I doing wrong?
// make top panel where output from the menu selections will appear
        topP = new JPanel(new BorderLayout());
        topP.setSize(new Dimension(500,150));
        // make default text message to be displayed in top panel
        output = new JTextArea("Output printed here...", 20, 20);
        // styles the text in the textarea
        output.setForeground(Color.BLUE);
        output.setFont(new Font("Times New Roman", Font.BOLD, 20));
        topP.add(output, BorderLayout.NORTH); // add default text to the top panel
        right.add(output);

        // here's the scrollbar guys
        top = new JScrollPane(output); // applies to the textarea
        top.setPreferredSize(new Dimension(500,150));
        top.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
        top.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        topP.add(top, BorderLayout.NORTH);

Comment: I think your scrollbar is appearing due to problems with your layout. Did you notice you're adding your textarea `output` to two different containers? Where is the container `right`defined?
Comment: `right` is a JPanel defined as `right = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10,10));
        right.setPreferredSize(new Dimension(400,500));`. And I tried commenting out each of the output.add lines - only adding it to the topP, then only adding it to the container `right`, but there was no difference in the scrollbar behavior.
Comment: Did you see the answer?
Comment: I did and it worked for me. Thank you so much!
Answer: Take a look at the documentation for JTextArea. If you scroll down to the constructor summary section, you'll see the following:

JTextArea(String text, int rows, int columns)
  Constructs a new TextArea with the specified text and number of rows and columns.

This is the same as the constructor you're using:
output = new JTextArea("Output printed here...", 20, 20);

By specifying rows and columns, you're effectively telling the JTextArea that it has to be a certain size, and the scrollpane is just responding to your specifications by showing scroll controls. Those scroll controls are displayed based on the number of rows and columns you asked for, as opposed to the amount of visible text within the text area.
If you construct a JTextArea without specifying rows and columns, there won't be any scrollbars. Since you're setting the size of the text area, specifying rows and columns is redundant anyhow. Just don't do it.
Note: You should avoid setting the absolute size of Swing components. Set a preferred size only, and when you call pack(), Swing will try to accommodate your specification as much as possible. When you specify absolute sizes, your UI can look really bad on different platforms or when a user resizes the frame.


Find the maximum value $P=x^{2}(y-z)+y^{2}(z-y)+z^{2}(1-z)$

Question: Given $x;y;z$ satisfying $0 \le x \le y \le z \le 1 $
Find the maximum value $$P=x^{2}(y-z)+y^{2}(z-y)+z^{2}(1-z)$$
$\bullet$ Note that:  $x^2(y-z) \le 0$
$\bullet$ By AM-GM we have: $y^2(z-y)=\dfrac{y^2(2z-2y)}{2}\le\bigg(\dfrac{2y+2x-2y}{3} \bigg)^3 . \dfrac{1}{2}=\dfrac{4z^3}{27}$
$\bullet$ So we need to find the maximum value of $\dfrac{4z^3}{27}+z^2(1-z)$, I have found it, $P\le \dfrac{108}{529}$ when $x=0;y=\dfrac{12}{23};z=\dfrac{18}{23}$ and by Wolfram Alpha, the problem has been solved.
But I found the solution because I already know its maximum value, which is $P\le \dfrac{108}{529}$ when $x=0;y=\dfrac{12}{23};z=\dfrac{18}{23}$, is there any way without knowing the answer in advance to solve this problem ?
Comment: You could probably just set the partial derivatives to $0$.
Comment: I am not sure what you mean by you knew in advance value of $x, y, z$. How did you find value of $z$ at which maximum occurs? Using calculus?
Answer: You don't need WA.
Just by AM-GM twice we obtain:
$$x^2(y-z)+y^2(z-y)+z^2(1-z)\leq4\cdot\left(\frac{y}{2}\right)^2(z-y)+z^2(1-z)\leq$$
$$\leq4\left(\frac{2\cdot\frac{y}{2}+z-y}{3}\right)^3+z^2(1-z)=\frac{4z^3}{27}+z^2(1-z)=$$
$$=\frac{1}{27}z^2(27-23z)=\frac{4}{27\cdot529}\left(\frac{23z}{2}\right)^2(27-23z)\leq$$
$$\leq\frac{4}{27\cdot529}\left(\frac{2\cdot\frac{23z}{2}+27-23z}{3}\right)^3=\frac{108}{529}.$$
The equality occurs for $x=0$, $\frac{y}{2}=z-y$ and $\frac{23z}{2}=27-23z,$ which says that we got a maximal value.


Unidentifiable Class Function Copy

Question: So, I am currently working on a text-based RPG, and I've run into an odd issue working on the character's inventory. I am getting the following error:
qualified-id in declaration before '(' token
This error is located at the following line of code in my Inventory.cpp class:
void Inventory::addItem(Item *I){...}
Of course, I realize that this isn't enough information to go by, so here is all the coding for both Inventory.h and Inventory.cpp:
In Inventory.h:
 #ifndef INVENTORY_H
 #define INVENTORY_H

 #include "Item.h"
 #include <string>

 const int BACKPACK_SIZE = 16;

 class Inventory
 {
     public:
         Inventory();

         void addItem(Item *I);

         std::string getInventory();

         Item *backpack[BACKPACK_SIZE];
     protected:

     private:
 };

 #endif // INVENTORY_H

In Inventory.cpp:
#include "Inventory.h"

 Inventory::Inventory(){
     for(int i = 0; i < BACKPACK_SIZE; i++){
         backpack[i] = nullptr;
     }
 }

 std::string Inventory::getInventory(){
     std::string allItems = "";
     int counter = 1;
     for(int i = 0; i < BACKPACK_SIZE; i++){
          if(backpack[i] == nullptr){
             continue;
          }
          else{
              allItems += (counter + ".) " + backpack[i]->getName() + "\n");
              counter += 1;
          }

     return allItems;
 }

 void Inventory::addItem(Item *I){ //THIS LINE IS WHERE THE ERROR APPEARS
     for(int counter = 0; counter < BACKPACK_SIZE; counter++){
         if(backpack[counter] == nullptr){
             backpack[counter] == I;
             break;
         }
     }
 }

I've done my research, yet I simply cannot figure what on earth I am doing wrong. Any help is much appreciated! Side note: it would be appreciated if people would not spend their time commenting on other things I could change about my coding, but rather stick to this specific issue. Thank you!
Comment: I haven't tried compiling the code, but aren't you missing a closing brace in the for loop in Inventory::getInventory()?
Comment: I hate to say it but the problem would be more obvious if you lined up your braces. So called Allman style.
Comment: This sort of error is often a clue that something is wrong in the previous function.
Answer: This question will likely be closed as a typo, but I'd like to illustrate a comment from @john that may help you.  (While also answering your question)
 std::string Inventory::getInventory()
 {
     std::string allItems = "";
     int counter = 1;
     for(int i = 0; i < BACKPACK_SIZE; i++)
     {
          if(backpack[i] == nullptr)
          {
             continue;
          }
          else
          {
              allItems += (counter + ".) " + backpack[i]->getName() + "\n");
              counter += 1;
          }

     return allItems;
 }

Your code has been reformatted here so that opening and closing braces are indented to the same level.
You may notice that it's much more apparent that you are getting your error because of a missing brace.
Comment: Wow, I can't believe that I overlooked that. I scanned my code up and down so many times haha. Well thank you for that recommendation; it does indeed make total sense why one should use your format over the format that I was using. Thanks again!

Unidentifiable Class Function Copy


How to add a correlated subquery expression in hook_views_query_alter?

Question: In hook_views_query_alter, how to add a condition which is a correlated subquery in which the value of the condition is an expression?
Given a view the produces this query:
SELECT node.nid, node.title, history.state
FROM node n
LEFT JOIN node_revision nr ON n.vid = nr.vid
INNER JOIN history h ON nr.vid = h.vid
WHERE (( (node.type IN ('blog')) ))

In order to show only the latest [state] for a given version (vid) of a node, we need to add this condition:
AND h.hid = (select max(hid) from history h2
where h2.nid = n.nid
and h2.vid = n.vid group by h.nid, h.vid)

So here's the statement we'd like to end up with after hook_views_query_alter:
SELECT node.nid, node.title, history.state
FROM node n
LEFT JOIN node_revision nr ON n.vid = nr.vid
INNER JOIN history h ON nr.vid = h.vid
WHERE (( (node.type IN ('blog')) ))
AND h.hid = (select max(hid) from history h2
where h2.nid = n.nid
and h2.vid = n.vid
group by h.nid, h.vid)

So we can see that our modified sql works, so here's our attempt (not working) to modify the statement on the fly:
function mymodule_views_query_alter($view, $query) {
  if ($view->name == 'my_view') {
  $expression = '(select max(hid) from
   workbench_moderation_node_history h
   where h.nid = node.nid
   and h.vid = node.vid
   group by h.nid, h.vid)';

  $condition = array();
  $condition['field'] = 'history.hid';
  $condition['value'][] = $expression;
$condition['operator'] = '=';
$query->where[1]['conditions'][] = $condition;
  }
}

This doesn't work (with or without the parenthesis) because the condition is an expression, not a value.  To validate that the syntax of adding a condition is correct, this will at least return results:
function mymodule_views_query_alter($view, $query) {
  if ($view->name == 'my_view') {
    $condition = array();
    $condition['field'] = 'history.hid';
    $condition['value'][] = '1';
    $condition['operator'] = '>';
    $query->where[1]['conditions'][] = $condition;
  }
}

How might we go about coding this constraint?
Answer: This doesn't answer the question as stated, but provides a very simple approach to get at the result using Views without implementing hook_views_query_alter.
The example provided is for workbench_moderation, although the principle applies in other scenarios as well:
Creating a new Workbench view showing recently updated content and its state


passing optional query string parameters to http service call

Question: i need to make an API call which allows me to pass through optional query sting params
 retrieveConts(param1:string,param2?:string):Observable<IContracts> {
  this.basePath =  "/myConts";
      return http.get(this.basePath,{
      params: {
       arg1:param1,
       arg2:param2,
      },
      withCredentials: false
    })
     .catch(this._errorHandler);
  }

With the above code spinet, i have declared param2 as an optional parameter which can or cannot be passed through to the service call, however if param2 gets no value, it then returns undefined for which its understandable.
How do i make the service call to ignore the "arg2" parameter if no value was returned from the param2 variable?
Answer: You can do something like this:
retrieveConts(param1:string,param2?:string):Observable<IContracts> {
    this.basePath =  "/myConts";
    let params = {arg1: param1};
    if (param2)
        params = {arg1: param1, arg2: param2};

    return http.get(this.basePath, {
        params: params,
        withCredentials: false
    })
    .catch(this._errorHandler);
}

Hope this will be helpful!
Answer: instead of passing two values in component, you could pass a object
//Assuming userService is your service
// code in your component
userService.retrieveConts({arg1:"val1",arg2:"val2"})

// Code in userService
retrieveConts(param:any):Observable<IContracts> {
  this.basePath =  "/myConts";
      return http.get(this.basePath,{
      params: param,
      withCredentials: false
    })
     .catch(this._errorHandler);
  }

or you can also check for param2 and append it to object
retrieveConts(param1:string,param2?:string):Observable<IContracts> {
    this.basePath =  "/myConts";
    let params = {arg1: param1};
    if (param2) params.arg2 = param2;

        return http.get(this.basePath, {
            params: params,
            withCredentials: false
        })
        .catch(this._errorHandler);
    }

or pass empty val, if param2 is undefined or null
retrieveConts(param1:string,param2?:string):Observable<IContracts> {
        this.basePath =  "/myConts";

            return http.get(this.basePath, {
                params: {arg1: param1, arg2: param2 || ''},
                withCredentials: false
            })
            .catch(this._errorHandler);
        }

or
  retrieveConts(param1:string,param2?:string=""):Observable<IContracts> {
           this.basePath =  "/myConts";

            return http.get(this.basePath, {
                params: {arg1: param1, arg2: param2},
                withCredentials: false
            })
            .catch(this._errorHandler);
        }

Answer: You can try something like this:
retrieveConts(p1,p2?): Observable<IContracts> {
    this.basePath =  "/myConts";
    let params = {argument1: p1};
    if (p2)
        params = {argument1: p1, argument2: p2};

    return http.get(this.basePath, {
        params: params,
        withCredentials: false
    })
    .catch(this._errorHandler);
 }

Comment: It would be nice if you add some explanation to your code
Answer: Switch to an object definition to shorten your code (other solutions will make it longer) :
retrieveConts(params: { [key: string]: value: string }) {
  return http
    .get('/myConts', {
      params,
      withCredentials: false
    })
    .catch(this._errorHandler);
}

The argument is declared as an object that can has a string key with a string value, and you pass it directly as the params of your URL (properties with the same name don't need to be written twice)
Comment: But from this solution, Am passing more than 7 params, That time some of them are optional, but from this HTTPPARAMS, every time its passing complete params with undefined values.
Answer: I would suggest one minor change:
Instead of:
    this.basePath =  "/myConts";
    let params = {arg1: param1};
    if (param2) params.arg2 = param2;

        return http.get(this.basePath, {
            params: params,
            withCredentials: false
        })
        .catch(this._errorHandler);
    }

I would do:
        this.basePath =  "/myConts";
    let params = {arg1: param1};
    if (param2) params['arg2'] = param2;

        return http.get(this.basePath, {
            params: params,
            withCredentials: false
        })
        .catch(this._errorHandler);
    }

By doing this you will avoid compilation error in Angular for instance.
Answer: You can try something like this:
retrieveConts(param1:string,param2?:string):Observable<IContracts> {
     var params = {arg1:param1};

     if(param2){
         params = Object.assign(params,{arg2:param2})
     }

     this.basePath =  "/myConts";
         return http.get(this.basePath,{
         params: params,
         withCredentials: false
     }).catch(this._errorHandler);
 }


How to use Ansible modules replace or inline instead shell command with SED

Question: i have file with string:
MYAPP.db.username.DEV=MYUSERNAME

Where:
MYAPP mean name of applications
DEV means environment
MYUSERNAME means name of user for connection to db

I need to replace these variables according to variables, that i have in some script.
I am using this:
- name: Replace line
  shell: sed -i "/{{ name_of_app }}.db.username.{{ name_of_environment }}/c\\{{ name_of_app }}.db.username.{{ name_of_environment }}={{ name_of_user_to_db }}" /path/to/my/apps/{{ name_of_app }}/config/{{ name_of_app }}.config

It works fine, but i see warnings in output of ansible
 [WARNING]: Consider using the replace, lineinfile or template module rather
than running sed.  If you need to use command because replace, lineinfile or
template is insufficient you can add warn=False to this command task or set
command_warnings=False in ansible.cfg to get rid of this message.
changed:

I have tried this
- name: Replace line via replace method
  replace:
    dest: "/path/to/my/apps/{{ name_of_app }}/config/{{ name_of_app }}.config"
    regexp: "{{ name_of_app }}.db.username.{{ name_of_environment }}"
    replace: "{{ name_of_app }}.db.username.{{ name_of_environment }}={{ name_of_user_to_db }}"

and this
- name: Replace line via lineinfile method
  lineinfile:
    dest: "/path/to/my/apps/{{ name_of_app }}/config/{{ name_of_app }}.config"
    regexp: "{{ name_of_app }}.db.username.{{ name_of_environment }}"
    line: "{{ name_of_app }}.db.username.{{ name_of_environment }}={{ name_of_user_to_db }}"
    backrefs: yes

each time, i have result with failed:
FAILED! => {"changed": false, "msg": "Unsupported parameters for (replace) module: when Supported parameters include: after, attributes, backup, before, content, delimiter, directory_mode, encoding, follow, force, group, mode, owner, path, regexp, remote_src, replace, selevel, serole, setype, seuser, src, unsafe_writes, validate"}

Can you help me, where i have error in my playbook ?
Answer: The replace and the lineinfile use the path parameter to mark

The file to modify.
  lineinfile module is used to
ensure[s] a particular line is in a file, or [to] replace an existing line using a back-referenced regular expression.

Use

the replace module if you want to change multiple, similar lines

I believe the dest parameter is used for modules creating new files like template or copy.
Just replace dest with path and both provided examples should work as expected.
Comment: I think this is the right answer. The official doco indicates `dest` is an alias for `path` in both modules, but I am not surprised it is not working in this case.
Comment: Ansible changed this behaviour with version `2.3` (released 2017) This answer might be out of date by now.


Does the Euler characteristic of a manifold depend upon the field of coefficients?

Question: Define the Euler characteristic of a space $X$ to be $$\chi(X)= \sum_i \dim H_i(X, \mathbb Q)$$ This is obviously not necessarily well-defined for an arbitrary space $X$, so let $X$ be a manifold (manifolds have only finitely many nonzero homology groups, and each homology group is finitely generated). I would prefer to keep this question entirely in the realm of closed manifolds.
There's an obvious restatement of this for $\Bbb Q$ replaced by another field $F$, so let $$\chi(M,F) = \sum_i \dim H_i(M, F)$$
Question: When does $\chi(M)=\chi(M,F)$ for all fields $F$? This is true for every finite CW-complex $M$, but it is my impression that not every closed manifold is a finite CW-complex, though I don't have a counter-example. If this is the case (again, for closed manifolds), what is a reference for this fact? If it's false, the question stands. Does the Euler characteristic depend on the field? I'm hoping for either a reference or a counter example.
Edit: The question was resolved below for smooth manifolds via Morse theory, but as far as I can tell this argument is not generally extendable to the topological case (see: Morse theory in TOP and PL categories?). Hopefully there's a known fully topological answer.
Comment: Morse theory contains the fact that every closed manifold has the homotopy type of a finite CW complex.
Comment: Independence of the field also follows from using the Mayer-Vietoris spectral sequence for a good cover, so if you can tell that all topological manifolds have such a cover, you are done: see http://mathoverflow.net/questions/165850/good-covers-of-manifolds
Comment: The singular complex and simplicial complexes are different things! The first is a complex of abelian groups, the others are obtained by glueing geometric simplices. Not even in the same ballback :P
Comment: @MarianoSuárez-Alvarez Your link states that every simplicial complex has a good cover. Since the homology can be computed from the singular complex (which according to that question has a good cover) are we not done? The Euler characteristic of the singular complex is invariant under base change so the Euler characteristic of $M$ is invariant under base change.
Answer: Every topological compact manifold can be embedded into $\mathbb{R}^{n}$ and since it is locally contractible it follows that it is an Euclidean Neighbourhood Retract. The proofs are elementary.
It follows that it is a retract of a finite simplicial complex and so its integral homology groups are finitely generated. This is enough to ensure that the Euler characteristic is independant from the field of coefficients (for example by universal coefficient theorem).
For references, see Appendix A of Hatcher's "Algebraic Topology", in particular Corollary A.8 and Corollary A.9.
Comment: Just to add: Every compact ANR (e.g. a compact topological manifold) manifold is homotopy-equivalent to a finite CW complex. This is known as "Borsuk conjecture" (proven in 1970s).
Comment: Yes, this does it. I should have thought of this. Thank you very much!
Answer: Every closed manifold is homotopy equivalent to a finite CW-complex. For a proof see Milnor's book Morse Theory in the section titled "Homotopy Type" (pg. 12 in the ancient edition I have).
(The statement of this is a remark at the end of part 1 section 3)
Comment: This answers the question for the smooth case (or at least $C^2$, but these are, afaik, equivalent). Do you know a reference for the topological case?