(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
Thanks to ErikEvenson https://github.com/ErikEvenson | |
I did three things to use Apple's current sample code in my ARC projects: | |
1) Set -fno-objc-arc as a compiler flag on KeychainItemWrapper.m under Build Phases, Compile Sources. | |
2) Use __bridge_transfer in the call to the wrapper: NSString *password = [wrapper objectForKey:(__bridge_transfer id)kSecValueData]; | |
3) Add an autorelease to line 196 of Apple's code to plug Apple's memory leak: self.keychainItemData = [[[NSMutableDictionary alloc] init] autorelease]; | |
Another solution which rewrites the code in ARC can be found here | |
https://gist.github.com/1170641 |
private Class<?> clazz = null; | |
public MonitorResinThread(Timer timer) { | |
super(timer, 1); | |
//Make sure the class is only load once | |
try { | |
String homePath = "/Home/folder/to/jar"; | |
File file = new File(homePath + "/lib/resin.jar"); | |
URL url = new URL("jar", "", "file:" + file.getAbsolutePath() + "!/"); | |
URL[] urls = new URL[] { url }; |
<style> | |
#outer | |
{ | |
background:red; | |
display:table; | |
width: 100%; | |
height:600px; | |
} | |
#inner | |
{ |
You can easily remove all the trailing whitespace within a single file by using | |
a regular expression with the Find/Replace dialog. Enter [ \t]+$ in the "Find:" box | |
and leave the "Replace with:" box empty. Check the "Regular expressions" option | |
then click "Replace All" |
#!/bin/sh | |
modulesDirectory=$DERIVED_FILES_DIR/modules | |
modulesMap=$modulesDirectory/module.modulemap | |
modulesMapTemp=$modulesDirectory/module.modulemap.tmp | |
mkdir -p "$modulesDirectory" | |
cat > "$modulesMapTemp" << MAP | |
module sqlite3 [system] { |
// https://github.com/apple/swift/pull/348 | |
private func getDoubleStrWith16DecimalDigits(value: Double) -> String { | |
return String(format: "%.16f", value) | |
} |
extension String { | |
func size(withAttributes attrs: [String:AnyObject], constrainedTo box: NSSize) -> NSRect { | |
let storage = NSTextStorage(string: self) | |
let container = NSTextContainer(containerSize: NSSize(width: box.width, height: box.height)) | |
let layout = NSLayoutManager() | |
layout.addTextContainer(container) | |
storage.addLayoutManager(layout) | |
storage.addAttributes(attrs, range: NSMakeRange(0, storage.length)) | |
container.lineFragmentPadding = 0.0 | |
let _ = layout.glyphRangeForTextContainer(container) |
When you get an error code in with the domain kCFStreamErrorDomainSSL, you can generally find the error codes in SecureTransport.h which is in /System/Library/Frameworks/Security.framework. Here are the error codes: | |
enum { | |
errSSLProtocol = -9800, /* SSL protocol error */ | |
errSSLNegotiation = -9801, /* Cipher Suite negotiation failure */ | |
errSSLFatalAlert = -9802, /* Fatal alert */ | |
errSSLWouldBlock = -9803, /* I/O would block (not fatal) */ | |
errSSLSessionNotFound = -9804, /* attempt to restore an unknown session */ | |
errSSLClosedGraceful = -9805, /* connection closed gracefully */ | |
errSSLClosedAbort = -9806, /* connection closed via error */ |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.