Skip to content

Instantly share code, notes, and snippets.

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

Aleksandar Vacić radianttap

🤔
· · ·
View GitHub Profile
@radianttap
radianttap / wwdc17.sh
Created June 7, 2017 09:57
Bash script to download all HD videos + PDF slides for WWDC 2017
#!/bin/bash
#Setup the environnement
mkdir wwdc2017
cd wwdc2017
mkdir tmp_download
cd tmp_download
#Extract IDs
echo "Downloading the index"
@radianttap
radianttap / human.swift.motemplate
Last active November 13, 2016 14:57 — forked from JoshuaSullivan/human.swift.motemplate
Better mogenerator Swift 3 templates, using code very similar to what Xcode produces but with mogenerator goodies on the top
import Foundation
import CoreData
@objc(<$managedObjectClassName$>)
public class <$managedObjectClassName$>: <$customSuperentity$> {
// MARK: - Life cycle methods
public override init(entity: NSEntityDescription, insertInto context: NSManagedObjectContext?) {
super.init(entity: entity, insertInto: context)
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))
@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
#
@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
- (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 / 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];
@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 / 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 / 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;