Skip to content

Instantly share code, notes, and snippets.

View cjndubisi's full-sized avatar
👋

Chijioke Ndubisi cjndubisi

👋
View GitHub Profile
@cjndubisi
cjndubisi / UIViewStyle.swift
Created November 2, 2018 14:04
UIViewStyling from Anatoli
import UIKit
import Foundation
/// An abstraction if `UIView` styling.
struct UIViewStyle<T: UIResponder> {
/// The styling function that takes a `UIView` instance
/// and performs side-effects on it.
public let styling: (T) -> Void
profileService.createProfile()
.then{ profile -> Void in
// do something with profile
}. catch { error in
// handle error
}
@cjndubisi
cjndubisi / PromiseCreate.swift
Created February 10, 2017 08:39
CreateWithPromise
func createProfile(with details: [String:Any]) -> Promise<Profile> {
return firstly
{
// return a promise to signup
auth.signup(with: details)
}.then { _ in
// I don’t need the value I only care that It passed.
auth.signIn(email: email, password: password)
}.then {
auth.user(with: details)
@cjndubisi
cjndubisi / CreateCallback.swift
Created February 10, 2017 08:36
Nested Callbacks.
func createProfile(completionHandler: @escaping (Any?, Error?) -> Void) {
let params = self.params()
// sign up
auth.signup(with: params) { error in
guard error == nil else { completionHandler(nil, error); return }
// log in
self.auth.signIn(email: email, password: password, completion: { (error) in
guard error == nil else { completionHandler(nil, error); return }
// get users profile
self.auth.user(with: params, completion: { (error, individual) in
@cjndubisi
cjndubisi / apns
Created January 20, 2017 00:02 — forked from fahied/apns
How to create APNS Certificates and merge into one PEM
Step 1: Create Certificate .pem from Certificate .p12
Command: openssl pkcs12 -clcerts -nokeys -out apns-dev-cert.pem -in apns-dev-cert.p12
Step 2: Create Key .pem from Key .p12
Command : openssl pkcs12 -nocerts -out apns-dev-key.pem -in apns-dev-key.p12
Step 3: Optional (If you want to remove pass phrase asked in second step)
Command : openssl rsa -in apns-dev-key.pem -out apns-dev-key-noenc.pem
Step 4: Now we have to merge the Key .pem and Certificate .pem to get Development .pem needed for Push Notifications in Development Phase of App
@cjndubisi
cjndubisi / TopPageControl.swift
Created July 8, 2016 10:42
Moving the UIPageControl inside a UIPageViewController from bottom to top without losing control provided by the view controller
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
// get pageControl and scroll view from view's subviews
let pageControl = view.subviews.filter{ $0 is UIPageControl }.first! as! UIPageControl
let scrollView = view.subviews.filter{ $0 is UIScrollView }.first! as! UIScrollView
// remove all constraint from view that are tied to pagecontrol
let const = view.constraints.filter { $0.firstItem as? NSObject == pageControl || $0.secondItem as? NSObject == pageControl }
view.removeConstraints(const)