In javascript you can print the call stack with something like this:
function print_call_stack() {
var stack = new Error().stack;
console.log("PRINTING CALL STACK");
console.log( stack );
}
A Log of Coding Solutions
by Webhead
In javascript you can print the call stack with something like this:
function print_call_stack() {
var stack = new Error().stack;
console.log("PRINTING CALL STACK");
console.log( stack );
}
by Webhead
Normally code in the resize event is meant to just run once when the user is done resizing. This code below, from css-tricks and seen elsewhere will do the trick:
var resizeTimer;
$(window).on('resize', function(e) {
clearTimeout(resizeTimer);
resizeTimer = setTimeout(function() {
// Run code here, resizing has "stopped"
}, 250);
});
by Webhead
I’m using PHPUnit 5.5, upgraded my PHP version to 7.2. Two problems actually occur. First there’s this weird error:
Fatal error: Declaration of SebastianBergmann\Comparator\DOMNodeComparator::assertEquals…
Then figuring PHPUnit needs to be upgraded, I ran
phpunit –self-upgrade
And that failed with the same error. Changing my PHP version back down to 5.6 and running then causes this error:
internal corruption of phar “…phpunit-temp.phar” (truncated entry)
Unfortunately PHPUnit 5.5 only supports up to version 7.1 and any old version of PHPUnit that has an “old” certificate needs to be downloaded/updated manually.
https://github.com/sebastianbergmann/phpunit/issues/1688
by Webhead
I’ve been trying like crazy to get to my local website at site.dev, but I keep getting redirected to https://site.dev and of course it doesn’t work because I don’t have a SSL certificate for that domain.
As of December 2017, Chrome 63, Chrome is forcing all .dev domains to be redirected to HTTPS via a preloaded HTTP Strict Transport Security (HSTS) header. The .dev TLD is an actual legitimate TLD so you will need to change your local development setup to use something like http://site.localhost .
A more detailed explanation can be found here:
https://ma.ttias.be/chrome-force-dev-domains-https-via-preloaded-hsts/
by Webhead
IE 10 shows a skewed svg image who’s width is set to a specific value and height is auto.
The problem is the width and height in the SVG file is set and IE is following those specs if you don’t set it. So if you’re image is 100×100 and you set only the width to 50px, the height will remain at 100px. The solution is to remove the width and height attributes in the <svg> tag.
A solution on a github gist suggests that removing the width and height attributes force the image to occupy the full width of its container in non-IE browers. All my current images with SVG are supposed to fill the width so this isn’t a problem for me.
Link to the gist: https://gist.github.com/larrybotha/7881691
by Webhead
When running wpdb->insert the result returns false. All the values seem to check out to be fine.
The problem might be due to this bug in WordPress. Basically one of your fields is too long and WordPress is not completing the insert. Reading through the ticket, it seems it is a WordPress error and not a MySql error so it would be pretty difficult to go through all the fields, determine the column field size limits, and then return an error of some sort. Anyway, this is one possible reason to wpdb->insert returning false.