Skip to content

Instantly share code, notes, and snippets.

View DanielStormApps's full-sized avatar
👨‍💻
Looking at your code

Daniel Storm DanielStormApps

👨‍💻
Looking at your code
View GitHub Profile
@lkoskela
lkoskela / UIColor+Contrast.swift
Created March 30, 2017 11:46
Utility for calculating the relative luminance and contrast ratio of two colors to determine whether they meet the recommendation set forth by the W3's Web Content Accessibility Guidelines 2.0.
import UIKit
extension UIFont {
private var weight: CGFloat {
if let traits = fontDescriptor.object(forKey: UIFontDescriptorTraitsAttribute) as? NSDictionary,
let weight = traits[UIFontWeightTrait] as? CGFloat {
return weight
}
return 0
}
public func getItemsFromSystemProfiler(dataTypeString: String) -> [[String:AnyObject]]? {
let task = Process()
let pipe = Pipe()
// Set up our task process
task.launchPath = "/usr/sbin/system_profiler"
task.arguments = ["-xml", dataTypeString]
task.standardOutput = pipe
// Go!
@tadija
tadija / FontNames-iOS-17.4.swift
Last active April 30, 2024 00:30
iOS - All Font Names
/*
*** Academy Engraved LET ***
AcademyEngravedLetPlain
---------------------
*** Al Nile ***
AlNile
AlNile-Bold
---------------------
*** American Typewriter ***
AmericanTypewriter
@darthpelo
darthpelo / EmailValidator.swift
Last active September 25, 2020 08:51
This regular expression is adapted from a version at regular-expressions.info and is a complete verification of RFC 2822. Source: http://www.cocoawithlove.com/2009/06/verifying-that-string-is-email-address.html. Dedicate article: https://medium.com/@darthpelo/email-validation-in-swift-3-0-acfebe4d879a
/// Validate email string
///
/// - parameter email: A String that rappresent an email address
///
/// - returns: A Boolean value indicating whether an email is valid.
func isValid(_ email: String) -> Bool {
let emailRegEx = "(?:[a-zA-Z0-9!#$%\\&‘*+/=?\\^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%\\&'*+/=?\\^_`{|}” +
“~-]+)*|\“(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\” +
“x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\“)@(?:(?:[a-z0-9](?:[a-” +
“z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5" +
//
// ProfileViewController.swift
// Drizzle
//
// Created by George on 2016-04-17.
// Copyright © 2016 George. All rights reserved.
//
import UIKit
import IBAnimatable
@NicholasTD07
NicholasTD07 / clean-up-simulators.sh
Created July 15, 2015 04:26
Remove all unavailable iOS simulators
#!/bin/sh
# "Delete all unavailable devices."
xcrun simctl delete unavailable
@asev
asev / bitbucket_load_all_diffs.js
Created July 14, 2015 05:43
Bitbucket load all diffs in pull request
/* Add this line to bookmarks and use when you see
* "Oops! You've got a lot of code in this diff and it couldn't load with the page."
* on a pull request at Bitbucket.
*/
javascript:(function(){[].forEach.call(document.querySelectorAll(".load-diff"),function(a){a.click()})})();
@steipete
steipete / UIImage+PSPDFKitAdditions.m
Created August 13, 2011 20:52
Preload UIImage for super-smooth interaction. especially great if you use JPGs, which otherwise produce a noticeable lag on the main thread.
- (UIImage *)pspdf_preloadedImage {
CGImageRef image = self.CGImage;
// make a bitmap context of a suitable size to draw to, forcing decode
size_t width = CGImageGetWidth(image);
size_t height = CGImageGetHeight(image);
CGColorSpaceRef colourSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef imageContext = CGBitmapContextCreate(NULL, width, height, 8, width*4, colourSpace,
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little);