Skip to content

Instantly share code, notes, and snippets.

@mamaz
mamaz / NoMarigin
Last active August 29, 2015 14:23
No Marrgin left for UITableView iOS
// on VC
// remove spacing
if ([self.table respondsToSelector:@selector(setSeparatorInset:)]) { // Safety check for below iOS 7
[self.table setSeparatorInset:UIEdgeInsetsZero];
}
// on custom cell subclass
- (UIEdgeInsets)layoutMargins
{
return UIEdgeInsetsZero;
@mamaz
mamaz / registerPushNotif.m
Created May 7, 2015 13:03
Register push notification iOS 8 compliant
- (void)registerForPushNotifications
{
UIApplication *sharedApplication = [UIApplication sharedApplication];
if ([sharedApplication respondsToSelector:@selector(registerUserNotificationSettings:)]) {
UIUserNotificationType type = (UIUserNotificationTypeSound|UIUserNotificationTypeAlert|UIUserNotificationTypeBadge);
UIUserNotificationSettings *notificationSettings = [UIUserNotificationSettings settingsForTypes:type
categories:nil];
[sharedApplication registerUserNotificationSettings:notificationSettings];
@mamaz
mamaz / Podfile
Last active August 29, 2015 14:18
Simple Podfille for any projects
# to download
# curl -o Podfile https://gist.githubusercontent.com/mamaz/87909165fd6a5c496a6c/raw/dddf4aad97ecfda42ade1e0cc216fc8cad14e000/Podfile
platform :ios, '8.0'
inhibit_all_warnings!
source 'https://github.com/CocoaPods/Specs.git'
pod 'AFNetworking', '2.5.2'
@mamaz
mamaz / fabric.sh
Last active December 7, 2023 07:53
iOS build script for building and uploading to Fabric
#!/bin/sh
#
# Simple script for uploading binaries to Fabric (d/h Crashlytics)
#
# written by @taufik_obet
# modified for pushing to fabric by @hismamaz
#
#
@mamaz
mamaz / withoutIndent.m
Created December 27, 2014 08:40
Make table separator without any indent
// iOS 7+
// on custom cell
- (void)awakeFromNib // or layoutSubviews
{
// make table separator without any indent
if ([self respondsToSelector:@selector(setLayoutMargins:)]) {
self.layoutMargins = UIEdgeInsetsZero;
}
@mamaz
mamaz / custom_keyboard_hint.txt
Created December 12, 2014 15:04
Hints for building Custom Keyboard App using Jenkins and xctools (XCode 6.1)
Notice for building Custom Keyboard App using Jenkins and xctools
# please use $(BUILT_PRODUCTS_DIR) as Installation Directory on Build Settings
# please specify $(SDKROOT)/ResourceRules.plist as Code Signing Resource Rules Path
# use 2 prov profile: containing app and custom keyboard extension
@mamaz
mamaz / initString.cpp
Last active August 29, 2015 14:07
initString.cpp simple pass by reference
#include <iostream>
using namespace std;
/**
User refrence sign '&' to make it pass by refernce.
*/
void initString(char* &dest) {
dest = new char[255];
dest[0] = 'a';
@mamaz
mamaz / MZCircleImage.m
Created September 11, 2014 10:06
Draw Circle Image by Clipping
// draw circler image
-(void)drawClippedAvatar:(UIImage *)image inRect:(CGRect)rect andContext:(CGContextRef)context
{
CGMutablePathRef path = CGPathCreateMutable();
CGPathAddEllipseInRect(path, NULL, rect);
CGContextAddPath(context, path);
CGContextClip(context);
CGPathRelease(path);
[image drawInRect:rect];
}
/*
Get UILabel's size for wordwrapping style
*/
+(CGSize)getLabelSizeWordWrapWithString:(NSString*)string
font:(UIFont*)font
constrainedToSize:(CGSize)constrainedSize
{
if (IOS_VERSION_LESS_THAN_7) {
@mamaz
mamaz / NSLogExtension
Last active August 29, 2015 14:05
Print filename and line with comments
// Print filename and line with comments
// credits to Taufik Obet
#ifndef __OPTIMIZE__
# define NSLog(...) printf("[%-30s:%4d]: %s\n", __FILE_NAME_ONLY__, __LINE__, [[NSString stringWithFormat:__VA_ARGS__] UTF8String])
#else
#define NSLog(...) do {} while (0)
#endif