Skip to content

Instantly share code, notes, and snippets.

View paulofierro's full-sized avatar

Paulo Fierro paulofierro

View GitHub Profile
@paulofierro
paulofierro / pre-commit
Created June 22, 2023 14:50
Pre-commit Example
#!/bin/bash
#
# Add this to your .git/hooks/ folder to run Swiftlint and Swiftformat
#
set -eo pipefail
# Redirect output to stderr
exec 1>&2
if [ `arch` == "arm64" ]; then
let request = VNDetectBarcodesRequest(completionHandler: nil)
request.symbologies = VNDetectBarcodesRequest
.supportedSymbologies
.filter {
$0.rawValue.contains("PDF417")
}
let request = VNDetectBarcodesRequest(completionHandler: nil)
if #available(iOS 15, *) {
request.symbologies = [.pdf417]
} else {
request.symbologies = [.PDF417]
}
let request = VNDetectBarcodesRequest(completionHandler: nil)
request.symbologies = [.PDF417]
@paulofierro
paulofierro / SFSymbols.swift
Last active September 17, 2019 19:00
A UIImage extension that returns a system image on iOS 13, otherwise returns an image from the Bundle provided.
extension UIImage {
/// Returns a system image on iOS 13, otherwise returns an image from the Bundle provided.
convenience init?(nameOrSystemName: String, in bundle: Bundle? = Bundle.main, compatibleWith traitCollection: UITraitCollection? = nil) {
if #available(iOS 13, *) {
self.init(systemName: nameOrSystemName, compatibleWith: traitCollection)
} else {
self.init(named: nameOrSystemName, in: bundle, compatibleWith: traitCollection)
}
}
}
@paulofierro
paulofierro / ArcProgress.swift
Last active April 23, 2019 18:26
Arc progress
//: A UIKit based Playground for presenting user interface
import UIKit
import PlaygroundSupport
class ArcProgressViewController : UIViewController {
private lazy var backgroundLayer: CAShapeLayer = {
let layer = CAShapeLayer()
layer.frame = CGRect(x: 25, y: 25, width: 325, height: 325)
@paulofierro
paulofierro / generify.h
Last active April 19, 2016 14:42
Generify
// This gives lets us use generics when compiling with Xcode 7 but will still compile using Xcode 6
#if __has_feature(objc_generics)
#define _generify(CODE) <CODE>
#define _generify_dict(KEY_TYPE, VAL_TYPE) <KEY_TYPE, VAL_TYPE>
#else
#define _generify(CODE)
#define _generify_dict(KEY_TYPE, VAL_TYPE)
#endif
/*
@paulofierro
paulofierro / video_listener.m
Last active April 6, 2023 15:41
WKWebView video playback change notification
// Listen for video playback
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(videoPlayingDidChange:)
name:@"SomeClientPlayingDidChange"
object:nil];
// Video playing state handler
- (void)videoPlayingDidChange:(NSNotification *)notification
{
BOOL isPlaying = [notification.userInfo[@"IsPlaying"] boolValue];
@paulofierro
paulofierro / all_notifications.m
Last active April 6, 2023 15:41
Listen for all NSNotifications
[[NSNotificationCenter defaultCenter] addObserverForName:nil
object:nil
queue:nil
usingBlock:^(NSNotification* notification) {
NSLog(@"Notification:\n"\
"name: %@\n"\
"object: %@\n"\
"userInfo: %@",
notification.name,
notification.object,
@paulofierro
paulofierro / ats-s3.txt
Created October 1, 2015 20:25
Apple Transport Security Diagnostics on Amazon S3
You can test ATS diagnositcs in Mac OS X El Capitan by running:
nscurl --ats-diagnostics -v https://s3.amazonaws.com
Here is the log:
================================================================================
Starting ATS Diagnostics
Configuring ATS Info.plist keys and displaying the result of HTTPS loads to https://s3.amazonaws.com.