This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
REM before use this script please disable pin/password unlock screen (set to none) | |
REM enable developer mode and USB debugging | |
REM download ADB and FASTBOOT from https://forum.xda-developers.com/showthread.php?t=2588979 | |
REM download recovery file for your device from https://twrp.me and rename to recovery.img | |
REM Tested with MI A1 | |
REM Thanks, script from https://forum.xda-developers.com/showpost.php?p=75541654&postcount=98 | |
echo. & echo Rebooting & echo. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
final class CookBookIntentHandler: NSObject, CookBookIntentHandling { | |
func handle(intent: CookBookIntent, completion: @escaping (CookBookIntentResponse) -> Void) { | |
guard let recipe = intent.recipe else { | |
completion(CookBookIntentResponse(code: .failure, userActivity: nil)) | |
return | |
} | |
completion(CookBookIntentResponse.success(recipe: recipe)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Intents | |
class IntentHandler: INExtension { | |
override func handler(for intent: INIntent) -> Any { | |
guard intent is CookBookIntent else { | |
fatalError("Unhandled intent type: \(intent)") | |
} | |
return CookBookIntentHandler() | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Intents | |
final class VoiceShortcutManager { | |
var voiceShortcuts: [INVoiceShortcut]? | |
init() { | |
updateShortcut() | |
} | |
public func updateShortcut(_ completion: (() -> Void)? = nil) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Recipe: Codable { | |
let identifier: String | |
let name: String | |
let instruction: [String] | |
} | |
protocol CookBookDataManager { | |
func getRecipe(_ identifier: String) -> Recipe? | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import IntentsUI | |
class ViewController: UIViewController { | |
private var shortcutManager: VoiceShortcutManager? | |
private var dataManager: CookBookDataManager? | |
private func presentVoiceShortcutViewController() { | |
guard let shortcutManager = shortcutManager, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import IntentsUI | |
extension ViewController: INUIAddVoiceShortcutViewControllerDelegate { | |
func addVoiceShortcutViewController(_ controller: INUIAddVoiceShortcutViewController, | |
didFinishWith voiceShortcut: INVoiceShortcut?, | |
error: Error?) { | |
if let error = error as NSError? { | |
print(error) | |
return | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import IntentsUI | |
class IntentViewController: UIViewController, INUIHostedViewControlling { | |
private let margin = CGFloat(8) | |
var dataManager: CookBookDataManager? | |
@IBOutlet weak var contentStackView: UIStackView! | |
// MARK: - INUIHostedViewControlling |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# credit https://dev.to/rrampage/snake-case-to-camel-case-and-back-using-regular-expressions-and-python-m9j | |
import re | |
REG = r"(.+?)([A-Z])" | |
def snake(match): | |
return match.group(1).lower() + "-" + match.group(2).lower() | |
words = """MyClass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# credit https://dev.to/rrampage/snake-case-to-camel-case-and-back-using-regular-expressions-and-python-m9j | |
# credit https://stackoverflow.com/a/3847369 | |
import re | |
REG = r"(.+?)([A-Z])" | |
def camel(match): | |
return match.group(1).lower() + match.group(2)[0].upper() + match.group(2)[1:].lower() | |
lowerFirstChar = lambda s: s[:1].lower() + s[1:] if s else '' |
OlderNewer