Skip to content

Instantly share code, notes, and snippets.

View Volker-E's full-sized avatar

Volker E. Volker-E

View GitHub Profile
@Volker-E
Volker-E / bash
Created March 30, 2020 20:41
OOUI loc
# 50k+ Ruby tests autogenerated './tests/JSPHP-suite.json' is still part of results
grunt clean && rm -rf vendor/ node_modules/ package-lock.json composer.lock && find . \( -name '*.*' ! -iname '.*' \) -not -path './i18n/*' -not -path './.git/*' | xargs wc -l
$languages = pll_the_languages( array( 'raw' => 1 ) );
$current = array_filter( $languages, create_function( '$v', 'return (bool) $v["current_lang"];' ) );
$current = reset( $current );
printf( '<ul id="nav--lang__menu" class="nav--lang__menu">
<li>
<a href="#" class="lang--on lang-item--%s">%s</a>
<ul class="lang__sel">',
$current['slug'], $current['name'] );
// Taken from https://justmarkup.com/log/2015/02/26/cut-the-mustard-revisited
if('querySelector' in document
&& 'localStorage' in window
&& 'addEventListener' in window) {
// Modern browser. Let's add JavaScript functionality
}

Pure SASS-adaption of Lea Verou's contrast-ratio javascript. Can be useful when eg. generating colored buttons from a single supplied color as you can then check which out of a couple of text colors would give the best contrast.

This script currently lacks the support for alpha-transparency that Lea supports in her script though.

In addition to the color-contrast adaption there's also some math methods that were needed to be able to calculate the exponent of a number and especially so when the exponent is a decimal number. A 2.4 exponent is used to calculate the luminance of a color and calculating such a thing is not something that SASS supports out of the box and not something I found a good pure-SASS script for calculating and I much prefer pure-SASS over ruby extensions. The math methods might perhaps be unecessary though if you're running Compass or similar as they may provide compatible math methods themselves.

Normal usage: `color: pick_best_color(#f00

@Volker-E
Volker-E / is_blog.php
Last active August 29, 2015 14:14 — forked from jjeaton/is_blog.php
/**
* WordPress' missing is_blog() function. Determines if the currently viewed page is
* one of the blog pages, including the blog home page, archive, category/tag, author, or single
* post pages.
*
* Doesn't include is_search(), if you only use search for the blog, then add that in or test separately
*
* @props grantnorwood @wesbos @toscho @jjeaton
* @return bool
*/
// added 2014-10-30, taken from http://toddmotto.com/mastering-svg-use-for-a-retina-web-fallbacks-with-png-script/
function supportsSVG() {
return !! document.createElementNS && !! document.createElementNS('http://www.w3.org/2000/svg','svg').createSVGRect;
}
if (supportsSVG()) {
document.documentElement.className += ' svg';
} else {
document.documentElement.className += ' svg-off';
var imgs = document.getElementsByTagName('img');
var dotSVG = /.*\.svg$/;
@Volker-E
Volker-E / CSS-target-selector.css
Created June 3, 2014 15:06
CSS :target selector for changing design on internal link
#g:target body {
columns: 15em;
column-gap: 0;
}
@Volker-E
Volker-E / CSS-box-shadow-at-page-top.css
Last active August 29, 2015 14:02
CSS Box-Shadow at top of page
body:before {
content: "";
position: fixed;
top: -10px;
left: 0;
width: 100%;
height: 10px;
-webkit-box-shadow: 0 0 10px rgba( 0, 0, 0, .8 );
-moz-box-shadow: 0 0 10px rgba( 0, 0, 0, .8 );
box-shadow: 0 0 10px rgba( 0, 0, 0, .8 );
@Volker-E
Volker-E / CSS-3D-emboss-text-shadow.css
Created May 19, 2014 12:23
Extra-3D-emboss-text-shadow (reveal.js)
.text-embossed {
text-shadow: 0 1px 0 #CCCCCC, 0 2px 0 #C9C9C9, 0 3px 0 #BBBBBB, 0 4px 0 #B9B9B9, 0 5px 0 #AAAAAA, 0 6px 1px rgba(0, 0, 0, 0.1), 0 0 5px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.3), 0 3px 5px rgba(0, 0, 0, 0.2), 0 5px 10px rgba(0, 0, 0, 0.25), 0 20px 20px rgba(0, 0, 0, 0.15);
}