jQuery - Create hidden form element on the fly

Source: https://stackoverflow.com/questions/2408043/jquery-create-hidden-form-element-on-the-fly

$('<input>').attr('type','hidden').appendTo('form');
To answer your second question:
$('<input>').attr({
    type: 'hidden',
    id: 'foo',
    name: 'bar'
}).appendTo('form');
The same as David's, but without attr()
$('<input>', {
    type: 'hidden',
    id: 'foo',
    name: 'foo',
    value: 'bar'
}).appendTo('form');

Express: Forever run app

Source: https://stackoverflow.com/questions/24072812/forever-node-js-express-4

Try this:
forever start ./bin/www
Let's take a look to package.json:
"scripts": {
    "start": "node ./bin/www"
},
I guess when we call npm start./bin/www will be executed at some point. Then look at the content of./bin/www:
var server = app.listen(app.get('port'), function() {
  debug('Express server listening on port ' + server.address().port);
});
so we are ready to listen for connections.

Express Application: How do I handle 404 responses?

Source: https://expressjs.com/en/starter/faq.html

In Express, 404 responses are not the result of an error, so the error-handler middleware will not capture them. This behavior is because a 404 response simply indicates the absence of additional work to do; in other words, Express has executed all middleware functions and routes, and found that none of them responded. All you need to do is add a middleware function at the very bottom of the stack (below all other functions) to handle a 404 response:
app.use(function (req, res, next) {
  res.status(404).send("Sorry can't find that!")
})
Add routes dynamically at runtime on an instance of express.Router() so the routes are not superseded by a middleware function.

jQuery change div background-image with fadeIn/Out

Source: https://stackoverflow.com/questions/8610973/jquery-change-div-background-image-with-fadein-out

This was the only reasonable thing I found to fade a background image.
<div id="foo">
  <!-- some content here -->
</div>
Your CSS; now enhanced with CSS3 transition.
#foo {
  background-image: url('a.jpg');
  transition: background 1s linear;
}
Now swap out the background
$("#foo").css("background-image", "url(b.jpg)");
Or do it with native javascript
document.querySelector("#foo").style.backgroundImage = "url(b.jpg)";
Voilà, it fades!

Obvious disclaimer: if your browser doesn't support the CSS3 transition property, this won't work.

Merge Branch into Master

Source: https://stackabuse.com/git-merge-branch-into-master/
https://stackoverflow.com/questions/5601931/what-is-the-best-and-safest-way-to-merge-a-git-branch-into-master

This is a very practical question, but all the answers above are not practical.
Like
git checkout master
git pull origin master
git merge test
git push origin master
This approach has two issues:
  1. It's unsafe, because we don't know if there are any conflicts between test branch and master branch.
  2. It would "squeeze" all test commits into one merge commit on master; that is to say on master branch, we can't see the all change logs of test branch.
So, when we suspect there would some conflicts, we can have following git operations:
git checkout test
git pull 
git checkout master
git pull
git merge --no-ff --no-commit test
Test merge before commit, avoid a fast-forward commit by --no-ff,
If conflict is encountered, we can run git status to check details about the conflicts and try to solve
git status
Once we solve the conflicts, or if there is no conflict, we commit and push them
git commit -m 'merge test branch'
git push
But this way will lose the changes history logged in test branch, and it would make master branch to be hard for other developers to understand the history of the project.
So the best method is we have to use rebase instead of merge (suppose, when in this time, we have solved the branch conflicts).
Following is one simple sample, for advanced operations, please refer to http://git-scm.com/book/en/v2/Git-Branching-Rebasing
git checkout master
git pull
git checkout test
git pull
git rebase -i master
git checkout master
git merge test
Yep, when you have uppers done, all the Test branch's commits will be moved onto the head of Master branch. The major benefit of rebasing is that you get a linear and much cleaner project history.
The only thing you need to avoid is: never use rebase on public branch, like master branch.
Never do operations like the following:
git checkout master
git rebase -i test
appendix:
To summarize, here are the commands to create a new branch, make some commits, and merge it back into master:
$ git checkout master
$ git branch new-branch
$ git checkout new-branch

# ...develop some code...

$ git add –A
$ git commit –m "Some commit message"
$ git checkout master
$ git merge new-branch

Job name “..getProjectMetadata” does not exist

Source: https://stackoverflow.com/questions/59447679/an-unhandled-exception-occurred-job-name-getprojectmetadata-does-not-exist

I had this error after npm audit found vulnerabilities in the version of @angular-devkit/build-angular that I was using. I ran npm audit fix which updated it to 0.900.2, but when I ran ng serve it gave the error quoted in the question.
I resolved it by downgrading to version 0.803.25. This was the highest version I could find which did not cause any errors when running ng serve. The vulnerabilities found by npm audit are resolved in this version.
This is the command I ran:
npm i @angular-devkit/build-angular@0.803.25

Multiple recaptcha same page

Source: https://www.okler.net/forums/topic/multiple-recaptcha-same-page/

<script src="https://www.google.com/recaptcha/api.js?onload=CaptchaCallback&render=explicit" async defer></script>
<script type="text/javascript">
    var CaptchaCallback = function() {
        grecaptcha.render('g-recaptcha1', {'sitekey' : 'YOUR_API_KEY'});
        grecaptcha.render('g-recaptcha2', {'sitekey' : 'YOUR_API_KEY'});
    };
</script>

Can't bind to 'aria-valuenow' since it isn't a known property of 'div'

Source: https://stackoverflow.com/questions/39161088/cant-bind-to-aria-valuenow-since-it-isnt-a-known-property-of-div


Angular2 binding is property binding by default. There is no aria-valuenow property on div if there is no directive or component applied that has such an @Input()
Use instead explicit attribute binding
attr.aria-valuenow="{{MY_PREC}}" 
or
[attr.aria-valuenow]="MY_PREC" 

Call static function from angular template

Source: https://stackoverflow.com/questions/41857047/call-static-function-from-angular2-template

Only instance members of the components class can be called from the view.
If you want to call static members, you need to provide a getter in the component.
export class MyComponent {
  parseDate = DateService.parseDate;
}
then you can use it like
(input)="event.date=parseDate($event.target.value)"
You can declare a field in your component that will make the class accessible for your template.
export class YourComponent {
    public DateService= DateService;
}

Renewing Facebook Graph API token automatically?

  Mã truy cập dài hạn https://developers.facebook.com/docs/facebook-login/guides/access-tokens/get-long-lived/ https://community.n8n.io/t/re...