Skip to content

Instantly share code, notes, and snippets.

View marciogranzotto's full-sized avatar

Marcio Granzotto Rodrigues marciogranzotto

View GitHub Profile
repeat
tell application "System Events" to delay 3.0
-- tell application "System Events" to set currentApp to name of first process where frontmost is true
if application "Spotify" is running then
try
-- Create a random number to do one of three things
set randomNum to random number from 1 to 3
if randomNum is 1 then
tell application "Spotify" to pause
// From http://stackoverflow.com/a/39344394/3984316
import UIKit
extension String {
init(htmlEncodedString: String) {
self.init()
guard let encodedData = htmlEncodedString.data(using: .utf8) else {
@marciogranzotto
marciogranzotto / example.py
Created January 27, 2017 14:01
Zeroconf example
#!/usr/bin/env python
""" Example of announcing a service (in this case, a fake HTTP server) """
import logging
import socket
import sys
from time import sleep
from zeroconf import ServiceInfo, Zeroconf
set voiceList to {"Agnes", "Kathy", "Princess", "Vicki", "Victoria", "Bruce", "Fred", "Junior", "Ralph", "Albert", "Bad News", "Bahh", "Bells", "Boing", "Bubbles", "Cellos", "Deranged", "Good News", "Hysterical", "Pipe Organ", "Trinoids", "Whisper", "Zarvox"}
repeat
repeat with voice in voiceList
tell application "System Events" to delay 3.0
tell application "Finder" to say "Clarice!" using voice
end repeat
end repeat
@marciogranzotto
marciogranzotto / KotlinContracts.kt
Last active August 7, 2017 04:01
File template for Android Studio that creates the contracts for a new VIPER module
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME}
#end
#parse("File Header.java")
object ${NAME} {
interface View: BaseContracts.View {
//TODO
}
class LoginContracts {
interface View {
fun showError(message: String)
//fun presentHomeScreen(user: User) <- This is no longer a part of the View's responsibilities
}
interface Router {
fun presentHomeScreen(user: User) // Now the router handles it
}
}
@marciogranzotto
marciogranzotto / backup.sh
Last active April 30, 2018 06:53 — forked from fragolinux/backup.sh
simple but effective node-red setup backup script
#!/bin/bash
cd
# useful vars
DATE=$(date +"%Y%m%d%H%M")
WHERE=~/backup/$DATE
# create dated backup folders
mkdir -p $WHERE/{sqlite,nodered,etc}
# safely backup sqlite db
# sqlite3 ~/dbs/iot.db ".backup $WHERE/sqlite/iot.db"
# backup json and js files

NX-SM400

This is the english version

Para a versão em português (pr-BR) use ESSE LINK

Recently, some smart plugs with the BR plug type started appearing on AliExpress

substitutions:
devicename: nome_do_nodo
ss_id: "Nome da Wifi"
pass: "Senha da Wifi"
switch4: "Nome switch4"
light_1: "Nome Luz1"
light_2: "Nome Luz2"
light_3: "Nome Luz3"
esphome:
name: ${devicename}
@marciogranzotto
marciogranzotto / MVP + Interactor example.kt
Last active November 4, 2020 15:40
This is an example of Android development with MVP + Interactor in Kotlin
interface LoginContracts {
interface View {
fun presentHomeScreen(user: User)
fun showError(message: String)
}
interface Presenter {
fun onDestroy()
fun onLoginButtonPressed(username: String, password: String)
}