Skip to content

Instantly share code, notes, and snippets.

View elpsk's full-sized avatar
:octocat:
I may be slow to respond.

alberto elpsk

:octocat:
I may be slow to respond.
View GitHub Profile
@elpsk
elpsk / shake
Created September 28, 2018 10:21
Swift - Undo text using Shake
override func motionEnded(_ motion: UIEventSubtype, with event: UIEvent?) {
if motion == .motionShake {
if (<#textField#>.undoManager?.canUndo)! {
self.<#textField#>.undoManager?.undo()
}
}
}
@elpsk
elpsk / fontsize.swift
Created September 28, 2018 10:23
Swift - Detect device font size
//
// FontSizeVC.swift
// Created by Pasca Alberto, IT on 10/08/18.
// Copyright © 2018 albertopasca.it. All rights reserved.
//
import UIKit
class FontSizeVC: UIViewController {
@elpsk
elpsk / proximity
Last active May 19, 2023 17:07
Swift - Proximity sensor (shut down screen if near ear)
//
// ProximityVC.swift
// Created by Pasca Alberto, IT on 10/08/18.
// Copyright © 2018 albertopasca.it. All rights reserved.
//
import UIKit
class ProximityVC: UIViewController {
@elpsk
elpsk / pasteboard
Created September 28, 2018 10:25
Swift - pasteboard
//
// PasteboardVC.swift
// Created by Pasca Alberto, IT on 10/08/18.
// Copyright © 2018 albertopasca.it. All rights reserved.
//
import UIKit
class PasteboardVC: UIViewController {
@elpsk
elpsk / lowpower
Created September 28, 2018 10:25
Swift - detect low power
//
// LowPowerVC.swift
// Created by Pasca Alberto, IT on 10/08/18.
// Copyright © 2018 albertopasca.it. All rights reserved.
//
import UIKit
class LowPowerVC: UIViewController {
@elpsk
elpsk / voiceOver
Created September 28, 2018 10:26
Swift - Voice over detection
//
// VoiceOverVC.swift
// Created by Pasca Alberto, IT on 10/08/18.
// Copyright © 2018 albertopasca.it. All rights reserved.
//
import UIKit
class VoiceOverVC: UIViewController {
@elpsk
elpsk / screen.sh
Created October 5, 2018 09:34
MacOS programmatically take screenshot of a particular windows
$ /usr/sbin/screencapture
-r
-l$(osascript -e 'tell app "QuickTime Player" to id of window 1')
/Users/pippo/Desktop/test.png
@elpsk
elpsk / android tap
Created October 5, 2018 09:52
Android send tap on screen
$ adb shell input tap x y
@elpsk
elpsk / android-screenshot.sh
Created October 5, 2018 10:05
Take a screenshot from Android connected device and save to macOS Desktop
$ adb shell screencap -p /sdcard/screencap.png
$ adb pull /sdcard/screencap.png /Users/pippo/Desktop/test.png
@elpsk
elpsk / .swiftlint.yml
Last active April 20, 2019 14:01
My swift rules for .swiftlint.yml
analyzer_rules:
- unused_import
- unused_private_declaration
opt_in_rules:
- array_init
- attributes
- closure_end_indentation
- closure_spacing
- collection_alignment
- contains_over_first_not_nil