Skip to content

Instantly share code, notes, and snippets.

View warpling's full-sized avatar

Ryan McLeod warpling

View GitHub Profile
@ZevEisenberg
ZevEisenberg / map float range.swift
Last active July 13, 2020 20:31
Mapping floating point numbers between two ranges in Swift
import QuartzCore
extension CGFloat {
func map(from from: ClosedInterval<CGFloat>, to: ClosedInterval<CGFloat>) -> CGFloat {
let result = ((self - from.start) / (from.end - from.start)) * (to.end - to.start) + to.start
return result
}
}
extension Double {
@zacwest
zacwest / ios-font-sizes.swift
Last active July 20, 2026 07:45
iOS default font sizes - also available on https://www.iosfontsizes.com
let styles: [UIFont.TextStyle] = [
// iOS 17
.extraLargeTitle, .extraLargeTitle2,
// iOS 11
.largeTitle,
// iOS 9
.title1, .title2, .title3, .callout,
// iOS 7
.headline, .subheadline, .body, .footnote, .caption1, .caption2,
]
@leonaka
leonaka / gist:51c1de59b64c863932f0
Created March 25, 2015 18:17
Tumblr- and Tweetbot-like view on top of UIActivityViewController, with appearance animation (put it on a subclass of UIActivityViewController)
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
CGFloat distance = 10.0;
[self.transitionCoordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
[UIView performWithoutAnimation:^{
self.effectView.frame = CGRectMake(0, self.view.frame.size.height - self.effectView.frame.size.height - distance, self.view.frame.size.width, self.effectView.frame.size.height);
}];
self.effectView.frame = CGRectMake(0, -self.effectView.frame.size.height - distance), self.view.frame.size.width, self.effectView.frame.size.height);
@geekmanager
geekmanager / make-git-use-sublime.markdown
Last active May 7, 2025 12:34
Making git use Sublime Text for rebase etc

Making git use Sublime Text

First up, let's make Sublime Text 2 available from the command line in terminal, by creating a link to subl which is the launcher from terminal:

ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime

(added bonus of this approach is when you upgrade to ST3 or change text editor, you can just redirect the symlink).

If there's any chance that bash doesn't check usr/local/bin then use [Launch Sublime Text 2 from Mac OSX Terminal] for more detailed instructions on how to make this happen.

@warpling
warpling / Pretty Device Identifiers
Created February 4, 2015 01:33
Apple Device Model Names (as of Jan 2015)
// Modified from: http://www.techrepublic.com/blog/software-engineer/better-code-determine-device-types-and-ios-versions/
+ (NSString *) platformRawString {
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = malloc(size);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
NSString *platform = [NSString stringWithUTF8String:machine];
free(machine);
return platform;
}
@danielchasehooper
danielchasehooper / count.sh
Created October 23, 2014 21:10
Count the lines of code in the current directory
#!/bin/sh
find . \( -iname "*.[chm]" -o -iname "*.swift" -o -iname "*.cpp" -o -iname "*.mm" \) -print0 | xargs -0 cat | wc -l
@uebo
uebo / Default-568h@2x.png
Last active October 12, 2022 01:41
iOS Sample Launch Screen File
Default-568h@2x.png
@d-ronnqvist
d-ronnqvist / Thoughts on removedOnCompletion in SparkRecordingCircle.md
Last active May 16, 2020 02:51
What I think is wrong with the Spark Recording Circle code and why

There was [a tweet][tweetSoto] a couple of days ago that resulted in a discussion/question about what it wrong with the usage of removedOnCompletion = NO in the [SparkRecordingCircle code][code] for that [Subjective-C post][post].

We all kept saying that the explanation doesn't fit in a tweet, so here is my rough explanation about the issues.

But, let me first say that I think that the Subjective-C articles are reallt cool and useful to learn from. This is trying to reason about the general usage of removedOnCompletion = NO, using that code as an example, since that was what was discussed on twitter.


The root problem, as [Nacho Soto pointed out][rootProblem], is that removedOnCompletion = NO in combination with fillMode = kCAFillModeForwards is almost always used when you are not updating the model layer. This means that after the animation has finished, what you see on screen is not reflected in the property of the layer. The biggest issue that this can cause is that all the

@razwan
razwan / _baseline.scss
Created April 14, 2014 16:20
Aligning type to baseline the right way with SASS
$base-font-size: 16px;
$base-line-height: 1.5;
// this value may vary for each font
// unitless value relative to 1em
$cap-height: 0.68;
@mixin baseline($font-size, $scale: 2) {
@raphaelschaad
raphaelschaad / RSPlayPauseButton.h
Last active July 25, 2016 21:44
Edit: this Gist has now a proper repo and even a CocoaPod: https://github.com/raphaelschaad/RSPlayPauseButton
//
// RSPlayPauseButton.h
//
// Created by Raphael Schaad on 2014-03-22.
// This is free and unencumbered software released into the public domain.
//
#import <UIKit/UIKit.h>