Skip to content

Instantly share code, notes, and snippets.

@shaps80
shaps80 / 1. UserDefaults+Key.swift
Last active September 25, 2020 08:29
Adds a Swift extension to make UserDefaults more consistent to work with.
//
// UserDefaults.swift
//
// Created by Shaps Benkau on 24/05/2018.
// Copyright © 2018 152percent Ltd. All rights reserved.
//
import Foundation
#if os(iOS)
@Krelborn
Krelborn / Sync.swift
Created May 23, 2015 10:46
Simple way to perform an asynchronous closure synchronously. Useful for unit testing synchronous calls like NSURLSession etc.
/**
* Simple way to perform an asynchronous closure synchronously
*
* Simply use the **run** method to execute the given closure that executes something with an
* asynchronous closure and signal when its complete.
*
* Sync.run { sync in somethingWithAsyncCallback { sync.signal() } }
*/
public struct Sync {
private var semaphore: dispatch_semaphore_t
@JaviSoto
JaviSoto / gist:6516942
Created September 10, 2013 22:57
iOS 7 Parallax effect
@interface UIView (JSParallaxEffect)
- (void)js_addParallaxEffectWithMaxOffset:(CGFloat)maxOffset;
@end
@seifsallam
seifsallam / bash_profile.sh
Last active December 21, 2015 07:29
This the bash_profile for my local development settings. ( Command + Name ) or ( Command + Project initials ) or ( Command Initials ) Hope this helps, if you have more tips, I'd love to hear them.
# Color Terminal
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
# Local Settings
alias ebash='vim ~/.bash_profile' # Edit bash
alias sbash='source ~/.bash_profile' # Source Bash
alias evars='vim ~/.rbenv/vars' # Edit rbenv Variables
alias pvars='rbenv vars' # Print rbenv Variables
@orta
orta / gist:6138581
Last active April 19, 2020 15:52
Objective-C Documentation discussion
TLDR
If you want the simplest option just start /** [content] */ slashes in your header files. Do it before the @implementation for class comments and above methods for method documentation.
Doing this is the minimal for support in LLVM and Appledoc, which means you get CocoaDocs & XCode support.
Not TLDR
Good examples:
https://github.com/marcransome/MRBrew/blob/master/MRBrew/MRBrew.h
https://github.com/AFNetworking/AFNetworking/blob/master/AFNetworking/AFHTTPClient.h
@seifsallam
seifsallam / asknative gems.md
Last active December 18, 2015 12:39
Gems used for asknative's Ruby on Rails API

Gemfile

  • Mongoid for mongodb communication
  • Devise for authentication and oAuth
  • Active Model Serializer for JSON formatting. Alot cleaner and faster than hash views solutions like RABL
  • Api versions for versioning API
  • Sidekiq for background jobs. Awesome dashboard and alot easier (with less bugs) than resque
  • HTTParty for sending push notifications to pushbots
  • SendGrid for sending emails
  • LetterOpener for viewing emails in the browser (Development)
  • Roadie for compiling css to be inline for emails
@chriseidhof
chriseidhof / classes.sh
Last active December 18, 2015 03:48
All classes in iOS Execute this in e.g. "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk/System/Library/Frameworks" or /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks
#!/bin/sh
All classes in iOS
Execute this in e.g. "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk/System/Library/Frameworks"
(find . -name "*.h" -type f -exec grep "@interface" {} \;) | sed -E 's/^.*\@interface[ \t]+([a-zA-Z0-9]+).*/\1/' | sort | uniq
@steipete
steipete / PSPDFUIKitMainThreadGuard.m
Last active March 10, 2024 19:23
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
// PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit.
#import <objc/runtime.h>
#import <objc/message.h>
@mattt
mattt / uiappearance-selector.md
Last active March 19, 2024 12:52
A list of methods and properties conforming to `UIAppearance` as of iOS 12 Beta 3

Generate the list yourself:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep UI_APPEARANCE_SELECTOR ./*     | \
  sed 's/NS_AVAILABLE_IOS(.*)//g'     | \
  sed 's/NS_DEPRECATED_IOS(.*)//g'    | \
  sed 's/API_AVAILABLE(.*)//g'        | \
  sed 's/API_UNAVAILABLE(.*)//g'      | \
 sed 's/UI_APPEARANCE_SELECTOR//g' | \