Skip to content

Instantly share code, notes, and snippets.

@matthiasplappert
matthiasplappert / gist:9493050
Last active August 29, 2015 13:57
QuickLook Debugging for `UIView`
@interface UIView (MPAdditions)
@end
@implementation UIView (MPAdditions)
- (id)debugQuickLookObject {
if (self.bounds.size.width < 0.0f || self.bounds.size.height < 0.0f) {
return nil;
}
/**
Allows easier pushing and popping of clang warnings.
Example (Ignoring undeclared selectors):
SQClangDiagnosticPushIgnored(-Wundeclared-selector);
SEL undeclaredSelector = @selector(thisSelectorDoesNotExist:::);
SQClangDiagnosticPop;
*/
//
// ViewController.swift
// Tetris
//
// Created by Julius Parishy on 11/19/14.
// Copyright (c) 2014 Julius Parishy. All rights reserved.
//
import UIKit
import Foundation
extension String {
var isHomogeneous: Bool {
if lengthOfBytesUsingEncoding(NSUTF8StringEncoding) == 0 {
return true
}
var homogeneous = true
var character: NSString?
@lawrencelomax
lawrencelomax / gist:1670617
Created January 24, 2012 15:09
Simple progressive image loading
UIView * view = [[UIView alloc] initWithFrame:CGRectMake( 0.0f, 0.0f, kAffirmationThumbnailWidth, kAffirmationThumbnailHeight )];
view.backgroundColor = [UIColor grayColor];
UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, kAffirmationThumbnailWidth, kAffirmationThumbnailHeight)];
imageView.backgroundColor = [UIColor clearColor];
imageView.alpha = 1.0;
[view addSubview:imageView];
// Background getting of small image and loading into memory
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){
NSString * imagePathSmall = [NSString stringWithFormat:@"%@_small.jpg",[[affirmation imagePath] stringByDeletingPathExtension]];
@milafrerichs
milafrerichs / AppleBlue.m
Created April 11, 2012 17:53
Default Apple Blue iOS Color
[UIColor colorWithRed:50.0/255.0 green:79.0/255.0 blue:133.0/255.0 alpha:1.0]
//
// OLD AND BUSTED
//
if ([self.zoomingDelegate respondsToSelector:@selector(zoomingWindow:didZoomOutViewController:)] == YES)
{
// Do something important.
}
//
@orta
orta / remove_headers.rb
Last active October 31, 2015 23:28
Remove all project headers
def should_crop(lines)
(0..6).each do |n|
return false unless lines[n].start_with? "//"
end
return false unless lines[7] = ""
true
end
all_objc = Dir.glob("Classes/**/**/**/**.{m,h}")
all_objc.each do |path|
@DrAma999
DrAma999 / gist:6554189
Created September 13, 2013 18:18
Method to be used inside a VC subclass or VC abstract class to avoid the status bar overlapping feature in iOS7. Actually tested only for single VC not added in hierachy. To use it you should embed all your view subviews into another view called tankView. It should be called before the view controller views has the opportunity to layout its view.
//This should be added before the layout of the view
- (void) adaptToTopLayoutGuide {
//Check if we can get the top layoutguide
if (![self respondsToSelector:@selector(topLayoutGuide)]) {
return;
}
//tankView is a contaner view
NSArray * array = [self.tankView referencingConstraintsInSuperviews]; //<--For this method get the Autolayout Demistified Book Sample made by Erica Sadun
[self.view removeConstraints:array];
NSArray * constraintsVertical = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[topLayoutGuide]-0-[tankView]|" options:0 metrics:nil views:@{@"tankView": self.tankView, @"topLayoutGuide":self.topLayoutGuide}];
@kimroen
kimroen / high-dpi-media.scss
Created November 20, 2012 10:24 — forked from marcedwards/high-dpi-media.css
A Sass media query mixin that captures almost all high DPI aware devices.
/* ----------------------------------------------------------------------- */
/* */
/* Improved upon a mixin from 37signals and combined */
/* with these numbers from marc. */
/* */
/* 37signals-version: */
/* http://37signals.com/svn/posts/3271-easy-retina-ready-images-using-scss */
/* */
/* @kimroen */
/* */