Skip to content

Instantly share code, notes, and snippets.

View libdx's full-sized avatar

Alexander Ignatenko libdx

View GitHub Profile
#!/usr/bin/ruby
projects = Dir.glob("*.xcworkspace") + Dir.glob("*.xcodeproj")
if projects.count > 1
puts "Choose file to open:"
projects.each_index do |i|
num = i + 1
puts "#{num}: #{projects[i]}"
end
class ConstraintAttribute
attr_reader :name
attr_reader :multiplier
attr_reader :constraint
attr_reader :relation
def initialize(constraint, name)
@constraint, @name = constraint, name
@constant, @multiplier = 0, 1
end
@interface ActionSheetItem : NSObject
@property (copy, nonatomic) NSString *title;
@property (nonatomic, getter=isDestructive) BOOL destructive;
@property (nonatomic, getter=isCancel) BOOL cancel;
@property (copy, nonatomic) void (^actionBlock)();
@property (nonatomic) SEL action;
@libdx
libdx / str.m
Last active August 29, 2015 14:04
#define str(T) _Generic( (T), SEL: NSStringFromSelector, Class: NSStringFromClass) (T)
NSString *cancelAction = str(@selector(cancel:));
NSString *objectClassName = str([NSObject class]);
class String
def discover
puts self + ' ' + self.ord.to_s(16)
end
end
# Аа Бб Вв Гг Дд Єє Ее
# Жж Ѕѕ Ꙁꙁ Ии Іі Її Ћћ
# Кк Лл Мм Нн Оо Пп Рр
# Сс Тт Уу Ꙋꙋ Фф Хх Ѿѿ
@interface MyManagedObjectContext : NSManagedObjectContext
- (instancetype)main;
- (instancetype)newBackground;
- (instancetype)newUI;
- (NSArray *)fetch:(id)query;
- (id)fetchFirst:(id)query;
protocol Attributed {
var attrs: Attrs { get }
}
struct Attrs {
let name: String
let sortBy: String
let keyPath: [String]
// init has defaults
//: Playground - noun: a place where people can play
import UIKit
protocol AnyValidator {
func validate(any: Any) -> Bool
}
protocol Validator: AnyValidator {
associatedtype Value
interface Transformer<A, B> {
B.Element transform(A.Element a);
}
// Abstract interface
protocol Interactor: class {
associatedtype Action
func dispatch(action: Action)
init()
}
protocol Presenter: class {
associatedtype State