(() => { | |
let count = 0; | |
function getAllButtons() { | |
return document.querySelectorAll('button.is-following') || []; | |
} | |
async function unfollowAll() { | |
const buttons = getAllButtons(); |
let regex = /^\([1-9]{2}\) 9 [7-9][0-9]{3}\-[0-9]{4}$/; | |
if( regex.test(c.value) ) { | |
return null; | |
} else { | |
return { phoneError: true }; | |
} |
Adaptação do fork: (https://gist.github.com/ljharb/58faf1cfcb4e6808f74aae4ef7944cff)
Ao tentar explicar como o Javascript usa seu métodos para arrays, acabei reunindo esses conceitos. Espero que Seja util. Ficarei feliz com qualquer sugestão.
O Objet Array no Javascript tem muitos métodos construidos no seu prototype. Alguns deles modificam o proprio array passado. Felizmente, a maioria não, eles retonar um novo array inteiramente distinto. Uma vez que arrays são conceitualmente uma lista de itens, ajuda na clareza do código e sua manutenção a ponto de ser capas de operar de uma forma mais "funcional" . (Eu insisto em refrenciar um array como uma "Lista" - embora em algumas linguaguens de programação, Lista
é um tipo de dado nativo, mais em JS e nesse POST, estou me referindo ao conceito. Em todos os lugares que eu usar a palavra "lista" você pode assumir que eu estou falando de JS Array) Isso siginifica, para a execução de uma simples operação na Lista como um
import csv | |
import re | |
from os import listdir | |
from os.path import isfile, join | |
def main(): | |
folder = './logs' | |
onlyfiles = [f for f in listdir(folder) if isfile(join(folder, f))] | |
log_files = filter( |
@function random-image ($width: 400, $height: null) { | |
$height: if($height, $height, $width); | |
$size: $width + "/" + $height; | |
$src: "https://unsplash.it/" + $size + "/?random=" + random(); | |
@return url($src); | |
} |
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.
Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.
elem.offsetLeft
,elem.offsetTop
,elem.offsetWidth
,elem.offsetHeight
,elem.offsetParent
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel"> | |
<ol class="carousel-indicators"> | |
<?php | |
$args = array( | |
'post_type' => 'slides1', | |
'orderby' => 'menu_order title', | |
'order' => 'ASC', | |
); | |
$query = new WP_Query( $args ); |
<?php | |
// Insert into your functions.php and have fun by creating login error msgs | |
function guwp_error_msgs() { | |
// insert how many msgs you want as array items. it will be shown randomly (html is allowed) | |
$custom_error_msgs = [ | |
'<strong>YOU</strong> SHALL NOT PASS!', | |
'<strong>HEY!</strong> GET OUT OF HERE!', | |
]; | |
// get and returns a random array item to show as the error msg | |
return $custom_error_msgs[array_rand($custom_error_msgs)]; |