Skip to content

Instantly share code, notes, and snippets.

View MarcoSero's full-sized avatar

Marco Sero MarcoSero

View GitHub Profile
@samdods
samdods / lldbinit
Created January 30, 2014 15:07
init file for LLDB, save this file in your home directory as .lldbinit, i.e. ~/.lldbinit
# rd: print recursive description of entire app window, or of a specified view
#
# usage: rd [view]
#
# if no view is specified, prints recursive description of app's keyWindow
#
command regex rd 's/^[[:space:]]*$/po [[[UIApplication sharedApplication] keyWindow] recursiveDescription]/' 's/^(.+)$/po [%1 recursiveDescription]/'
# slow-on: turn slow animations on, for testing on device only, and optionally set the speed
#
@lbrndnr
lbrndnr / gist:705946cb937fadeebca4
Created April 29, 2015 09:39
UIColor to init them using hex values: UIColor(0x8046A2)
extension UIColor {
convenience init(_ hexValue: Int) {
let r = (hexValue & 0xFF0000) >> 16
let g = (hexValue & 0x00FF00) >> 8
let b = hexValue & 0x0000FF
self.init(red: CGFloat(r)/255, green: CGFloat(g)/255, blue: CGFloat(b)/255, alpha: 1)
}
@wkiefer
wkiefer / gist:2366514
Created April 12, 2012 11:00
Notes on using NSURLProtocol
// The basics:
// - Write your own NSURLProtocol subclass and register it.
// - Override the 5 required methods
// - Kick off download or cache fetch during |startLoading|
// - Update self.client with progress/completion/failure notifications.
// UIWebView will download requests concurrently via NSURLProtocol.
// If you use the typical NSURLCache hook to download content, you're
// stuck with serial downloads.
@vinhnx
vinhnx / timeZoneWithName.md
Last active December 17, 2015 09:43
NSTimeZone +timeZoneWithName:

For a list of known timezone supported in NSTimeZone, log:

[NSTimeZone knownTimeZoneNames]

The full list:

(lldb) po [NSTimeZone knownTimeZoneNames]
<__NSCFArray 0x7fba91903000>(
@JaviSoto
JaviSoto / gist:5986283
Last active December 19, 2015 16:48
ms_invoke_block_if_not_nil()
#define ms_invoke_block_if_not_nil(BLOCK, ...) do { typeof((BLOCK)) b = (BLOCK); if (b) b(__VA_ARGS__); } while(0)
// Usage:
void (^block)(id, id, id) = void(^)(id parameter1, id parameter2, id parameter3) {
// ...
};
ms_invoke_block_if_not_nil(block, parameter1, parameter2, parameter3);
// As opposed to:
function lols {
random_num=$RANDOM
let "random_num %= 20"
if [ $random_num -eq 0 ]; then
alias hg="say hg && /usr/local/bin/hg"
else
alias hg="/usr/local/bin/hg"
fi
}
@aprato
aprato / AMPNavigationBar.m
Last active July 13, 2018 00:23
Darker iOS7 translucent UINavigationBar
// .h
@interface AMPNavigationBar : UINavigationBar
@property (nonatomic, assign) CGFloat extraColorLayerOpacity UI_APPEARANCE_SELECTOR;
@end
// .m
@steipete
steipete / gist:d76549ec262430354e7c
Last active December 3, 2018 23:56
Our set of warnings in PSPDFKit
//
// Warnings.xcconfig
//
// The list of warnings we (don’t) use, and the reasons why.
//
// :MARK: Warnings in use:
// :MARK: -everything
// We want the best possible diagnostics, so we simply enable everything that exists, and then opt–out of what doesn’t make sense for us.
//
// :MARK: - Warnings not to be promoted:
@ksm
ksm / UINavigationController+Fade.h
Created February 14, 2012 22:23
UINavigationController custom pop/push transition animation
/*
Copied and pasted from David Hamrick's blog:
Source: http://www.davidhamrick.com/2011/12/31/Changing-the-UINavigationController-animation-style.html
*/
@interface UINavigationController (Fade)
- (void)pushFadeViewController:(UIViewController *)viewController;
- (void)fadePopViewController;
@chriseidhof
chriseidhof / json.swift
Last active March 21, 2019 07:45
Reflection
import Cocoa
struct Person {
var name: String = "John"
var age: Int = 50
var dutch: Bool = false
var address: Address? = Address(street: "Market St.")
}
struct Address {