Skip to content

Instantly share code, notes, and snippets.

View NghiaTranUIT's full-sized avatar
💭
Workaholic 👨‍💻

Noah Tran NghiaTranUIT

💭
Workaholic 👨‍💻
View GitHub Profile
NSString *customURL = @"facebook://";
if ([[UIApplication sharedApplication]
canOpenURL:[NSURL URLWithString:customURL]])
{
// App fb có cài
return YES;
}
else
{
- (void) mergeAVAssetByArrAsset:(NSArray *) arrAsset
{
AVMutableComposition * composition = [AVMutableComposition composition];
for (AVAsset *asset in arrAsset)
{
CMTimeRange timeRange = CMTimeRangeMake(kCMTimeZero, asset.duration);
[composition insertTimeRange:timeRange ofAsset:asset atTime:composition.duration error:nil];
}
@NghiaTranUIT
NghiaTranUIT / gist:6aaac1fe9fd52600507a
Last active August 29, 2015 14:10
Pause video at 15th second
__weak FePreviewVideoViewController *weakSelf = self;
timeObserver = [_player addPeriodicTimeObserverForInterval:CMTimeMake(15, 1) queue:dispatch_get_main_queue() usingBlock:^(CMTime time)
{
typeof(self) strongSelf = weakSelf;
CGFloat currentTime = CMTimeGetSeconds(time);
if (currentTime >= 15)
{
[strongSelf.player pause];
-(void) addNewItemFromArray:(NSArray *) newArrItem
{
// Add
[_arrPhotos addObjectsFromArray:newArrItem];
NSMutableArray *arrNewIndexpath = [NSMutableArray array];
for (NSInteger i = _arrPhotos.count ; i < _arrPhotos.count + newArrItem.count ; i++)
{
NSIndexPath *newIndexPath = [NSIndexPath indexPathForRow:i inSection:0];
[arrNewIndexpath addObject:newIndexPath];
@interface UIImage (Orientation)
- (UIImage*)imageByNormalizingOrientation;
@end
@implementation UIImage (Orientation)
- (UIImage*)imageByNormalizingOrientation {
// Add catefory
@interface UIButton (Sound)
@end
#import "UIButton+Sound.h"
#import <objc/runtime.h>
@implementation UIButton (Sound)
@NghiaTranUIT
NghiaTranUIT / BaseModel.h
Created November 16, 2015 12:53 — forked from onmyway133/BaseModel.h
BaseModel Model -> SQLite statement using property inspection
#import <Mantle.h>
@interface BaseModel : MTLModel <MTLJSONSerializing>
@property (nonatomic) int64_t id;
@property (nonatomic) NSTimeInterval createdUtc;
@property (nonatomic) NSTimeInterval modifiedUtc;
- (NSString *)createTableStatement;
- (NSString *)className;
@NghiaTranUIT
NghiaTranUIT / PSPDFUIKitMainThreadGuard.m
Created November 25, 2015 14:35 — forked from steipete/PSPDFUIKitMainThreadGuard.m
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.
#import <objc/runtime.h>
#import <objc/message.h>
// Compile-time selector checks.
@NghiaTranUIT
NghiaTranUIT / introrx.md
Created February 19, 2016 13:54 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing

Difference between Debounce and Throttle

Debounce

Debounce a function when you want it to execute only once after a defined interval of time. If the event occurs multiple times within the interval, the interval is reset each time.
Example A user is typing into an input field and you want to execute a function, such as a call to the server, only when the user stops typing for a certain interval, such as 500ms.

Throttle