Skip to content

Instantly share code, notes, and snippets.

View richardwei6's full-sized avatar
🤔

Richard Wei richardwei6

🤔
View GitHub Profile
//
// AppUtility.swift
// AHS
//
// Created by Richard Wei.
//
import Foundation
import UIKit
struct AppUtility {
@richardwei6
richardwei6 / multipartPacketProtocol.swift
Last active March 1, 2021 06:43
Multipart Packet implementation in Swift
//
// multipartPacketProtocol.swift
// Omegacam-ios
//
// Created by Richard Wei on 2/23/21.
//
import Foundation
class multipartPacketManager{
@richardwei6
richardwei6 / dataDeltaFinder.swift
Last active February 28, 2021 04:15
A simple class to find the delta between subsequent data variables
//
// imageDeltaFinder.swift
// Omegacam-ios
//
// Created by Richard Wei on 2/24/21.
//
import Foundation
import AVFoundation
#include <iostream>
using namespace std;
double dydx(double x, double y){
return x+y;
}
int main(){
double x, y, h, endX;
extension String {
func getHeight(withConstrainedWidth width: CGFloat, font: UIFont) -> CGFloat {
let constraintRect = CGSize(width: width, height: .greatestFiniteMagnitude)
let boundingBox = self.boundingRect(with: constraintRect, options: .usesLineFragmentOrigin, attributes: [NSAttributedString.Key.font: font], context: nil)
return ceil(boundingBox.height)
}
func getWidth(withConstrainedHeight height: CGFloat, font: UIFont) -> CGFloat {
let constraintRect = CGSize(width: .greatestFiniteMagnitude, height: height)
func resetAllSettingsDefaults() {
let defaults = UserDefaults.standard
let dictionary = defaults.dictionaryRepresentation()
dictionary.keys.forEach { key in
defaults.removeObject(forKey: key)
}
}