Skip to content

Instantly share code, notes, and snippets.

View mbigatti's full-sized avatar

Massimiliano Bigatti mbigatti

View GitHub Profile
import Foundation
class QueryResult {} // if I make this class public then the compiler says that generate has to be declared public.
// If I make generate public I get a different error...
// But QueryResult is a class which has to be public... it is part of my public API...
public class Row {}
class QueryResultGenerator : GeneratorType {
typealias Element = Row
func next() -> Element? {
anonymous
anonymous / my.css
Created December 29, 2014 16:11
CSS Gradient Animation
background: linear-gradient(330deg, #5599ae, #556eae, #9655ae);
background-size: 600% 600%;
-webkit-animation: AnimationName 28s ease infinite;
-moz-animation: AnimationName 28s ease infinite;
-o-animation: AnimationName 28s ease infinite;
animation: AnimationName 28s ease infinite;
@-webkit-keyframes AnimationName {
    0%{background-position:19% 0%}
    50%{background-position:82% 100%}
    100%{background-position:19% 0%}
@tomlokhorst
tomlokhorst / Optional+Unwrap.swift
Last active December 26, 2017 19:50
Unwrap multiple optionals in Swift 1.0
func unwrap<T1, T2>(optional1: T1?, optional2: T2?) -> (T1, T2)? {
switch (optional1, optional2) {
case let (.Some(value1), .Some(value2)):
return (value1, value2)
default:
return nil
}
}
func unwrap<T1, T2, T3>(optional1: T1?, optional2: T2?, optional3: T3?) -> (T1, T2, T3)? {
@ulrikdamm
ulrikdamm / gist:a9edb3516db7e9a13829
Created May 26, 2014 11:17
Xcide quicklook for UIColor
@interface UIColor (WBDebugExtensions)
@end
@implementation UIColor (DebugExtensions)
- (id)debugQuickLookObject {
UIGraphicsBeginImageContext(CGSizeMake(128, 128));
[self setFill];
[[UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 128, 128)] fill];
@myell0w
myell0w / BoldDynamicText
Last active January 2, 2016 14:09
Respect the accessibility setting "Bold Text" on iOS7, when implementing Dynamic Type with a custom font.
BOOL MTDIsBoldTextEnabled(void) {
static BOOL boldTextEnabled = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// Hack that checks if the "bold text" flag in the accessibility settings is enabled
UIFont *font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
boldTextEnabled = [font.fontName rangeOfString:@"MediumP4"].location != NSNotFound;
});
@JaviSoto
JaviSoto / gist:5906004
Last active June 27, 2023 10:25
Mark designated initializer at compile time
#define MSDesignatedInitializer(__SEL__) __attribute__((unavailable("Invoke the designated initializer `" # __SEL__ "` instead.")))
// Sample usage:
- (instancetype)initWithObject:(id)object;
- (instancetype)init MSDesignatedInitializer(initWithObject:); // <- This even gets auto-complete.
// Now calling init on this class would throw a warning.