Skip to content

Instantly share code, notes, and snippets.

View saiday's full-sized avatar
:shipit:
su su su

Saiday saiday

:shipit:
su su su
View GitHub Profile
@saiday
saiday / HysteriaPlayerManager.h
Created March 14, 2014 17:05
HysteriaPlayerManager
@interface HysteriaPlayerManager : NSObject
+ (instancetype)sharedInstance;
- (void)setupNewSourceGetter:(id)responseObject;
@end
@saiday
saiday / HysteriaPlayerManager.m
Created March 14, 2014 17:06
HysteriaPlayerManager
#import "PlayingItems.h"
#import "Song.h"
#import <HysteriaPlayer.h>
@implementation HysteriaPlayerManager
static HysteriaPlayerManager *_sharedInstance = nil;
static dispatch_once_t onceToken;
+ (instancetype)sharedInstance
@saiday
saiday / PlayerViewController.h
Created March 14, 2014 19:32
PlayerViewController with HysteriaPlayerDelegate protocol
#import <HysteriaPlayer.h>
@interface PlayerViewController : UIViewController <HysteriaPlayerDelegate>
@end
@saiday
saiday / PlayerViewController.m
Created March 14, 2014 19:54
add/remove delegates
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[[HysteriaPlayer sharedInstance] addDelegate:self];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
@saiday
saiday / PlayerViewController.m
Created March 14, 2014 19:56
HysteriaPlayerDelegate protocl
- (void)hysteriaPlayerCurrentItemChanged:(AVPlayerItem *)item
{
[self updateCurrentItem];
}
- (void)hysteriaPlayerRateChanged:(BOOL)isPlaying
{
[self updateInterfaceState:isPlaying];
}
import lldb
import re
import shlex
# This script allows Xcode to selectively ignore Obj-C exceptions
# based on any selector on the NSException instance
def getRegister(target):
if target.triple.startswith('x86_64'):
return "rdi"
@saiday
saiday / My Release Build Scheme Pre-Action shell script
Last active August 29, 2015 14:10
My Release Build Scheme Pre-Action shell script
#!/bin/sh
# xcode-build-number-generator.sh
# @desc Automaticvally create build number every time using curent day, month and year
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
- (void)findMisbehavingScrollViews
{
UIView *view = [[UIApplication sharedApplication] keyWindow];
[self findMisbehavingScrollViewsIn:view];
}
- (void)findMisbehavingScrollViewsIn:(UIView *)view
{
if ([view isKindOfClass:[UIScrollView class]])
{
@saiday
saiday / NSArray+Extensions
Created March 6, 2015 13:22
NSArray group by
- (NSDictionary *)groupByKey:(NSString *)key
{
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
for (id obj in self) {
id keyValue = [obj valueForKey:key];
if (keyValue) {
NSMutableArray *array = dictionary[keyValue];
if (!array) {
array = [NSMutableArray array];
@saiday
saiday / NSArray+Extensions
Created March 6, 2015 13:24
NSArray shuffle items
- (NSArray *)shuffle
{
NSUInteger count = [self count];
NSMutableArray *mutableArray = [NSMutableArray arrayWithArray:self];
for (NSUInteger i = 0; i < count; ++i) {
NSInteger remainingCount = count - i;
NSInteger exchangeIndex = i + arc4random_uniform((u_int32_t )remainingCount);
[mutableArray exchangeObjectAtIndex:i withObjectAtIndex:exchangeIndex];
}