Skip to content

Instantly share code, notes, and snippets.

@scottjehl
scottjehl / whichones.js
Created August 21, 2020 15:40
which elements are wider than the viewport?
View whichones.js
var list = [];
document.querySelectorAll("body *")
.forEach(function(elem){
if(elem.getBoundingClientRect().width > document.body.getBoundingClientRect().width){
list.push(elem.outerHTML.split('>')[0] + '>');
}
});
confirm( "these elements are wider than the viewport:\n\n " + list.join("\n") )
@samhernandez
samhernandez / haxor.twig
Last active December 2, 2022 21:40
Craft 3 gain access to admin account for support cases or when owner loses access
View haxor.twig
{#
Resets the username, password, and email address
of the first found Admin account in case of
lost admin access or for support cases.
#}
{% set values = {
username: 'me',
password: craft.app.security.hashPassword('mypassword'),
email: 'me@site.com',
passwordResetRequired: 0
@watershed
watershed / dateTimeMacro.twig
Last active July 2, 2021 10:31
CraftCMS datetime macro
View dateTimeMacro.twig
{#
value : date and/or time value validated as not null (mandatory),
format : php date format string (mandatory),
options: {
prefix: string to append to processed format,
suffix: string to append to processed format,
tag : html tagname string,
html : markup, typically to be wrapped in a <time> element,
attr : hash of name:value attribute pairs
}
@bjmiller121
bjmiller121 / iframe_defer.js
Created January 30, 2015 19:45
Defer loading of iframes
View iframe_defer.js
/**
* Defer iframe loading.
*
* Markup:
* <div class="defer-iframe" data-src="{SOURCE URL}" data-{ATTR}="{VAL}"></div>
*/
$(window).load( function(){
if ($('.defer-iframe').length) {
$('.defer-iframe').each( function() {
var $iframe = $('<iframe frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>');
@serrynaimo
serrynaimo / gist:faeec7f3c1d55e300fa1
Last active March 29, 2016 08:45
Interesting UX resources
View gist:faeec7f3c1d55e300fa1