Skip to content

Instantly share code, notes, and snippets.

@hujunfeng
hujunfeng / Hardware.swift
Last active January 9, 2019 04:07
A Swift struct to read the model names for iOS devices.
import Darwin
/// A struct for reading device model names for iOS devices.
public struct Hardware {
public let machine: String
public init() {
machine = Hardware.getSystemInformation("hw.machine")
}
# Reset branch with remote branch (or force pull)
$ git fetch origin master
$ git reset --hard FETCH_HEAD
$ git clean -df
# Altering `master` to whatever branch you want to be following.
@hujunfeng
hujunfeng / Optional+SafeValue.swift
Last active July 8, 2016 09:51
A `safeValue` method for Optional type. It returns an empty value if the wrapped type of the Optional type has one, for example String and Array.
/// A type that supports an "empty value"
protocol EmptyValuable {
/// Returns the empty value of `Self`
static var emptyValue: Self { get }
}
extension String: EmptyValuable {
static var emptyValue: String {
return ""
}
@hujunfeng
hujunfeng / random.swift
Last active January 2, 2016 18:54 — forked from mattt/random.swift
import Darwin
extension Int {
static func random() -> Int {
return Int(arc4random_uniform(UInt32(Int.max)))
}
static func random(range: Range<Int>) -> Int {
return Int(arc4random_uniform(UInt32(range.endIndex - range.startIndex))) + range.startIndex
}
Pod::Spec.new do |spec|
spec.name = 'YahooSearchKit'
spec.platform = :ios, '7.0'
spec.version = '0.5.0'
spec.summary = "Yahoo Search SDK for iOS"
spec.license = { :type => 'Yahoo', :text => 'Yahoo Confidential' }
spec.homepage = 'https://github.com/yahoo/searchsdk-ios'
spec.author = {
'Mobile Search' => 'mobile-search-eng@yahoo-inc.com'
}
//
// UIDeviceHardware.h
//
// Used to determine EXACT version of device software is running on.
#import <Foundation/Foundation.h>
@interface UIDeviceHardware : NSObject
+ (NSString *)platform;
Pod::Spec.new do |s|
s.name = "MediaKit"
s.version = "0.1"
s.summary = "MediaKit for iOS"
s.homepage = "http://www.2359media.com"
s.author = '2359 Media'
s.source = { :git => "https://github.com/2359media/MediaKit-iOS.git", :branch => 'experimental' }
s.platform = :ios, '7.0'
s.license = { :type => 'Copyright', :text => <<-LICENSE
[diff]
tool = Kaleidoscope
[difftool]
prompt = false
[merge]
tool = Kaleidoscope
[mergetool]
prompt = false
keepBackup = true
[difftool "Kaleidoscope"]

Embrace iOS 8 App Extensions to Reach More Users

An iOS app is sandboxed to protect unintentional access of its content from malicious software. App sandboxing is a great way to keep iOS apps in a safe environment. An iOS app basically lives in its own world. However, it also creases the difficulties for apps to collaborate. For example, a user might want to take a photo with the Camera app (because it can be opened quickly from lock screen), and share the photo with Instagram. Because of sandboxing, The Instagram app cannot directly access the photo image inside the Camera Roll, but it needs to copy the