Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env node
console.log('Olá mundo2!')
@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).

@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
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 / logcat
Created April 3, 2019 13:37
Android 7.1.2 Google Pixel XL in AWS Device Farm
--------- beginning of main
04-02 11:02:32.310 5549 7959 I PTCommittedOperation: Receive new configuration for com.google.android.gms.magictether
04-02 11:02:32.341 5549 7679 E MagicTether: [MagicTetherInitializer] Invalid account list.
04-02 11:02:32.398 5581 7947 W ModuleInitIntentOp: Dropping unexpected action com.google.android.gms.phenotype.COMMITTED
04-02 11:02:32.402 5549 8068 I PTCommittedOperation: Receive new configuration for com.google.android.metrics
04-02 11:02:32.438 5549 7170 E MagicTether: [TetherListenerService] Invalid account list.
04-02 11:02:32.511 5581 7946 W ModuleInitIntentOp: Dropping unexpected action com.google.android.gms.phenotype.COMMITTED
04-02 11:02:32.518 5549 8068 I PTCommittedOperation: Receive new configuration for com.google.android.gms.walletp2p#config
04-02 11:02:32.598 5581 8028 W ModuleInitIntentOp: Dropping unexpected action com.google.android.gms.phenotype.COMMITTED
04-02 11:02:32.648 5549 8228 I PTCommittedOperation: Receive new configuration for
@ricardobrg
ricardobrg / checkboxes.js
Last active December 2, 2018 12:59
jQuery checkboxes handling based on ids and classes with indeterminate property
jQuery(document).ready(function($){
$(":checkbox").click(function(){
let isChecked = $(this).prop('checked');
let id = $(this)[0].id;
let itemClasses = $(this).attr('class');
if (id != undefined && id != ""){
$("."+id).prop('checked',isChecked);
}
if (!isChecked){
if (itemClasses != undefined){
@ricardobrg
ricardobrg / fixed.js
Last active October 29, 2018 08:50
fixed sidebar with variable height
var fixed = false;
var sidebarTop = jQuery('#secondary').offset().top;
var sidebarHeight = jQuery('#secondary').height();
var windowHeight = jQuery(window).height();
var leftHeight = jQuery('.left-content-area').height();
if (windowHeight < sidebarHeight){
startPosition = sidebarTop + sidebarHeight - windowHeight;
fixPosition = windowHeight - sidebarHeight;
endPosition = leftHeight + sidebarTop - windowHeight;
}else{
@ricardobrg
ricardobrg / main.dart
Created August 7, 2018 06:58
Flutter app exit error
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
@ricardobrg
ricardobrg / maxlength.html
Created June 6, 2018 03:06
input number maxlength with javascript oninput
<input type="number" step="1" min="1" max="999" maxlength="3" name="number" inputmode="numeric" oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);">
@ricardobrg
ricardobrg / enqueue.php
Last active July 18, 2023 09:11
Enqueue scripts in WordPress with defer or async
<?php
// This code is based in Mathew Horne blog post: https://matthewhorne.me/defer-async-wordpress-scripts/
//function to add async attribute
function add_async_attribute($tag, $handle) {
$scripts_to_async = array('my-js-handle-async', 'another-handle-async');
//check if this script is in the array
if (in_array($handle, $scripts_to_async)){
//return with async
return str_replace(' src', ' async="async" src', $tag);