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
// UIFont *font = [UIFont headline1]; | |
UIFont *font = [UIFont fontWithName:@"Futura" size:20]; | |
UIFontDescriptor *d = font.fontDescriptor; | |
NSLog(@"Matching Descriptors: %@", [d matchingFontDescriptorsWithMandatoryKeys:[NSSet setWithObjects: UIFontDescriptorTraitsAttribute, nil]]); | |
NSDictionary *descriptor = @ | |
{ | |
(__bridge NSString *)kCTFontSymbolicTrait:@(UIFontDescriptorTraitMonoSpace), | |
}; | |
NSDictionary *fontTraits = @ |
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
Thonburi Family: | |
Thonburi-Bold: Bold | |
Thonburi: | |
Academy Engraved LET Family: | |
AcademyEngravedLetPlain: | |
Snell Roundhand Family: | |
SnellRoundhand-Bold: Italic, Bold | |
SnellRoundhand-Black: Italic, Bold |
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
0. Read the <link>FAQ</link>. Other *mandatory* reading follows at the bottom of these rules. | |
1. Google first, ask second. You must work through the Rubber Duck process <i>before</i> asking questions in-channel. | |
2. This is a volunteer-staffed channel. The time of the volunteers is worth at *least* as much as your time. We are not your employees or your servants. Clean your own room, do your own homework, write your own code, and don't forget to say "Thank you" for the help. | |
3. The phrase "doesn't work" isn't allowed. Prepare to explain the problem without links to Stack Overflow. | |
4. Show your code. We don't care about your NDAs. If you don't want to show your code, go pay a consultant. We may ask you to create a minimal project that demonstrates your issue. Save time by doing so before entering the channel. |
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 | |
struct BagGenerator<T:Hashable> : Generator | |
{ | |
typealias Element = (T, Int, Int) | |
var count = 0 | |
var _backingGenerator : DictionaryGenerator<T, Int> | |
init(_ backingDictionary : Dictionary<T, Int>) { | |
_backingGenerator = backingDictionary.generate() | |
} |
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
// | |
// Bag.swift | |
// CmdLineTest | |
// | |
// Created by Erica Sadun on 6/23/14. | |
// Copyright (c) 2014 Erica Sadun. All rights reserved. | |
// | |
import Foundation |
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
// | |
// explore.swift | |
// CmdLineTest | |
// | |
// Created by Erica Sadun on 6/25/14. | |
// Copyright (c) 2014 Erica Sadun. All rights reserved. | |
// | |
import Foundation |
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 | |
// See http://www.ruby-doc.org/core-2.1.1/Enumerable.html | |
extension Array { | |
var first : Element? {return self.count > 0 ? self[0] : nil} | |
var last : Element? {return self.count > 0 ? self[self.count - 1] : nil} | |
var random : Element? {return self.count > 0 ? self[Int(arc4random_uniform(UInt32(self.count)))] : nil} | |
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 AbsoluteValuable | |
protocol ArrayBound | |
protocol ArrayBufferType | |
protocol ArrayLiteralConvertible | |
protocol ArrayType | |
protocol BidirectionalIndex | |
protocol BitwiseOperations | |
protocol CVarArg | |
protocol CharacterLiteralConvertible | |
protocol Collection |
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 | |
# All credit to @mikeash | |
echo "import Cocoa\n:print_decl $1" | /Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -integrated-repl | open -f |
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
let fd = open("/tmp/scratch.txt", O_WRONLY|O_CREAT, 0o666) | |
if fd < 0 { | |
perror("could not open /tmp/scratch.txt") | |
} else { | |
let text = "Hello World\n" | |
write(fd, text, strlen(text)) | |
close(fd) | |
} |