Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View mike-zarandona's full-sized avatar

Mike Zarandona mike-zarandona

View GitHub Profile
@mike-zarandona
mike-zarandona / commands.js
Created April 5, 2019 19:35
Cypress custom command to check if an element is in the viewport
Cypress.Commands.add('shouldBeInViewport', { prevSubject: true }, subject => {
cy.document().then(doc => {
let clientHeight = doc.documentElement.clientHeight
let viewportTop = doc.documentElement.scrollTop
let viewportBottom = viewportTop + clientHeight
let subjectTop = subject[0].offsetTop
cy.expect(subjectTop).to.be.at.least(viewportTop)
cy.expect(subjectTop).to.be.at.most(viewportBottom)
})
@mike-zarandona
mike-zarandona / coolers-shades.js
Last active November 5, 2018 15:54
A tiny script which can be pasted into the console at https://coolers.co to create a listing of all the generated color shades.
let allColors = [[], [], [], [], []]
$('.palette-shades-row').each((i, thisRow) => {
$(thisRow)
.find('.palette-shades-col')
.each((j, thisCol) => {
allColors[j].push('#' + $(thisCol).data('color'))
})
})
@mike-zarandona
mike-zarandona / editor-style.css
Created June 2, 2017 14:23 — forked from vielhuber/editor-style.css
TinyMCE Advanced Custom Formats / Styles / Shortcode Buttons
/* step 1: load this in editor-style.css in the theme folder */
/* step 2: activate function "Create CSS classes menu" in tinymce advanced */
/* this gets shown automatically in the formats dropdown */
.MY-CUSTOM-CLASS {
background-color:red;
}
@mike-zarandona
mike-zarandona / For Sandwiches
Last active May 8, 2017 13:57
for_sandwiches.js?
for { sandwiches
while lettuce => 0
return true; }
else (return vicky);
@mike-zarandona
mike-zarandona / RetinaMixin3.less
Last active August 29, 2015 14:11
Retina LESS Mixin v3 - now makes it super easy to specify one background image to cover three image sizes (@1x|@2x|@3x).
.retina3(@bg-image, @size: cover, @file-type: 'png'){
background-image: url('@{path}@{bg-image}.@{file-type}');
background-size: @size;
@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (min--moz-device-pixel-ratio: 1.5),
only screen and (min-device-pixel-ratio: 1.5) {
background-image: url('@{path}@{bg-image}@2x.@{file-type}');
background-size: @size;
@mike-zarandona
mike-zarandona / BlurMixin.less
Created December 5, 2014 15:50
A LESS mixin to apply CSS3 blurs to elements.
.blur(@blur) {
filter: blur(@blur);
-webkit-filter: blur(@blur);
}
@mike-zarandona
mike-zarandona / BX-Slider Logo Ticker.html
Created October 16, 2014 15:58
Responsive ticker-style display drop-in using BX-Slider (http://bxslider.com/).
<section class="logos-bar">
<div class="width-container">
<ul class="logos">
<li>
<div><a href="javascript:void(0)"><img src="path/to/logo.png" alt="thumbnail logo" /></div></a>
</li>
<li>
<div><a href="javascript:void(0)"><img src="path/to/logo.png" alt="thumbnail logo" /></div></a>
</li>
<li>
@mike-zarandona
mike-zarandona / Strip Off Any Protocol from a URL.js
Created October 15, 2014 18:27
A tiny bit of logic to strip off any protocol from a URL.
// strip off the protocol
url = 'http://twitter.com/mikezarandona';
if ( url.indexOf('://') != -1 ) {
url = url.substr( url.indexOf('://') + 3 );
}
@mike-zarandona
mike-zarandona / getURLParameter.js
Last active August 29, 2015 14:07
Function to check for and return the values of URL parameters.
// Get URL parameters
function getURLParameter(name) {
name = name.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)",
regex = new RegExp( regexS ),
results = regex.exec( window.location.href )
;
if( results === null ) {
@mike-zarandona
mike-zarandona / Statamic-Admin-iOS-Install-as-WebApp
Created October 12, 2014 09:11
Two `<meta/>` tags and a `<script/>` tag to allow iOS users to use the "Add to Home Screen" function in Mobile Safari. This is convenient in maximizing screen real estate when composing in `/admin`. This is a modification to `/admin/themes/ascent/layouts/default.php`
<?php
$current_user = Auth::getCurrentMember();
$name = $current_user->get('name');
?><!doctype html>
<html lang="<?php echo Config::getCurrentLanguage(); ?>">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0">
<title>Statamic Control Panel</title>
<link rel="stylesheet" href="<?php echo Path::tidy(Config::getSiteRoot().'/'.$app->config['theme_path']) ?>css/ascent.min.css">