Skip to content

Instantly share code, notes, and snippets.

View warpling's full-sized avatar

Ryan McLeod warpling

View GitHub Profile
//
// SKAction+FadeColorAction.h
//
#import <SpriteKit/SpriteKit.h>
@interface SKAction (FadeColorAction)
+ (SKAction*) fadeColorFrom:(SKColor*)fromColor toColor:(SKColor*)toColor duration:(CGFloat)duration;
//
// MotionOrientation.h
//
// Originally based on code by Sangwon Park on 5/3/12.
// Copyright (c) 2012 tastyone@gmail.com. All rights reserved.
// Heavily modified by Ryan McLeod on 10/3/14
// Copyright (c) 2014 ryanmcleod@gmail.com. All rights reserved.
#import <CoreMotion/CoreMotion.h>
#import <CoreGraphics/CoreGraphics.h>
@warpling
warpling / extraUIActivityTypes.m
Created November 24, 2016 07:42
Extra UIActivityTypes
// UIActivityTypes
NSString * const UIActivityTypePostToInstagram = @"com.burbn.instagram.shareextension";
NSString * const UIActivityTypeFacebookMessenger = @"com.facebook.Messenger.ShareExtension";
NSString * const UIActivityTypeWhatsApp = @"net.whatsapp.WhatsApp.ShareExtension";
NSString * const UIActivityTypeTelegraph = @"ph.telegra.Telegraph.Share";
NSString * const UIActivityTypeGmail = @"com.google.Gmail.ShareExtension";
NSString * const UIActivityTypeTencent = @"com.tencent.mqq.ShareExtension";
NSString * const UIActivityTypeViber = @"com.viber.app-share-extension";
NSString * const UIActivityTypeTumblr = @"com.tumblr.tumblr.Share-With-Tumblr";
NSString * const UIActivityTypeSkype = @"com.skype.skype.sharingextension";
@warpling
warpling / CircularTextView.h
Last active March 21, 2017 23:26
CircularTextView (as seen in the iOS app Blackbox)
//
// CircularTextView.h
// Wormhole
//
// Created by Ryan McLeod on 5/5/15.
// Copyright (c) 2015 Ryan McLeod. All rights reserved.
//
#import <UIKit/UIKit.h>
@warpling
warpling / CircleBloom.h
Last active July 25, 2016 23:10
Circle Bloom!?
//
// CircleBloom.h
// Blackbox
//
// Created by Ryan McLeod on 7/25/16.
// Copyright © 2016 Ryan McLeod. All rights reserved.
//
#import <UIKit/UIKit.h>
@warpling
warpling / UIBezierPathLength.swift
Created July 21, 2016 20:38 — forked from janselv/UIBezierPathLength.swift
Get total iOS CGPath length as an extension of UIBezierPath written in swift
// The MIT License (MIT)
//
// Copyright (c) 2016 Jansel Valentin
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@warpling
warpling / README.md
Last active May 12, 2016 17:47
NSAttributedNightmare Idea

Okay, so the basic idea is markdown but customizable… Often I want a section of text to be bold, but I'm also making a byline with strange kerning, or a strikeout with different opacity, etc. I envision a system for defining markdown codes with coresponding styles per NSAttributableString (this class could be subclassed to persist styles, ala NSProductHeaderString, etc)

So imagine we have a string like: "Hello, well aren't you bold." where we want to bold the last word. With NSAttributedString we either have to hardcode the NSRange or do a substring look-up at run-time to generate a NSRange to apply the bold style, or just append the bold string with its bolding attribute. None are concise or easy to understand and change.

Now imagine we define styles:

NSDictionary *styles = @{
//
// UIView+Screengrab.h
//
//
// Created by Ryan McLeod on 7/27/15.
//
//
#import <UIKit/UIKit.h>
@warpling
warpling / CGRectGetCenter.h
Created April 2, 2016 23:09
CGRectGetCenter
#define CGRectGetCenter(rect) ({ __typeof__(rect) __r = (rect); (CGPoint) { CGRectGetMidX(__r), CGRectGetMidY(__r)}; })
@warpling
warpling / MAPRANGE.c
Last active January 26, 2017 03:57
MapRange Macro
// Maps one ascending range onto another
// Example: map a range like [-50, 100] to [0, 1.0]
#define MAPRANGE(x, inputLow, inputHigh, outputLow, outputHigh) ({\
__typeof(x) __x = (x); \
__typeof(inputLow) __inputLow = (inputLow); \
__typeof(inputHigh) __inputHigh = (inputHigh); \
__typeof(outputLow) __outputLow = (outputLow); \
__typeof(outputHigh) __outputHigh = (outputHigh); \
(((__x - __inputLow) / (__inputHigh - __inputLow)) * (__outputHigh - __outputLow)) + __outputLow; \
})