Skip to content

Instantly share code, notes, and snippets.

View wata's full-sized avatar

Wataru Nagasawa wata

View GitHub Profile
@niw
niw / use_var_in_struct.md
Last active January 27, 2025 04:58
Use `var` in `struct` in Swift

Use var in struct in Swift

TL;DR: Use var for properties in struct as long as it serves as a nominal tuple. In most cases, there is no obvious benefit to using let for struct properties.

Simple Example

Let's start with a simple example:

struct MyStruct {
@robksawyer
robksawyer / excludedActivityTypes.swift
Last active December 12, 2024 10:37
A list of UIActivity.ActivityType for modern apps.
let excludedActivityTypes = [
UIActivity.ActivityType.print,
UIActivity.ActivityType.openInIBooks,
UIActivity.ActivityType.copyToPasteboard,
UIActivity.ActivityType.addToReadingList,
UIActivity.ActivityType.assignToContact,
UIActivity.ActivityType.copyToPasteboard,
UIActivity.ActivityType.mail,
UIActivity.ActivityType.markupAsPDF,
UIActivity.ActivityType.postToFacebook,
@1amageek
1amageek / FirestoreMonitoring.swift
Created August 19, 2020 09:56
Count Cloud Firestore Reads
//
// FirestoreMonitoring.swift
// Monitor
//
// Created by nori on 2020/08/19.
// Copyright © 2020 1amageek. All rights reserved.
//
import Foundation
import FirebaseFirestore
@ole
ole / UIAlertController+TextField.swift
Last active January 24, 2025 19:07
A UIAlertController with a text field and the ability to perform validation on the text the user has entered while the alert is on screen. The OK button is only enabled when the entered text passes validation. More info: https://oleb.net/2018/uialertcontroller-textfield/
import UIKit
/// A validation rule for text input.
public enum TextValidationRule {
/// Any input is valid, including an empty string.
case noRestriction
/// The input must not be empty.
case nonEmpty
/// The enitre input must match a regular expression. A matching substring is not enough.
case regularExpression(NSRegularExpression)
@darktable
darktable / app.yaml
Created March 16, 2011 19:10
GAE: App.yaml designed for serving a static site on Google App Engine (Python). Copy your static html and files into a folder called "static" next to app.yaml. Contains a bunch of mimetype declarations from html5boilerplate's .htaccess. May not be neces
application: you-app-name-here
version: 1
runtime: python
api_version: 1
default_expiration: "30d"
handlers:
- url: /(.*\.(appcache|manifest))
mime_type: text/cache-manifest