Skip to content

Instantly share code, notes, and snippets.

View carmolim's full-sized avatar

Augusto Carmo carmolim

View GitHub Profile
#include "OneWire/OneWire.h"
#include "MQTT/MQTT.h"
// ONE WIRE
OneWire one = OneWire(D0);
uint8_t rom[8];
uint8_t resp[9];
// AVERAGE TEMPERATURE
const int temperatureManySamples = 5;
@carmolim
carmolim / configuration
Last active April 22, 2016 13:49
My last configuration.yaml file for my Home Assistant setup (HA, HASS)
homeassistant:
# Name of the location where Home Assistant is running
name: Home
# Location required to calculate the time the sun rises and sets
latitude: ******
longitude: ******
# C for Celcius, F for Fahrenheit
temperature_unit: C
# Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
time_zone: America/Sao_Paulo
@carmolim
carmolim / 0_reuse_code.js
Created July 7, 2016 20:17
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@carmolim
carmolim / deleta_produtos.sql
Last active January 7, 2025 17:52
Deletar todos os produtos do woocommerce via SQL
DELETE relations.*, taxes.*, terms.*
FROM wp_term_relationships AS relations
INNER JOIN wp_term_taxonomy AS taxes
ON relations.term_taxonomy_id=taxes.term_taxonomy_id
INNER JOIN wp_terms AS terms
ON taxes.term_id=terms.term_id
WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type='product');
DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = 'product');
DELETE FROM wp_posts WHERE post_type = 'product';
@carmolim
carmolim / functions.php
Created July 13, 2016 17:29
Funções utilizadas para retornar as informações de Cidade e Bairro quando essa localização está armazenada em uma taxonomia com a seguinte hierarquia: Estado - Cidade -Bairro - Cidade - Cidade - Cidade -Bairro Estado
// Função para retornar a Cidade do empreendimento
function get_cidade(){
global $post;
$taxonomy = 'localizacao';
$estados;
$cidade = [];
$bairro;
// busca termos que não tem parents, esses são os estados
$estados = get_terms( $taxonomy, array( 'parent' => 0 ) );
@carmolim
carmolim / featured_image_url.php
Last active September 18, 2016 22:40
featured image url
@carmolim
carmolim / get_excerpt.php
Last active September 23, 2016 18:07
Função para criar um excerpt com base no conteúdo do post.
// Retorna uma string com a quantidade de caracteres especificadas provindas do conteúdo do post
// sempre cortando a string em um espaço em branco para não cortar uma palavra pela metade
function get_excerpt( $count ){
// puxa a variáel global do post
global $post;
// puxa o ID do post
$post_id = $post->ID;
@carmolim
carmolim / find_and_replace.mysql
Created October 17, 2016 18:07
Find and Replace in post_content
UPDATE wp_posts SET post_content = REPLACE (
post_content,
'Item to replace here',
'Replacement text here');
@carmolim
carmolim / defer.js
Created February 22, 2017 15:40
Defer loading javascript
// ref: https://varvy.com/pagespeed/defer-loading-javascript.html
function downloadJSAtOnload() {
const scripts = ['defer.js', 'defer2.js', 'defer3.js'];
scripts.forEach(function(script){
const element = document.createElement("script");
element.src = script;
document.body.appendChild(element);
@carmolim
carmolim / signature.html
Created May 4, 2017 15:48
responsive mail signature template
<!--[if gte mso 9]>
<table cellspacing=0><tr><td style="font-family: Arial; font-size: 10pt; color: #fff; background-color: orange; width: 250px; height: 100px; padding: 3px; vertical-align: top">
<![endif]-->
<div style="float: left; font-family: Arial; font-size: 10pt; color: #fff; background-color: orange; width: 250px; height: 100px; padding: 3px; vertical-align: top">
<strong>{Display name}</strong><br>Phone {Phone}<br>Email <a href="mailto:{E-mail}" style="color: #fff; text-decoration: none;">{E-mail}</a>
</div>
<!--[if gte mso 9]>
</td><td style="font-family: Arial; font-size: 10pt; color: #fff; background-color: red; width: 250px; height: 100px; padding: 3px; vertical-align: top">
<![endif]-->
<div style="float: left; font-family: Arial; font-size: 10pt; color: #fff; background-color: red; width: 250px; height: 100px; padding: 3px; vertical-align: top">