Skip to content

Instantly share code, notes, and snippets.

View wata's full-sized avatar

Wataru Nagasawa wata

  • Tokyo
View GitHub Profile
@wata
wata / UIView+Borders.swift
Created May 31, 2023 06:48
Swift Extension for adding borders to any side of UIView
extension UIView {
struct Side: OptionSet {
let rawValue: Int
static let left = Side(rawValue: 1 << 0)
static let right = Side(rawValue: 1 << 1)
static let top = Side(rawValue: 1 << 2)
static let bottom = Side(rawValue: 1 << 3)
}
@wata
wata / TextView.swift
Last active May 9, 2022 13:18
Add placeholder text to UITextView in Swift
class TextView: UITextView {
override init(frame: CGRect, textContainer: NSTextContainer?) {
super.init(frame: frame, textContainer: textContainer)
commonInit()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
}
@wata
wata / CLLocation+Extensions.swift
Last active January 14, 2022 04:16
Get TimeZone from CLLocation. Works locally and offline with no restrictions. source of json file: https://github.com/Alterplay/APTimeZones/blob/master/APTimeZones/timezonesDB.json
import CoreLocation
struct TimeZoneInfo: Decodable {
let location: CLLocation
let timeZone: TimeZone
enum CodingKeys: String, CodingKey {
case latitude
case longitude
case identifier = "zone"
@wata
wata / EventStoreNotificationInfo.swift
Last active March 27, 2024 05:27
Parse EKEventStoreChanged notification user info
struct EventStoreNotificationInfo {
let changeType: Int
let calendarDataChanged: Bool
let remindersDataChanged: Bool
let changedObjectIDs: [NSObject]
let modifiedObjectIdentifiers: Set<String>? // Not included in iOS 16?
struct UserInfoKeys {
static let changeType = "EKEventStoreChangeTypeUserInfoKey"
static let calendarDataChanged = "EKEventStoreCalendarDataChangedUserInfoKey"
@wata
wata / connect.sh
Last active May 18, 2021 04:49
Connect AirPods from Terminal
# AlfredのWorkflowではPATHを通す処理が必要
# (これをせずに直にフルパス打つ方法もあるがApple Siliconマシンとの互換性問題が生じる)
# Cocoapods
export PATH=/usr/local/bin:$PATH
# Cocoapods(ARM)
export PATH=/opt/homebrew/bin:$PATH
AIR_PODS_NAME=wAPP
# Bluetooth接続
@wata
wata / siri.applescript
Created April 20, 2021 06:24
Siriコマンド入力するAppleScript
tell application "System Events" to tell the front menu bar of process "SystemUIServer"
tell (first menu bar item whose description is "Siri")
perform action "AXPress"
end tell
end tell
delay 1
tell application "System Events" to tell the process "NotificationCenter"
set notifyWindows to every window
struct CopyableText: UIViewRepresentable {
let text: String
init(_ text: String) {
self.text = text
}
func makeUIView(context: Context) -> UILabel {
let label = CopyableLabel()
label.text = text
@wata
wata / Fastfile
Created August 7, 2020 07:27
Get TestFlight Feedback
lane :testflight_feedback do
fastlane_require 'spaceship'
Spaceship::Tunes.login
Spaceship::Tunes.select_team
app = Spaceship::ConnectAPI::App.find(ENV["TEST_APP_BUNDLE"])
buffer = []
feedbacks = app.get_beta_feedback
@wata
wata / testflight-feedback.yml
Created August 7, 2020 07:21
GitHub Actions workflow
name: Get TestFlight Feedback
on:
schedule:
- cron: 0 0 * * * # UTC 0:00
jobs:
build:
runs-on: macos-latest
steps:
@wata
wata / credentials.js
Last active April 14, 2020 05:14
A script to get the password from accounts.google.com for iOS shortcuts
if (navigator.credentials && navigator.credentials.preventSilentAccess) {
navigator.credentials.get({
password: true,
unmediated: false,
federated: {
providers: ['https://accounts.google.com']
}
}).then((cred) => {
if (cred && cred.password) {
window.alert(cred.password)