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
#import <Foundation/Foundation.h> | |
#include <dlfcn.h> | |
NSDictionary *FCPrivateBatteryStatus() | |
{ | |
static mach_port_t *s_kIOMasterPortDefault; | |
static kern_return_t (*s_IORegistryEntryCreateCFProperties)(mach_port_t entry, CFMutableDictionaryRef *properties, CFAllocatorRef allocator, UInt32 options); | |
static mach_port_t (*s_IOServiceGetMatchingService)(mach_port_t masterPort, CFDictionaryRef matching CF_RELEASES_ARGUMENT); | |
static CFMutableDictionaryRef (*s_IOServiceMatching)(const char *name); |
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
import Cocoa | |
import MASShortcut | |
func pow() { | |
let rect = NSScreen.mainScreen()?.frame | |
let window = NSWindow(contentRect: rect!, styleMask: NSBorderlessWindowMask, backing: .Buffered, `defer`: false) | |
window.backgroundColor = NSColor.clearColor() | |
window.opaque = false | |
window.alphaValue = 1 | |
window.makeKeyAndOrderFront(NSApplication.sharedApplication()) |
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
protocol FactoryAType { | |
typealias Product | |
} | |
protocol FactoryBType { | |
typealias Product | |
} | |
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
#!/bin/sh | |
# ID='A16FF353-8441-459E-A50C-B071F53F51B7' # Xcode 6.2 | |
# ID='992275C1-432A-4CF7-B659-D84ED6D42D3F' # Xcode 6.3 | |
# ID='AABB7188-E14E-4433-AD3B-5CD791EAD9A3' # Xcode 7b5 | |
# ID='7265231C-39B4-402C-89E1-16167C4CC990' #Xcode 7.1.1 | |
ID='F41BD31E-2683-44B8-AE7F-5F09E919790E' # Xcode 7.2 | |
PLIST_BUDDY=/usr/libexec/PlistBuddy |
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
public func print<T>(object: T, _ file: String = __FILE__, _ function: String = __FUNCTION__, _ line: Int = __LINE__) { | |
Swift.print("\(file.lastPathComponent.stringByDeletingPathExtension).\(function)[\(line)]: \(object)") | |
} |
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 { | |
var isHomogeneous: Bool { | |
guard !isEmpty else { return true } | |
for i in startIndex..<endIndex.predecessor() { | |
if characters[i] != characters[i.successor()] { | |
return false | |
} | |
} | |
return true |
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
var results = [MyModel]() // must use var :( | |
do { | |
results = try fetch(request: request, inContext: context) | |
} | |
catch { | |
print("Fetch error: \(error)") | |
} | |
// use results |
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
protocol MyProtocol { | |
} | |
protocol MyOtherProtocol { | |
} | |
func configure <T: UIViewController where T: MyProtocol, T: MyOtherProtocol> (viewController: T) { |
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
public protocol TableViewCellFactoryType { | |
typealias DataItem | |
typealias Cell: UITableViewCell | |
func cellForItem(item: DataItem, inTableView tableView: UITableView, atIndexPath indexPath: NSIndexPath) -> Cell | |
func configureCell(cell: Cell, forItem item: DataItem, inTableView tableView: UITableView, atIndexPath indexPath: NSIndexPath) -> Cell | |
} |
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
// Swift | |
var arr: [Int] = // some array | |
let newArr = sorted(arr); | |
// Objective-C | |
NSMutableArray *arr = // some array | |
[arr sortUsingComparator:^NSComparisonResult(NSNumber *n1, NSNumber *n2) { | |
return [n1 compare:n2]; | |
}]; |
NewerOlder