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 | |
@infix func ==(lhs: NSDate, rhs: NSDate) -> Bool { | |
return lhs == rhs | |
} | |
@infix func <=(lhs: NSDate, rhs: NSDate) -> Bool { | |
return !(lhs > rhs) | |
} | |
@infix func >=(lhs: NSDate, rhs: NSDate) -> Bool { |
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 Comparable : Equatable { | |
func <=(lhs: Self, rhs: Self) -> Bool | |
func >=(lhs: Self, rhs: Self) -> Bool | |
func >(lhs: Self, rhs: Self) -> Bool | |
} |
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
- (instancetype)initWithFoo:(id)foo | |
{ | |
self = [super initWithFoo:foo]; | |
if (!self) { | |
return nil; | |
} | |
_foo = foo; | |
return self; | |
} |
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 users = ["klausa_qwpx", "macoscope"] | |
func getTweetsForUser(userName: String, completion: AnyObject? -> Void) { | |
let parameters: [String:AnyObject] = ["screen_name": userName, "include_rts": true, | |
"count": 5, "include_entities": true] | |
Alamofire.request(.GET, "https//api.twitter.com/1/statuses/user_timeline.json", parameters: parameters) | |
.responseJSON { (_, _, json, _) in | |
if let json = json { | |
completion(json) |
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 TestClass { | |
var aStruct: MyStruct; | |
init(inout initialStruct: MyStruct) { | |
aStruct = initialStruct; | |
} | |
func changeValueTo(newValue: Int) { | |
aStruct.aValue = newValue; | |
} |
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
/* Explanation: I need to have a string that says "x days ago" BUT, if there's a word in the languague for it | |
(like "yesterday" in english, or "gestern" and "vorgestern" in geman), use that instead. Obviously, it needs to | |
support multiple languages, so no hardcoding of strings if possible. | |
I've inherited a .stringsdict with "x days ago" in some languages (that's the @"RELATIVE_DAYS_NEGATIVE"). | |
I wanna avoid having external dependency just for that, but can be convinced otherwise. | |
How horrible is this? | |
*/ |
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
# Reactive Cocoa 5 crash-course | |
##👋 | |
I sincerely hate most RAC/RAS/FRP/WTF/BBQ (MOAR three letter acronyms is what programming needs, definitely) that start with "oh, Reactive Cocoa is a framework for working with streams of values over time" or some other similar word-soup. | |
If you understand it already, I'm sure it makes sense, for newcomers it's absolutely horrible and impenetrable. | |
Hopefully this will be more digestible. |
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
(lldb) po [NSBundle mainBundle] | |
NSBundle </var/containers/Bundle/Application/FD1BE089-EFC8-469A-AA95-84FE25E47201/WordPress.app> (loaded) | |
(lldb) po [[NSFileManager defaultManager] contentsOfDirectoryAtPath:@"/var/containers/Bundle/Application/FD1BE089-EFC8-469A-AA95-84FE25E47201/WordPress.app/WordPress.momd" error:nil] | |
<__NSArrayM 0x1c4048ee0>( | |
WordPress 67.mom, | |
WordPress 66.mom, | |
WordPress 68.omo, | |
WordPress 58.mom, | |
WordPress 64.mom, |
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 | |
# Useful for downloading Xcode on machines where you don't want to log-in with your Apple ID (e.g. CI | |
# machines, or other low-trust environemnts). | |
# Requires you to manually log-in to the Apple Dev Portal, and extract contents of the ADCDownloadAuth cookie | |
# (easiest way to do it is using Web Inspector, going to the "Storage" Pane, selecting "Cookies" in the left sidebar, | |
# and copying the appropriate value. | |
# | |
# Usage: | |
# curl https://gist.githubusercontent.com/jklausa/5780d5126d97f73b70a91aeab58f7f4a/raw/ | bash -s -- XCODE-URL COOKIE_VALUE |
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
created by running: find . -type f -perm +111 -exec sh -c "file \"{}\" | head -n 1" \; | grep Mach-O > ~/macho-s | |
and then cat ~/macho-s | grep -v arm64 | |
./Developer/usr/share/xcs/CouchDB/bin/makeconv: Mach-O 64-bit executable x86_64 | |
./Developer/usr/share/xcs/CouchDB/bin/gencnval: Mach-O 64-bit executable x86_64 | |
./Developer/usr/share/xcs/CouchDB/bin/gencfu: Mach-O 64-bit executable x86_64 | |
./Developer/usr/share/xcs/CouchDB/bin/icuinfo: Mach-O 64-bit executable x86_64 | |
./Developer/usr/share/xcs/CouchDB/bin/gendict: Mach-O 64-bit executable x86_64 |