Skip to content

Instantly share code, notes, and snippets.

View mac-cain13's full-sized avatar

Mathijs Kadijk mac-cain13

View GitHub Profile
@mac-cain13
mac-cain13 / Info.plist
Last active March 29, 2024 17:12
Function to request and check Local Network permission on iOS, iPadOS & visionOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSBonjourServices</key>
<array>
<string>_preflight_check._tcp</string>
</array>
</dict>
</plist>
@mac-cain13
mac-cain13 / Readme.md
Last active July 21, 2020 20:22
SwiftUI - ScrollViewSpy

ScrollViewLongPressSpy

Unleash the power of UIScrollView when just using SwiftUI ScrollView.

What is it?

A dummy "spy" view you can add inside your ScrollView that will attach a UILongPressGestureRecognizer to it and gives you a binding to the point where the finger is in the direct superview of the spy.

Why do I need it?

SwiftUI ScrollView is getting better every release, but currently (iOS 14) you can't add extra gesture recognizers. This is often needed for more complex interactions, this little spy gets that job done.

Is this the recommended way to add complex ScrollView behaviour?

@mac-cain13
mac-cain13 / AccessibleHStack.swift
Created July 9, 2020 07:19
SwiftUI - AccessibleHStack
//
// AccessibleHStack.swift
//
// Created by Mathijs Kadijk on 08/07/2020.
//
import SwiftUI
/// HStack that will switch to a VStack when the horizontal size class is compact and the content size category is set to an accessibility size option
struct AccessibleHStack<Content>: View where Content: View {

Convert iWork to Office mapactions

Automatically convert Pages and/or Keynote files added to a certain folder into Word and/or Powerpoint files. Just throw in the iWork files and this scripts will convert them into Office files in the same folder. The iWork versions will be moved to the trash.

Setup

  1. Copy the two AppleScript files to ~/Library/Workflows/Applications/Folder Actions
  2. Create a conversion folder where you'll put the files you want to convert
  3. Right click the folder, choose configure folder actions, check the "Enable folder actions" checkbox and attach the pages-to-word.scpt and/or keynote-to-powerpoint.scpt to your folder
@mac-cain13
mac-cain13 / Readme.md
Last active August 29, 2015 14:11
Automatically copy all PNG assets to the correct Android drawable folder when exporting from for example Sketch.

Android assets folder action

Automatically copy all PNG assets to the correct Android drawable folder. Very helpful when exporting assets with @?x-suffix from, for example, Sketch and putting them into the correct folder without human interaction.

Setup

  1. Copy the AppleScript file to ~/Library/Workflows/Applications/Folder Actions
  2. Create a export folder where you'll put all exported PNGs
  3. Right click the folder, choose configure folder actions, check the "Enable folder actions" checkbox and attach the android_assets.scpt to your folder
  4. Open the terminal and create a symbolic link by typing ln -s /path/to/android-project/app/src/main/res /path/to/export-folder-you-just-created
@mac-cain13
mac-cain13 / NetworkActivityIndicatorManager.swift
Last active December 7, 2015 11:59
Swift class to manage the UIApplication.networkActivityIndicatorVisible in an effective and simple way
//
// NetworkActivityIndicatorManager.swift
//
// Created by Mathijs Kadijk on 30-10-14.
// From: https://gist.github.com/ab1b9196c99dcc16e5fe
// License: Public domain
//
@objc
class NetworkActivityIndicatorManager {
@mac-cain13
mac-cain13 / appledoc-buildphase.sh
Created April 26, 2014 09:31
XCode buildphase script that generated Appledoc of the project asynchronously
APPLEDOC_PATH=`which appledoc`
if [ $APPLEDOC_PATH ]; then
$APPLEDOC_PATH \
--project-name ${PROJECT_NAME} \
--project-company "YourCompany" \
--company-id "com.yourcompany" \
--ignore ".m" \
--ignore "Pods" \
--explicit-crossref \