This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
this is the Netlify on-demand builder described here: | |
https://www.leereamsnyder.com/blog/dynamic-social-media-images-with-puppeteer-and-netlify | |
but updated to work with puppeteer 10 | |
See that article for setup on netlify, including redirects and meta tags | |
The builder code in linked article was written for puppeteer 8 | |
and things didn't work after I updated to version 10 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Usage: | |
var jsoncheck = require('./wantsJSON') // path to file with this middleware function | |
app.use(jsoncheck) | |
app.get('/', function(req,res,next){ | |
if (req.wantsJSON) { | |
// serve JSON | |
} | |
if (req.wantsHTML) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
**UPDATE**: This was fixed in iOS 8. But this could still be valid for iOS 7 and below. | |
I believe this was first noticed here: http://blog.b123400.net/window-scrollto-and-ios-status-bar/ | |
> When the status bar is tapped, the page scrolls to the top and url bar is shown, | |
> then window.scrollTo doesn't work anymore. | |
Yep! | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Let's say you want to support BOTH post excerpts and use of the <!--more--> tag | |
* to truncate post content in The Loop. | |
* | |
* And let's also say that you definitely do not want to show the full content of the post | |
* if either of those are absent. Maybe you're displaying posts in little Pinterest-y | |
* cards so the text/excerpt can't be too long. | |
* | |
* Let's say this is your priority: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
Re-use some existing WordPress functions so you don't have to write a bunch of raw PHP to check for SSL, port numbers, etc | |
Place in your functions.php (or re-use in a plugin) | |
If you absolutely don't need or want any query string, use home_url(add_query_arg(array(),$wp->request)); | |
Hat tip to: | |
+ http://kovshenin.com/2012/current-url-in-wordpress/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(function($, window, document, undefined){ | |
/* :focusable and :tabbable selectors from | |
https://raw.github.com/jquery/jquery-ui/master/ui/jquery.ui.core.js */ | |
function visible(element) { | |
return $.expr.filters.visible(element) && !$(element).parents().addBack().filter(function () { | |
return $.css(this, "visibility") === "hidden"; | |
}).length; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*********************************** | |
Little utility function for handling single transitionEnd events. | |
Particularly handy for when you need to remove something from | |
the DOM after transforming it with an animation | |
WHY NOT $el.one('transitionend', callback) ???? | |
============================================= |