Skip to content

Instantly share code, notes, and snippets.

@mciuba
mciuba / AmSymbolsForLocales.swift
Last active May 22, 2018 07:44
AM Symbols in different Locales in Foundation
let locales = Locale.availableIdentifiers.map(Locale.init(identifier:))
let dateFormatter = DateFormatter()
var amSymbols = Set<String>()
for locale in locales {
dateFormatter.locale = locale
guard let amSymbol = dateFormatter.amSymbol else {
continue
import Foundation
public protocol PriceFormatting {
var locale: Locale { get }
func format(price: Decimal) -> String?
}
public extension PriceFormatting {
func format(price: Decimal) -> String? {
import Foundation
public extension Never {
static func gonnaGiveYouUp() -> String {
return "gonna give you up"
}
static func gonnaLetYouDown() -> String {
return "gonna let you down"
}
#!/bin/bash
#modified script from: http://stackoverflow.com/a/5396755/2128900
# Git lets you use very readable time formats!
cutoff_time="1 week ago"
# other examples:
# cutoff_time="July 23, 2010"
# cutoff_time="yesterday"
@mciuba
mciuba / NSDataExample.m
Created November 23, 2015 13:14
NSData example
- (NSUInteger)responseLenght
{
NSData *lenghtData = [self.responseData subdataWithRange:NSMakeRange(0, 4)];
int lenght;
[lenghtData getBytes:&lenght length:sizeof(lenght)];
return lenght;
}
@mciuba
mciuba / gist:9e8c6f31408a336b3749
Created April 18, 2015 13:56
RAC combineLatest:reduce: sample
[[RACSignal combineLatest:@[connectUsersSignal, facebookUsersSignal, applicationUsersSignal] reduce:^id(NSArray *first, NSArray *second, NSArray *third) {
return [[first arrayByAddingObjectsFromArray:second] arrayByAddingObjectsFromArray:third];
}]
subscribeNext:^(NSArray *allUsers) {
//Do something
}];
// in a UITableView subclass
@interface TestTableViewCell ()
@property (strong, nonatomic) UIView *mainView;
@end
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
find . -not -path '*/Pods/*' -a \( -name '*.m' \) | xargs wc -l | sort -r | more
#!/bin/sh
# put this in file 'pre-commit' in .git/hooks
# file has to be marked as executable (+x)
#don't commit if FIXME was found in diff
exec 1>&2
DONT_COMMIT_MARKER="FIXME"
if [ $(git diff --cached -G "$DONT_COMMIT_MARKER"|wc -l) != 0 ]; then
git --no-pager diff --cached -G "$DONT_COMMIT_MARKER"