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
--heres a even better one for a fake virus prank
tell application "Finder"
-- set x to ((path to me as text) & "Contents:Resources:appicon.icn*s") as
display dialog "Please read and agree to our Terms of Service (ToS). " buttons "OK" default button "OK" with title "iLivid Terms of Service" with icon 1
set volume 10
do shell script "say -v trinoids Virus activated"
display dialog "Virus propagating.
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
// 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 / mosquitto.service
Created January 24, 2017 16:30
mqtt-avahi-service-descriptor
<!-- Put this in /etc/avahi/services/mosquitto.service -->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">Mosquitto MQTT server on %h</name>
<service>
<type>_mqtt._tcp</type>
<port>1883</port>
<txt-record>info=Publish, Publish! Read all about it! mqtt.org</txt-record>
</service>
@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
@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)
}
@marciogranzotto
marciogranzotto / VIPER Android Example.kt
Last active April 16, 2021 08:41
This is an example of Android development with VIPER in Kotlin
interface LoginContracts {
interface View {
fun showError(message: String)
}
interface Presenter {
fun onDestroy()
fun onLoginButtonPressed(username: String, password: String)
}
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 / 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
}