Skip to content

Instantly share code, notes, and snippets.

View bishalg's full-sized avatar
🏠
Working from home

Bishal Ghimire bishalg

🏠
Working from home
View GitHub Profile
// UIFont+Utility.h
// UIFont+Utility.[h|m] is (C) Kerri Shotts 2013, and released under an MIT license.
#import <UIKit/UIKit.h>
/**
*
* PKFontNormal = no modifications to the font; i.e., -Regular, -Roman, -Book, etc.
* PKFontBold = bold font desired (if possible); i.e., -Bold, -Black, -Heavy, etc.
* PKFontItalic = italic font desired (if possible); i.e., -Italic, -Oblique, etc.
@bishalg
bishalg / API Status Code
Last active August 29, 2015 14:18
REST API Status Codes for Objective-C
//
// APIStatusCode.h
// Bishal Ghimire
//
// Created by Leapfrog on 9/1/14.
// Copyright (c) 2014 Bishal Ghimire. All rights reserved.
//
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Response_codes
// http://www.w3.org/Protocols/HTTP/HTRESP.html
// http://www.raywenderlich.com/51127/nsurlsession-tutorial
@bishalg
bishalg / sideMenu
Last active August 29, 2015 14:22
Side Menu JSON Example
{
"success": true,
"meanuItems": [
{
"menuTitle": "MY STUFF",
"isClosed": false,
"items": [
{
"title": "ITINERARIES",
"icon": "itineraries_icon"
@bishalg
bishalg / Random UIColor
Created July 3, 2015 06:00
Random Shades of Gray UIColor - iOS Objective-C
- (UIColor *)randomColor {
CGFloat white = ( arc4random() % 90 / 256.0 ) + 0.3; // 0.35 - 0.65
UIColor *color = [UIColor colorWithWhite:white alpha:1.0];
return color;
}
@bishalg
bishalg / apiStatusCodes
Created July 10, 2015 07:48
REST API Status Codes for Swift 2.0
//
// apiStatusCodes.swift
// Bishal Ghimire
//
// Copyright (c) 2014 Bishal Ghimire. All rights reserved.
//
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Response_codes
// http://www.w3.org/Protocols/HTTP/HTRESP.html
// http://www.raywenderlich.com/51127/nsurlsession-tutorial
@bishalg
bishalg / gist:319e68633c74a71860da
Created September 21, 2015 06:09
Debug only Logger for Swift using NSLog
import Foundation
#if DEBUG
func dLog(@autoclosure message: () -> String, filename: NSString = __FILE__, function: String = __FUNCTION__, line: Int = __LINE__) {
NSLog("[\(filename.lastPathComponent):\(line)] \(function) - %@", message())
}
#else
func dLog(@autoclosure message: () -> String, filename: NSString = __FILE__, function: String = __FUNCTION__, line: Int = __LINE__) {
}
#endif
@bishalg
bishalg / HeightForIndexPath.swift
Created January 18, 2016 11:27
Height For CollectionViewCell Label Dynamic Font scale
func heightForIndexPath(indexPath: NSIndexPath, inWidth width: CGFloat, andHeight height: CGFloat) -> CGFloat {
if indexPath.item % 2 != 0 {
return cellHeight
}
let labelLeft = UILabel(frame: CGRect(x: 0, y:0, width: width, height: height))
labelLeft.font = UIFont.fontForTextStyle(UIFontTextStyleHeadline, scaleFactor: Fonts.FontScale.Small.value)
labelLeft.numberOfLines = 0
let video = videosInCollection[indexPath.row]
labelLeft.text = video.description
@bishalg
bishalg / RKOrderedTaskVC.swift
Created March 24, 2016 07:30
ResearchKit - example of ORKOrderedTask for ORKTaskViewController with ORKCompletionStep
//
// HomeVC.swift
// LoginKit
//
// Created by Bishal Ghimire on 2/24/16.
// Copyright © 2016 Bishal Ghimire. All rights reserved.
//
import UIKit
import ResearchKit
@bishalg
bishalg / AppInfo.swift
Last active November 3, 2017 16:51
AppInfo Swift - Util to get app infos like build / version number etc
//
// AppInfo.swift
// This is an Util to get app infos like build / version number etc
// Swift 3.0
// Xcode 8.0
//
import Foundation
import AVFoundation
@bishalg
bishalg / CoreDataStack.swift
Last active July 2, 2024 04:16
Core Data Stack in Swift for managing Managed Object Context for NSManagedObjectModel using NSPersistentStoreCoordinator
//
// CoreDataStack.swift
// Swift 3.0
// Xcode 8.0
//
import Foundation
import CoreData
class CoreDataStack: NSObject {