Skip to content

Instantly share code, notes, and snippets.

View TosinAF's full-sized avatar
🧢

Tosin Afolabi TosinAF

🧢
View GitHub Profile
@TosinAF
TosinAF / 0_reuse_code.js
Created November 27, 2015 17:38
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@TosinAF
TosinAF / TNPageViewController.m
Created May 24, 2015 18:30
Disabling UIPageViewController Swipe on certain areas of the screen
//
// TNPageViewController.m
// The News
//
// Created by Tosin Afolabi on 26/06/2014.
// Copyright (c) 2014 Tosin Afolabi. All rights reserved.
//
#import "TNPageViewController.h"
- (void)shareAction
{
NSArray *activityItems = @[self.url, self.titleLabel.text];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
[self presentViewController:activityViewController animated:true completion:nil];
}
@TosinAF
TosinAF / A-HopperBus-CodeSample-Readme.md
Last active January 20, 2021 14:06
Example use of the Model-View-ViewModel Pattern in iOS (Swift) as explained in http://www.objc.io/issue-13/mvvm.html. Full Source Code can be found at https://github.com/TosinAF/HopperBus-iOS

I decided to build an iOS app for my University's bus service that runs through the various campuses.

xy

It was an interesting challenge as I had nothing but the printed timetables (http://www.nottingham.ac.uk/about/documents/903-times.pdf) to use as the data.

Thus I had to come with a suitable data structure that would complement the design & user experience i had in mind for the app.

I also decided to take the challenge of writing the app in swift. This project has helped me get to up speed with swift really quickly.

@TosinAF
TosinAF / A-DN-API-iOS-Wrapper-Readme.md
Last active August 29, 2015 14:09
Designer News API iOS Wrapper. Full Source Code can be found at https://github.com/TosinAF/thenews

I released TheNews iOS (bit.ly/thenews-ios) over the past summer. A required part of the app was to communicate with the designer news api. The api had only just been recently released so there was no wrapper for iOS apps.

As such, I had to create an API wrapper. Having never attempted this before, I studied a few examples on Github and modeled my solution like those I had seen.

It was a really interesting project to build. It's important to create the wrapper as a singleton to maintain a user session & prevent multiple calls of the same requests. I also built the wrapper with the consideration that others might find it useful (https://github.com/TosinAF/DNManager) .

As such I had to consider what methods should be public and make them easy for anyone to get familiar with it.

I leveraged the power of the AFNetworking Library to build the api wrapper & used blocks so as to allow the user to specify what actions should be taken if the request succeeds or if it fails.

@TosinAF
TosinAF / NSDate Extension
Created October 13, 2014 02:42
NSDate extension for detecting when its a shcool holiday or term time & stuff like that
extension NSDate {
class func isSaturday() -> Bool {
if NSDate.getDay() == 7 { return true }
return false
}
class func isSunday() -> Bool {
if NSDate.getDay() == 1 { return true }
return false
@TosinAF
TosinAF / PEExcuseViewController.m
Created January 13, 2014 18:53
These are the two view controllers for my iOS app, Procuses. This code sample shows my understanding of Design Patterns (Delegates, Enums) & my ability to use 3rd Party API's (Parse)
//
// PEExcuseViewController.m
// Procuses
//
// Created by Tosin Afolabi on 09/11/2013.
// Copyright (c) 2013 Tosin Afolabi. All rights reserved.
//
#import <Parse/Parse.h>
@TosinAF
TosinAF / PEExcuseLabel.m
Created January 13, 2014 18:21
My Subclass of UILabel to ensure that when a new excuses is displayed in my app, Procuses (tosinaf.github.io/Procuses), the height is dynamically updated to fit the new text content while keeping the width constant.
//
// PEExcuseLabel.m
// Procuses
//
// Created by Tosin Afolabi on 04/08/2013.
// Copyright (c) 2013 Tosin Afolabi. All rights reserved.
//
#define IOS_NEWER_OR_EQUAL_TO_7 ( [ [ [ UIDevice currentDevice ] systemVersion ] floatValue ] >= 7.0 )
@TosinAF
TosinAF / CommandInterpreter.java
Created January 13, 2014 18:01
Code Sample from my implementation of a POP3 Mail Server (https://github.com/TosinAF/POP3MailServer) The POP3 Mail Server is split into several classes (Command Interpreter, Database, Server). This code sample shows my excellent knowledge of OOP, appropriate use of comments and ability to write tests for my code.
/**
* The Class Command Interpreter.
*
* @author Tosin Afolabi
* @version 1.0
*
* This class will receive commands from the network Call the
* approaiate method on the Databse then send a response back to the
* client
*
@TosinAF
TosinAF / gTheory.py
Created December 2, 2013 08:10
Game Theory v1.0 This a Pshcychological game, Have a good look at your opponent.
class Player(object):
""" To Create a new Player Instance with name, credit & bet values """
bet = 0
def __init__(self, PlayerName, Credit):
self.PlayerName = PlayerName
self.Credit = Credit
def __str__(self):
return self.PlayerName