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
class F<A> { | |
} | |
protocol Functor { | |
typealias A | |
typealias B | |
typealias FA = F<A> | |
typealias FB = F<B> | |
func fmap(a: FA, fn: (A -> B)) -> FB | |
} |
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: Wanted: Generalized chaining | |
Summary: | |
Swift's Optional chaining is super cool. | |
It'd be really really cool if we could generalize that (monads!) to Haskell-like do-syntax. | |
Steps to Reproduce: | |
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
func renderForm(state: State) -> Element<State> { | |
let incButton = Button(title: "Increment", fn: { mapCount($0, inc) }) | |
|> sizeToFit | |
|> offset(0, 40) | |
let decButton = Button(title: "Decrement", fn: { mapCount($0, dec) }) | |
|> sizeToFit | |
let count = Label<State>(text: "\(state.count)") | |
|> sizeToFit |
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/bash | |
echo "*** Removing saved user…" | |
rm -rf "${HOME}/Library/Application Support/GitHub for Mac/usersByServer.plist" | |
echo "*** Removing keychain items…" | |
security -q delete-internet-password -s github.com/mac | |
security -q delete-generic-password -l 'GitHub for Mac — github.com' |
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
CGRect newFrame = [view.superview convertRect:view.frame toView:nil]; | |
[view.window addSubview:view]; | |
view.frame = newFrame; |
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
CGRect newFrame = [newSuperview convertRect:view.frame fromView:nil]; | |
[newSuperview addSubview:view]; | |
view.frame = newFrame; |
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
- (void)floatIntoWindow { | |
if(self.superview == self.window) return; | |
CGRect newFrame = [self.superview convertRect:self.frame toView:nil]; | |
[self.window addSubview:self]; | |
self.transform = [self transformForCurrentInterfaceOrientation]; | |
self.frame = newFrame; | |
} | |
- (void)unfloatIntoView:(UIView *)newSuperview { |
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
- (NSSize)sizeWithSize:(NSSize)size { | |
if([self length] < 1) return NSZeroSize; | |
NSTextContainer *textContainer = [[[NSTextContainer alloc] initWithContainerSize:size] autorelease]; | |
NSTextStorage *textStorage = [[[NSTextStorage alloc] initWithAttributedString:self] autorelease]; | |
NSLayoutManager *layoutManager = [[[NSLayoutManager alloc] init] autorelease]; | |
[layoutManager addTextContainer:textContainer]; | |
[textStorage addLayoutManager:layoutManager]; | |
[layoutManager setHyphenationFactor:0.0]; |
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
NSString *base64Encode(NSData *data); | |
NSString *base64Encode(NSData *data) { | |
BIO *context = BIO_new(BIO_s_mem()); | |
BIO *command = BIO_new(BIO_f_base64()); | |
context = BIO_push(command, context); | |
BIO_write(context, [data bytes], (int) [data length]); | |
(void) BIO_flush(context); | |
char *outputBuffer; |
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
NSIndexSet *matches = [self.elements indexesOfObjectsWithOptions:NSEnumerationConcurrent | |
passingTest:(BOOL ^(ChiroXMLElement *element, NSUInteger index, BOOL *stop){ | |
return (BOOL)([name compare:element.tag options:options] == NSOrderedSame); | |
}) | |
]; |
OlderNewer