Skip to content

Instantly share code, notes, and snippets.

View celian-m's full-sized avatar

celian celian-m

  • MyStudioFactory
  • Paris
View GitHub Profile
@celian-m
celian-m / Singleton.md
Last active January 19, 2016 13:57
iOS Singleton

Generate Objective-C Singleton

@implementation <#MyManager#>

#pragma mark Singleton Methods

+ (id)sharedManager {
    static <#MyManager#> *sharedManager = nil;
    static dispatch_once_t onceToken;
 dispatch_once(&amp;onceToken, ^{
@celian-m
celian-m / Twitter.md
Last active February 28, 2018 13:09
Generate Twitter Bearer Token

Generate a Bearer token to access Twitter REST API

- (void) generateAPIKeyWithCompletionBlock:(void (^)(BOOL success, NSString* twitterOAuthToken, NSString *error))completion {
    //Network tasks should be in background thread
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
        
        //Generate Bearer Token according to Twitter Documentation
        NSString* bearerToken = [NSString stringWithFormat:@"%@:%@", TWITTER_API_KEY , TWITTER_API_SECRET];
        bearerToken = [[bearerToken dataUsingEncoding:NSUTF8StringEncoding] base64EncodedStringWithOptions:0];
@celian-m
celian-m / CMBanner.md
Last active February 24, 2016 17:02
Banner

#Add a top-right banner to your view Added Banner ##Usage

 let banner = CMBannerView(frame: CGRectMake(0, 0, 120, 120), text: "New", color: UIColor.redColor(), width: 30)
 myView.addSubview(banner)

##Implementation

@celian-m
celian-m / Register.md
Last active January 19, 2016 13:37
Registering for remote notificatiosn

#Register for remote notifications in Objective-C

    if ([application
         respondsToSelector:@selector(registerUserNotificationSettings:)]) {
        
        UIUserNotificationSettings *notificationSettings = [UIUserNotificationSettings settingsForTypes:
        UIUserNotificationTypeAlert | 
        UIUserNotificationTypeBadge | 
 UIUserNotificationTypeSound categories:nil];
@celian-m
celian-m / bash_profile
Created February 24, 2016 16:57
MAC OS X Bash Profile basic
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
alias sub='sublime'
alias ll='ls -la'
@celian-m
celian-m / iOS_Notifications.md
Last active February 29, 2016 13:37
Register for iOS Push Notifications, iOS7 and above

#Registering

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

//Your code...

//Check if OS is Version 7
  if (![[UIApplication sharedApplication]
          respondsToSelector:@selector(registerUserNotificationSettings:)]) {
@celian-m
celian-m / debugQuickLookObject.md
Last active March 3, 2016 14:09
iOS debugQuickLookObject

#Visual Debuging# If you are borred to use po myObject to check the content of your objects, you may use debugQuickLookObject, an XCode hidden gem.

Assuming your object is a subclass of NSObject

- (id)debugQuickLookObject {
    UIImage* img = [UIImage imageNamed:self.productThumbImage];
    UIImageView* view = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, img.size.width, img.size.height)];
 view.image = img;
@celian-m
celian-m / CurrentDevice.swift
Created April 13, 2016 07:30
Check Device Model in Swift
public extension UIDevice {
var modelName: String {
#if (arch(i386) || arch(x86_64)) && os(iOS)
let DEVICE_IS_SIMULATOR = true
#else
let DEVICE_IS_SIMULATOR = false
#endif
var machineString : String = ""
@celian-m
celian-m / CoreDataManager.swift
Last active May 10, 2016 12:20
Core Data Manager for Swift usage
//
// CoreDataController.swift
//
//
// Created by Célian MOUTAFIS on 26/04/2016.
// Copyright © 2016 mouce. All rights reserved.
//
import Foundation
@celian-m
celian-m / SuperViewController.swift
Created June 17, 2016 08:24
Super View controller for iOS swift apps
//
// SuperViewController.swift
// Mouce
//
// Created by Célian MOUTAFIS on 15/06/2016.
// Copyright © 2016 Célian MOUTAFIS. All rights reserved.
//
import Foundation
import UIKit