Skip to content

Instantly share code, notes, and snippets.

View dasdom's full-sized avatar

Dominik Hauser dasdom

View GitHub Profile
import UIKit
@objc protocol TransitionInfoProtocol {
var view: UIView! { get set }
func viewsToAnimate() -> [UIView]
func copyForView(subView: UIView) -> UIView
optional func frameForView(subView: UIView) -> CGRect
}
import AddressBookUI
let picker = ABPeoplePickerNavigationController()
picker.peoplePickerDelegate = self
presentViewController(picker, animated: true, completion: nil)
@dasdom
dasdom / createButton.swift
Last active August 29, 2015 14:16
A closure to reuse button creation code.
import UIKit
let makeButton = { (title: String) -> UIButton in
let button = UIButton.buttonWithType(.System) as UIButton
button.setTranslatesAutoresizingMaskIntoConstraints(false)
button.layer.cornerRadius = 5
button.layer.borderWidth = 1.0
button.layer.borderColor = UIColor.yellowColor().CGColor
button.setTitle(title, forState: .Normal)
return button
#!/usr/bin/perl -w
use strict;
if (not defined($ARGV[1])) {
die "usage: $0 <class name> <file with property names>\n";
}
open(PROP, $ARGV[1]) || die "could not open property names file: $!\n";
@dasdom
dasdom / gist:7355562
Last active December 27, 2015 16:29
Code to move the cursor in a UITextView with a pan.
- (void)panHappend:(UIPanGestureRecognizer*)sender
{
if (sender.state == UIGestureRecognizerStateBegan)
{
self.startRange = self.postTextView.selectedRange;
}
NSRange selectedRange = {MAX(self.startRange.location+(NSInteger)([sender translationInView:self.view].x/8.0f), 0), 0};
self.postTextView.selectedRange = selectedRange;
}
@dasdom
dasdom / DDHLanguageDetection.m
Last active August 23, 2018 14:39
Language detection in iOS. This code is used to add the language to a post in my ADN client hAppy. This is pubic domain. To with it what every you like!
NSString *languageGuessedString;
if (postString.length < 60) {
languageGuessedString = nil;
} else {
NSArray *componentsArray = [postString componentsSeparatedByString:@" "];
NSMutableString *mutablePostString = [NSMutableString string];
for (NSString *string in componentsArray) {
if ([string rangeOfString:@"@"].location != NSNotFound) {
continue;