Skip to content

Instantly share code, notes, and snippets.

@manmal
manmal / SynthesizeSingleton.h
Created March 11, 2012 13:55
Synthesize Singleton
#define SYNTHESIZE_SINGLETON_FOR_CLASS_WITH_CUSTOM_METHOD_NAME(classname, methodname) \
\
static classname *shared##classname = nil; \
\
+ (classname *)methodname \
{ \
@synchronized(self) \
{ \
if (shared##classname == nil) \
{ \
@manmal
manmal / TabManager.java
Created March 13, 2012 10:13
Tabmanager for using a TabHost with fragments.
import java.util.HashMap;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;
@manmal
manmal / AVPlayer+MOAdditions.m
Created April 24, 2012 11:42
AVPlayer URL & volume Additions
#import "AVPlayer+MOAdditions.h"
#include <CoreMedia/CMBase.h>
#import "AVPlayerItem+MOAdditions.h"
@implementation AVPlayer (MOAdditions)
- (NSURL *)currentURL {
AVAsset *asset = self.currentItem.asset;
if ([asset isMemberOfClass:[AVURLAsset class]])
return ((AVURLAsset *)asset).URL;
@manmal
manmal / UIImageView+AFNetworkingFadeInAdditions.h
Last active August 27, 2017 17:31
Very minimalistic fade-in implementation for AFNetworking's UIImageView category. Thanks to @myellow and @merowing_.
#import <AFNetworking.h>
@interface UIImageView (AFNetworkingFadeInAdditions)
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholderImage fadeInWithDuration:(CGFloat)duration;
@end
@manmal
manmal / MMTableViewWithParallaxHeader.m
Created January 15, 2014 08:54
Forwards hit testing on a UITableView to certain views which are behind the tableview (siblings of UITableView). Quite hacky :/ If you know a better way, please tweet @manuelmaly
@interface MMTableViewWithParallaxHeader : UITableView
@property (strong, nonatomic) NSArray *forwardTouchesOnTransparentCellToViews;
@end
@implementation MMTableViewWithParallaxHeader
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
if ([self pointInside:point withEvent:event]) {
@manmal
manmal / comment.coffee
Created November 14, 2014 07:09
Ember Promised Properties
# /app/controllers/comment.coffee
`import promisedProperty from "../utils/promised_property"`
CommentController = Ember.ObjectController.extend
needs: ["application"]
currentUser: Ember.computed.alias('controllers.application.currentUser')
isCommentController: true
static UIView *PSPDFViewWithSuffix(UIView *view, NSString *classNameSuffix) {
if (!view || classNameSuffix.length == 0) return nil;
UIView *theView = nil;
for (__unsafe_unretained UIView *subview in view.subviews) {
if ([NSStringFromClass(subview.class) hasSuffix:classNameSuffix]) {
return subview;
}else {
if ((theView = PSPDFViewWithSuffix(subview, classNameSuffix))) break;
}
@manmal
manmal / MMReactiveSearchTableViewModel.m
Created January 23, 2015 16:02
Reactive Search Table View Model
@interface MMBaseReactiveSearchTableViewModel()
// Most of these will actually be public/header file
@property (copy, nonatomic) NSArray *searchResults;
@property (copy, nonatomic) NSString *searchTerm;
@property (strong, nonatomic) NSError *error;
@property (assign, nonatomic) BOOL isLoading;
@property (strong, nonatomic) RACSubject *forceRestartServerRequestSubject;
@end
// Just a quick hack to achieve something like this: https://www.dropbox.com/s/6a6lsqasee0zp1q/bgview.png?dl=0
@interface MMGradientBackgroundView()
@property (strong, nonatomic) UIImage *noiseImage;
@end
@implementation MMGradientBackgroundView
- (instancetype)initWithFrame:(CGRect)frame {
@manmal
manmal / upload_to_crashlytics
Created March 12, 2015 18:31
Upload an .ipa to Crashlytics
#!/bin/bash
set -x
cd ${0%/*}/..
ARCHIVEPATH=`pwd`/archive
IPA_PATH=("${ARCHIVEPATH}"/*.ipa)
DSYM_PATH=("${ARCHIVEPATH}"/*.dSYM.zip)
CRASHLYTICS_API_KEY=XXXX