Skip to content

Instantly share code, notes, and snippets.

View warpling's full-sized avatar

Ryan McLeod warpling

View GitHub Profile
@uebo
uebo / Default-568h@2x.png
Last active October 12, 2022 01:41
iOS Sample Launch Screen File
Default-568h@2x.png
@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
@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;
}
@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.

@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);
@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,
]
@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 {
@janselv
janselv / UIBezierPathLength.swift
Last active March 8, 2023 08:20
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:
@MattesGroeger
MattesGroeger / CAMediaTimingFunctionExtension.swift
Created August 12, 2016 14:47
This Swift extension allows to use more timing functions than the default ones provided by `CAMediaTimingFunction`. It's based on the work of Christian Giordano: https://gist.github.com/nuthinking/7415509
import QuartzCore
enum BezierType {
case Default
case Linear
case EaseIn
case EaseOut
case EaseInOut
@sgr-ksmt
sgr-ksmt / file.swift
Created September 26, 2016 05:55
Safe DispatchQueue.main.sync (Swift3.0)
extension DispatchQueue {
class func mainSyncSafe(execute work: () -> Void) {
if Thread.isMainThread {
work()
} else {
DispatchQueue.main.sync(execute: work)
}
}
class func mainSyncSafe<T>(execute work: () throws -> T) rethrows -> T {