Skip to content

Instantly share code, notes, and snippets.

// 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 = @
@erica
erica / Font Traits per family
Last active December 18, 2015 11:29
Font Traits per family
Thonburi Family:
Thonburi-Bold: Bold
Thonburi:
Academy Engraved LET Family:
AcademyEngravedLetPlain:
Snell Roundhand Family:
SnellRoundhand-Bold: Italic, Bold
SnellRoundhand-Black: Italic, Bold
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.
@erica
erica / gist:481a34bc2a6f838dcdbe
Created June 23, 2014 16:58
Xcode seems to hate this
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()
}
//
// Bag.swift
// CmdLineTest
//
// Created by Erica Sadun on 6/23/14.
// Copyright (c) 2014 Erica Sadun. All rights reserved.
//
import Foundation
@erica
erica / gist:06d7e44f4f834757dc36
Last active April 21, 2023 17:14
Exploring
//
// explore.swift
// CmdLineTest
//
// Created by Erica Sadun on 6/25/14.
// Copyright (c) 2014 Erica Sadun. All rights reserved.
//
import Foundation
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}
protocol AbsoluteValuable
protocol ArrayBound
protocol ArrayBufferType
protocol ArrayLiteralConvertible
protocol ArrayType
protocol BidirectionalIndex
protocol BitwiseOperations
protocol CVarArg
protocol CharacterLiteralConvertible
protocol Collection
#! /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
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)
}