Skip to content

Instantly share code, notes, and snippets.

View radianttap's full-sized avatar
🤔
· · ·

Aleksandar Vacić radianttap

🤔
· · ·
View GitHub Profile
@radianttap
radianttap / AppleiOS6MapsLegallink.m
Created September 17, 2012 10:47
Remove Legal link in Apple Maps
@radianttap
radianttap / gist:4455176
Last active August 16, 2018 08:52
Inserting child controllers in the Auto-Layout world.
// ## inserting. this can be done in viewDidLoad
// this can be any view, here I'm adding to main view
UIView *containerView = self.view;
// load child controller
UIViewController *svc = [[UIViewController alloc] initWithNibName:nil bundle:nil];
// kill the randomness
svc.view.translatesAutoresizingMaskIntoConstraints = NO;
// add child VC to hierarchy
[self addChildViewController:svc];
// set initial rect
@radianttap
radianttap / gist:4484269
Last active December 10, 2015 19:48 — forked from anonymous/gist:4468522
Pulse view
+ (void)pulseView:(UIView *)view completion:(void (^)(void))block {
// if you use auto layout, view-based transform go haywire, as they trigger layoutSubviews
// consequence is that you have no idea where the view will end up on the screen once animation completes
// see this discussion: http://stackoverflow.com/questions/12943107/how-do-i-adjust-the-anchor-point-of-a-calayer-when-auto-layout-is-being-used
// thus (per solution 4 from link above), rewriting with CAKeyframeAnimation
CAKeyframeAnimation *ka = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
ka.duration = .49;
@radianttap
radianttap / NeverCreateTabsLikeThis.mm
Created January 23, 2013 16:15
Never initialize multiple UICollectionViewControllers with the same UICollectionViewLayout instance
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// this subclass defines itemsSize as {320, 88}
MyUICollectionViewFlowLayout *l = [[MyUICollectionViewFlowLayout alloc] init];
// initialize one subclass of UICollectionViewController
MainViewController *mvc = [[MainViewController alloc] initWithCollectionViewLayout:l];
// initialize another with same layout
// but inside this init method do:
@radianttap
radianttap / daringfireball.css
Created November 16, 2013 11:03
User CSS for daringfireball.net, using Avenir Next (and its condensed variant).
body, dt, dd {
font-family: "Avenir Next", sans-serif !important;
line-height: 1.5 !important;
}
body {
font-size: 14px !important;
font-weight: 400 !important;
}
@radianttap
radianttap / dynamictypefontsize
Created January 7, 2014 18:36
Dynamic Type size for custom fonts
UIFontDescriptor *userFont = [UIFontDescriptor preferredFontDescriptorWithTextStyle:UIFontTextStyleBody];
float userFontSize = [userFont pointSize];
someLabelOrText.font = [UIFont fontWithName:@"CustomFont" size:userFontSize];
- (void)preferredContentSizeChanged:(NSNotification *)aNotification
{
UITextView *textView = <the text view holding your attributed text>
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithAttributedString:textView.attributedText];
NSRange range = NSMakeRange(0, attributedString.length - 1);
// Walk the string's attributes
[attributedString enumerateAttributesInRange:range options:NSAttributedStringEnumerationReverse usingBlock:
^(NSDictionary *attributes, NSRange range, BOOL *stop) {
@radianttap
radianttap / wwdchd.sh
Created June 4, 2014 09:14
Download HD session from WWDC 2014
curl https://developer.apple.com/videos/wwdc/2014/ | grep -iIoh 'http.*._hd_.*dl=1">HD' | sed -e 's/\?dl=1">HD//g' | xargs -n1 wget -N
@radianttap
radianttap / versioning
Created September 12, 2014 10:11
Xcode versioning based on git tags and number of builds
# Get the version number from the tag in git and the number of commits as the build number
#
appVersion=$(git describe --long | cut -f 1 -d "-")
appBuild=$(git describe --long | cut -f 2 -d "-")
#gitHash=$(git describe --long | cut -f 3 -d "-")
echo "From GIT Version = $appVersion Build = $appBuild"
#
# Set the version info in plist file
#
double ToRadians(double degrees) { return degrees * M_PI / 180; }
- (NSNumber *)geoDistanceFromLat:(CLLocationDegrees)lat1 fromLon:(CLLocationDegrees)lng1 toLat:(CLLocationDegrees)lat2 toLon:(CLLocationDegrees)lng2 {
CLLocationDistance EarthRadiusInMeters = 6367000.0;
CLLocationDistance distance = EarthRadiusInMeters * 2 *
asin(fmin(1, sqrt((pow(sin((ToRadians(lat2) - ToRadians(lat1)) / 2.0),2.0)
+
cos(ToRadians(lat1)) * cos(ToRadians(lat2))