/(\d{1,2}\% \d{1,2}\%)/g
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 getImageBrightness(imageSrc, callback) { | |
var img = document.createElement('img'), | |
colorSum = 0, | |
i = 0, | |
len, | |
canvas, | |
ctx, | |
imageData, | |
data, | |
brightness, |
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
const not = { | |
inert: ':not([inert]):not([inert] *)', | |
negTabIndex: ':not([tabindex^="-"])', | |
disabled: ':not(:disabled)', | |
} | |
export const FOCUSABLE_SELECTORS = [ | |
`a[href]${not.inert}${not.negTabIndex}`, | |
`area[href]${not.inert}${not.negTabIndex}`, | |
`input:not([type="hidden"]):not([type="radio"])${not.inert}${not.negTabIndex}${not.disabled}`, |
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
name: Build and deploy | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
jobs: | |
build: |
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
export function debounce (fn, wait = 1) { | |
let timeout | |
return function (...args) { | |
clearTimeout(timeout) | |
timeout = setTimeout(() => fn.call(this, ...args), wait) | |
} | |
} |
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 getWeekNumber(d) { | |
d = new Date(+d) // Copy date so don't modify original. | |
d.setHours(0, 0, 0, 0) // Reset hours. | |
d.setDate(d.getDate() + 4 - (d.getDay() || 7)) // Set to nearest Thursday: current date + 4 - current day number and make Sunday's day number 7 | |
var yearStart = new Date(d.getFullYear(), 0, 1) // Get first day of year | |
var weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7) // Calculate full weeks to nearest Thursday | |
return weekNo // Return week number | |
} | |
var date = new Date() |
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
// console.log(getTextLines(querySelector('span'))) | |
// returns number of lines | |
function collapseWhiteSpace(value) { | |
return value.trim().replace(/\s+/g, ' ') | |
} | |
function getTextLines(textNode) { | |
if (textNode.nodeType !== 3) { | |
return false // Only text nodes allowed |
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
const warnAbout = [ | |
{ | |
id: 'single_quote_notice', | |
needle: '"', | |
haystack: 'text', | |
message: "Content includes simple quotation marks: '. Did you mean ’ ?", | |
dispatched: false, | |
}, | |
{ | |
id: 'double_quote_notice', |
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 | |
/** | |
* Limit image srcset width | |
* @link https://developer.wordpress.org/reference/hooks/max_srcset_image_width/ | |
*/ | |
function limit_image_srcset_width( $max_width = 2048, $size_array = [] ) { | |
$saveData = (isset($_SERVER["HTTP_SAVE_DATA"]) && stristr($_SERVER["HTTP_SAVE_DATA"], "on") !== false) ? true : false; | |
return $saveData ? 652 : $max_width; | |
} |
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
import React from 'react' | |
import { Animated } from 'react-native' | |
import Canvas, { Image as CanvasImage } from 'react-native-canvas' | |
const TransparentImage = ({ source, width, height, backgroundColor }) => { | |
const fadeAnim = React.useRef(new Animated.Value(0)).current | |
return ( | |
<Animated.View | |
style={{ |
NewerOlder