Skip to content

Instantly share code, notes, and snippets.

@rickytan
rickytan / RTRouter.h
Created October 17, 2016 14:01
A app router designation
#import <Foundation/Foundation.h>
@class RTRouter;
typedef void(^RTRouteCompleteBlock)(void);
@protocol RTRoutable <NSObject>
@optional
+ (BOOL)routerDidRoutePattern:(NSString *)pattern
withParameters:(id)parameters
import requests
import sys
import os
import json
MAX_PAGE = 10
def get_projects(gitlab_site,private_token):
projects = []
@cyndibaby905
cyndibaby905 / NSNUll+ InternalNullExtention.m
Created March 28, 2014 09:23
NSNUll+ InternalNullExtention.m
#define NSNullObjects @[@"",@0,@{},@[]]
@interface NSNull (InternalNullExtention)
@end
@implementation NSNull (InternalNullExtention)
@onevcat
onevcat / orientation-in-framework.m
Created October 28, 2014 02:43
Swizzle to solve Landscape mode in a Portrait app. Can be used in third party framework. If you are working on an app, you can only modify the app delegate to achieve it.
#pragma mark - Magic
// Need for supporting orientation when not supported in host app plist.
// Swizzle original -application:supportedInterfaceOrientationsForWindow: to change supported orientation in runtime.
-(void) swizzleSupportedInterfaceOrientationsForWindow
{
Class applicationDelegateClass = [[UIApplication sharedApplication].delegate class];
Class sdkClass = [self class];
SEL originalSelector = @selector(application:supportedInterfaceOrientationsForWindow:);
SEL swizzledSelector = @selector(las_application:supportedInterfaceOrientationsForWindow:);
@zwaldowski
zwaldowski / NSObject+Blocks.h
Created May 4, 2011 12:08
Perform blocks with delays and cancellation
//
// NSObject+Blocks.h
// Filemator
//
// Created by Zachary Waldowski on 4/12/11.
// Copyright 2011 Dizzy Technology. All rights reserved.
//
@interface NSObject (Blocks)
@natecook1000
natecook1000 / NSCalendar+Swift.swift
Created March 18, 2015 03:08
Swift-friendly NSCalendar methods
// NSCalendar+Swift.swift
// A set of Swift-idiomatic methods for NSCalendar
//
// (c) 2015 Nate Cook, licensed under the MIT license
extension NSCalendar {
/// Returns the hour, minute, second, and nanoseconds of a given date.
func getTimeFromDate(date: NSDate) -> (hour: Int, minute: Int, second: Int, nanosecond: Int) {
var (hour, minute, second, nanosecond) = (0, 0, 0, 0)
getHour(&hour, minute: &minute, second: &second, nanosecond: &nanosecond, fromDate: date)
@matej
matej / CALayer+MBAnimationPersistence.h
Last active February 16, 2023 18:43
Persists (pauses) layer animations (including UIView animation generated animations) when the application enters into background and restores (resumes) animations from where they left off upon returning from background.
//
// CALayer+MBAnimationPersistence.h
//
// Created by Matej Bukovinski on 19. 03. 14.
// Copyright (c) 2014 Matej Bukovinski. All rights reserved.
//
#import <QuartzCore/QuartzCore.h>
@OliverLetterer
OliverLetterer / XCDUUID.m
Created January 26, 2013 17:05
With this gist, I, as a total assembly noob, am trying to understand the XCDUUID runtime hack (https://github.com/0xced/NSUUID/blob/1.0.1/NSUUID.m#L167-L221) to be able to use NSUUID on iOS < 6.0.
@implementation XCDUUID
+ (void) load
{
// query runtime if NSUUID class already exists, if so => done
if (objc_getClass("NSUUID"))
{
return;
}
//
// ViewController.m
// AVPlayerCaching
//
// Created by Anurag Mishra on 5/19/14.
// Sample code to demonstrate how to cache a remote audio file while streaming it with AVPlayer
//
#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>
@mayoff
mayoff / UIBezierPath+forEachElement.h
Created December 2, 2012 06:51
dragging an object along a CGPath on iOS demo
#import <UIKit/UIKit.h>
@interface UIBezierPath (forEachElement)
- (void)forEachElement:(void (^)(CGPathElement const *element))block;
@end