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
@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);
@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()})})();
@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
//
// ProfileViewController.swift
// Drizzle
//
// Created by George on 2016-04-17.
// Copyright © 2016 George. All rights reserved.
//
import UIKit
import IBAnimatable
@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" +
@tadija
tadija / FontNames-iOS-17.4.swift
Last active May 31, 2024 19:23
iOS - All Font Names
/*
*** Academy Engraved LET ***
AcademyEngravedLetPlain
---------------------
*** Al Nile ***
AlNile
AlNile-Bold
---------------------
*** American Typewriter ***
AmericanTypewriter
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!
@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
}
@ryanrey
ryanrey / Font.swift
Created May 8, 2017 03:41
UIFont Extension
typealias Font = UIFont
public extension Font {
convenience init(_ family: FontFamily = .system, size: CGFloat = 17.0, weight: FontWeight = FontWeight.regular) {
let descriptor: UIFontDescriptor
if family == .system {
descriptor = UIFont.systemFont(ofSize: size, weight: weight.value).fontDescriptor
} else {
var attributes: [String: AnyObject] = [:]
attributes[UIFontDescriptorNameAttribute] = family.name as AnyObject

Note

Apple will reject apps that are using private url schemes (Ugh, Apple....) if they are pretty much obvius. Some apps are rejected and others are not, so, be aware of this issue before implementing any of those URL's in your app as a feature.

Updates

  • [UPDATE 4] iOS 10 update: apparently settings now can be reached using App-Pref instead of prefs
  • [UPDATE 3] For now you just can use url schemes to open your apps's settings with Swift 3.0 (Xcode 8). I'll keep you informed when OS preferences can be reached
  • [UPDATE 2] The openURL() method of UIApplication is now deprecated. You should use application(_:open:options:) instead
  • [UPDATE 1] Not yet tested in iOS 10. It will fail because of policies changes in URL scheme handling.