Skip to content

Instantly share code, notes, and snippets.

function is_happening_now(talk) {
// take talk.datetime in ms from epoch
let talkTime = new Date(talk.datetime).getTime();
// calculate talkend in ms from epoch
let talkEnd = talkTime + (talk.duration * 60000);
// take current epoch time in browser`s timezone
let now = new Date().getTime();
// Return boolean true if talk is happening now or false.
return now > talkTime && now < talkEnd;
}
@ricardobrg
ricardobrg / price_qtd.php
Created January 27, 2020 21:06
Woocommerce price quantities
add_filter( 'woocommerce_get_price_html', 'wb_change_product_html' );
// Change and return $price_html variable using the $price and weight amount
function wb_change_product_html( $price ) {
$price_html = '<span class="amount">' . $price . ' per kg </span>'; // change weight measurement here
return $price_html;
}
add_filter( 'woocommerce_cart_item_price', 'wb_change_product_price_cart' );
// Change the cart prices with $price variable and weight amount
@ricardobrg
ricardobrg / post.md
Created March 12, 2020 23:03 — forked from vinicius73/post.md
["LÓGICA DE PROGRAMAÇÃO" É BOBAGEM, e explicarei porquê.]

#["LÓGICA DE PROGRAMAÇÃO" É BOBAGEM, e explicarei porquê.]

Se preparem que o texto é longo.

Várias vezes chegam novatos aqui perguntando como começar, e a galera diz "estuda lógica primeiro, depois vai pra linguagem X". Vivo dizendo que é bobagem. Ontem, em particular, falei isso, e vieram várias pessoas por inbox me perguntar porquê (e uma pra me xingar, achando que falei por arrogância).

Pra facilitar, eu vou escrever uma boa explicação de porquê "lógica de programação" é furada, doa a quem doer, e postar na APDA e no fórum da EnergyLabs (para futuras referências, porque esse assunto vai voltar, ctz).

#!/usr/bin/env node
console.log('Olá mundo2!')