Skip to content

Instantly share code, notes, and snippets.

View danilopinotti's full-sized avatar
Possibly drinking coffee

Danilo Pinotti danilopinotti

Possibly drinking coffee
View GitHub Profile
@danilopinotti
danilopinotti / mqtt-serial-chat.ino
Last active April 28, 2021 03:19
Simple MQTT chat using Arduino Serial and a public broker
#include <WiFi.h>
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
#include <PubSubClient.h> // https://github.com/knolleary/pubsubclient
#define BROKER_ADDRESS "broker.hivemq.com"
#define BROKER_PORT 1883
#define MQTT_CLIENT_ID "arduinoClient-1A2B3C"
WiFiClient wifiClient;
PubSubClient mqttClient(wifiClient);
@danilopinotti
danilopinotti / webserver-toggle-led.ino
Last active April 26, 2021 02:00
Código para treinamento sobre bibliotecas e utilização delas
#include <Led.h>
#include <WebServer.h>
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
Led led(2);
WebServer webServer(80);
void setupWifi() {
WiFi.mode(WIFI_STA);
WiFiManager wifiManager;
@danilopinotti
danilopinotti / UrlHelper.php
Created December 15, 2020 18:11
A support class made to help working with URLs
<?php
/**
* A support class made to help with URLs
*/
class UrlHelper
{
/**
* Validate if param is a valid URL;
*
@danilopinotti
danilopinotti / EmbeddedGoogleMaps.vue
Last active November 1, 2021 20:45
Embedded Google Maps Vue Component to show a given address. Stylized with Tailwind CSS
<template>
<div class="relative text-right" :style="`height: ${height}; width: ${width}`">
<div :style="`height: ${height}; width: ${width}`" class="overflow-hidden bg-none">
<iframe :width="width" :height="height"
:src="mapUrl"
frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe>
</div>
</div>
</template>
@danilopinotti
danilopinotti / RefreshDatabase.php
Created February 10, 2020 20:41
Laravel RefreshDatabase freshing database once according migrations folder.
<?php
namespace Tests;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Foundation\Testing\RefreshDatabase as RefreshDatabaseBase;
use Illuminate\Foundation\Testing\RefreshDatabaseState;
trait RefreshDatabase
{
@danilopinotti
danilopinotti / CacheKeys.php
Last active December 15, 2020 18:05
Trait to generate Model cache keys. Applicable in Models from Laravel 5+
<?php
/**
* Created by: @danilopinotti
* Inspired in Laravel Model Caching article (https://laravel-news.com/laravel-model-caching).
*/
trait CacheKeys
{
/**
* Generates a key that is updated each time Model is updated.