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 resetAllSettingsDefaults() { | |
let defaults = UserDefaults.standard | |
let dictionary = defaults.dictionaryRepresentation() | |
dictionary.keys.forEach { key in | |
defaults.removeObject(forKey: key) | |
} | |
} |
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 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) |
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
#include <iostream> | |
using namespace std; | |
double dydx(double x, double y){ | |
return x+y; | |
} | |
int main(){ | |
double x, y, h, endX; |
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
// | |
// imageDeltaFinder.swift | |
// Omegacam-ios | |
// | |
// Created by Richard Wei on 2/24/21. | |
// | |
import Foundation | |
import AVFoundation |
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
// | |
// multipartPacketProtocol.swift | |
// Omegacam-ios | |
// | |
// Created by Richard Wei on 2/23/21. | |
// | |
import Foundation | |
class multipartPacketManager{ | |
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
// | |
// AppUtility.swift | |
// AHS | |
// | |
// Created by Richard Wei. | |
// | |
import Foundation | |
import UIKit | |
struct AppUtility { |
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
// | |
// udpsocket.swift | |
// | |
// Created by Richard Wei on 3/7/21. | |
// | |
import Foundation | |
import Network | |
// https://developer.apple.com/news/?id=0oi77447 |
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 UIColor{ | |
convenience init(hex: String, alpha: CGFloat = 1.0){ | |
var hex_copy = hex; | |
let count = hex.count; | |
if (count != 6 && count != 7){ | |
self.init(); | |
return; | |
} |
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
int solution(vector<int> a) { | |
int n = a.size(); | |
vector<int> dp(n, 0); // init array of size n to 0 | |
int mx = 0; // find max dp value | |
for (int i = n - 1; i > -1; i--) { // loop backwards from a | |
int t = a[i]; // this DP value |
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
#include <stdio.h> | |
#include <stdbool.h> | |
#include <math.h> | |
int main(){ | |
printf("Hello World\nNew line\nTest"); | |
OlderNewer