Skip to content

Instantly share code, notes, and snippets.

View PattoMotto's full-sized avatar
📱

Patompong Manprasatkul PattoMotto

📱
  • @careem an Uber + E& company
  • Dubai, UAE
View GitHub Profile
# 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 ''
# 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
import IntentsUI
class IntentViewController: UIViewController, INUIHostedViewControlling {
private let margin = CGFloat(8)
var dataManager: CookBookDataManager?
@IBOutlet weak var contentStackView: UIStackView!
// MARK: - INUIHostedViewControlling
import IntentsUI
extension ViewController: INUIAddVoiceShortcutViewControllerDelegate {
func addVoiceShortcutViewController(_ controller: INUIAddVoiceShortcutViewController,
didFinishWith voiceShortcut: INVoiceShortcut?,
error: Error?) {
if let error = error as NSError? {
print(error)
return
}
@PattoMotto
PattoMotto / ViewController.swift
Last active July 9, 2018 11:45
Method for present VoiceShortcutViewController and update UI, full project https://github.com/neungnarakjung/CookBook-Siri-Shortcuts-Example
import UIKit
import IntentsUI
class ViewController: UIViewController {
private var shortcutManager: VoiceShortcutManager?
private var dataManager: CookBookDataManager?
private func presentVoiceShortcutViewController() {
guard let shortcutManager = shortcutManager,
struct Recipe: Codable {
let identifier: String
let name: String
let instruction: [String]
}
protocol CookBookDataManager {
func getRecipe(_ identifier: String) -> Recipe?
}
import Intents
final class VoiceShortcutManager {
var voiceShortcuts: [INVoiceShortcut]?
init() {
updateShortcut()
}
public func updateShortcut(_ completion: (() -> Void)? = nil) {
import Intents
class IntentHandler: INExtension {
override func handler(for intent: INIntent) -> Any {
guard intent is CookBookIntent else {
fatalError("Unhandled intent type: \(intent)")
}
return CookBookIntentHandler()
}
}
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))
}
@PattoMotto
PattoMotto / enable_camera2_api.bat
Last active September 16, 2019 10:29
Enable Camera 2 API for android
@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.