Skip to content

Instantly share code, notes, and snippets.

View awaismubeen's full-sized avatar
🎯
Focusing

Awais Mubeen awaismubeen

🎯
Focusing
View GitHub Profile
//
// Created by Muhammad Ashir Mubeen on 13/07/2022.
//
#if os(iOS) || os(tvOS)
import UIKit
#elseif os(OSX)
import AppKit
#endif
import UIKit
enum AppStoryboard : String{
case Main = "Main"
case PreLogin = "Payment"
var instance : UIStoryboard {
return UIStoryboard(name: self.rawValue, bundle: Bundle.main)
}
func viewController<T>(vc : T.Type) -> T where T: UIViewController{
let identifier = String(describing: T.self)
@Tulakshana
Tulakshana / Data+File.swift
Created November 14, 2018 23:38
An extension for Data to get the file extension
extension Data {
private static let mimeTypeSignatures: [UInt8 : String] = [
0xFF : "image/jpeg",
0x89 : "image/png",
0x47 : "image/gif",
0x49 : "image/tiff",
0x4D : "image/tiff",
0x25 : "application/pdf",
0xD0 : "application/vnd",
0x46 : "text/plain",
@berkcebi
berkcebi / progress-indicator-spinning-color.swift
Created August 23, 2018 00:45
Changing the color of a spinning `NSProgressIndicator` using Core Image filters.
extension NSProgressIndicator {
func set(tintColor: NSColor) {
guard let adjustedTintColor = tintColor.usingColorSpace(.deviceRGB) else {
contentFilters = []
return
}
let tintColorRedComponent = adjustedTintColor.redComponent
@fethica
fethica / Units.swift
Last active January 9, 2024 15:42
[Swift] Convert Bytes to Kilobytes to Megabytes to Gigabytes
public struct Units {
public let bytes: Int64
public var kilobytes: Double {
return Double(bytes) / 1_024
}
public var megabytes: Double {
return kilobytes / 1_024
@mminer
mminer / NSButton+TextColor.swift
Last active September 10, 2022 23:24
NSButton extension that adds a method to change its text color.
import AppKit
extension NSButton {
func set(textColor color: NSColor) {
let newAttributedTitle = NSMutableAttributedString(attributedString: attributedTitle)
let range = NSRange(location: 0, length: attributedTitle.length)
newAttributedTitle.addAttributes([
.foregroundColor: color,