This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension View { | |
func onScroll(_ isScrolling: Binding<Bool>) -> some View { | |
modifier(OnScrollModifier(isScrolling: isScrolling)) | |
} | |
} | |
private struct OnScrollModifier: ViewModifier { | |
@State private var callbackID = 0 | |
@Binding var isScrolling: Bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
/// Implementation of `Layout` that aligns subviews relative it their `anchor` value | |
/// | |
/// Considerations before using: | |
/// * Sizing is not taken into account | |
/// * No stacking is provided if multiple subviews are anchored to the same position | |
/// * Subviews will be able to overlap if anchored closely together and they're both large enough | |
public struct AnchorLayout: Layout { | |
public init() { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import CryptoKit | |
private protocol ByteCountable { | |
static var byteCount: Int { get } | |
} | |
extension Insecure.MD5: ByteCountable { } | |
extension Insecure.SHA1: ByteCountable { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func savePNG(_ frame: AVFrame, to url: String) throws { | |
let fmtCtx = try AVFormatContext(format: nil, filename: url) | |
guard let codec = AVCodec.findEncoderById(.PNG) else { | |
fatalError("png codec doesn't exist") | |
} | |
guard let codecCtx = AVCodecContext(codec: codec) else { | |
fatalError("Could not allocate video codec context") | |
} | |
codecCtx.width = frame.width |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Controller } from 'grind-framework' | |
export class AuthController extends Controller { | |
login(req, res) { | |
if(!req.user.isNil) { | |
return res.redirect('/') | |
} | |
return res.render('auth.login') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Backup a Plex database. | |
# Author Scott Smereka | |
# Version 1.0 | |
# Modified by Shaun Harrison | |
# Version 1.1 | |
# Script Tested on: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fileprivate class NetworkingDelegate: NSObject, URLSessionDelegate { | |
fileprivate func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) { | |
completionHandler(.useCredential, URLCredential(trust: challenge.protectionSpace.serverTrust!)) | |
} | |
} | |
private let proxySessionDelegate = NetworkingDelegate() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension CGRect: DebugPrintable { | |
var debugDescription: String { | |
return NSStringFromCGRect(self) | |
} | |
} | |
extension CGSize: DebugPrintable { | |
var debugDescription: String { | |
return NSStringFromCGSize(self) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// SHNFakeStatusBar | |
// Created by Shaun Harison on 12/3/13. | |
// | |
#import <objc/runtime.h> | |
#define CARRIER_STRING @"Apple" | |
#define TIME_STRING @"Timestamp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <objc/runtime.h> | |
#import <objc/message.h> | |
SEL SHNSwapSelectorWithBlock(Class class, SEL selector, BOOL isClassMethod, id block) { | |
Method method1 = isClassMethod ? class_getClassMethod(class, selector) : class_getInstanceMethod(class, selector); | |
// Generate new selector to inject | |
SEL newSelector = NSSelectorFromString([@"_swappedBlock_" stringByAppendingString:NSStringFromSelector(selector)]); | |
// Inject the block as method in the class |
NewerOlder