Skip to content

Instantly share code, notes, and snippets.

View omayib's full-sized avatar
Focusing

omayib omayib

Focusing
View GitHub Profile
@omayib
omayib / RahmayanaDeptStore.kt
Last active November 28, 2017 22:52
The real world implementation of strategy pattern in Kotlin
/**
* Created by omayib on 22/05/17.
*/
fun main(args: Array<String>){
val tShirtUbuntu = TShirt(70000,2)
val tShirtAndroid = TShirt(50000,4)
val tShirtCoder = TShirt(80000,3)
val bill = Bill()
bill.add(tShirtUbuntu)
@omayib
omayib / ViewController.swift
Created October 10, 2017 02:56
here is a place to control the view state.
class ViewController: UIViewController {
@IBOutlet weak var emailTextField: UITextField!
@IBOutlet weak var passwordTextField: UITextField!
@IBOutlet weak var fullNameTextField: UITextField!
@IBOutlet weak var phoneNumberTextField: UITextField!
var presenter: RegistrationPresenter?
override func viewDidLoad() {
super.viewDidLoad()
@omayib
omayib / RegistrationPresenter.swift
Created October 10, 2017 02:53
create an implementation of business logic on RegistrationPresenter class.
protocol RegistrationDelegate{
func showProgress()
func hideProgress()
func registrationDidSucceed()
func registrationDidFailed(message: String)
}
class RegistrationPresenter{
var delegate: RegistrationDelegate
@omayib
omayib / TheRegistrationPageTests.swift
Last active October 10, 2017 02:50
Initiate the RegistrationPresenter object
class TheRegistrationPageTests: XCTestCase {
override func setUp() {
super.setUp()
}
//...
func testRegisterWithEmptyEmail(){
let expec = expectation(description: "registration with empty email")
let registrationPresenter = RegistrationPresenter(delegate: MockUIViewController1(expectation: expec))
registrationPresenter.register(email: "", password: "123456789", fullName: "michel jhon", phoneNumber: "087654325673")
@omayib
omayib / TheRegistrationPageTests.swift
Last active October 10, 2017 02:26
the initial unit test for registration page presenter
class TheRegistrationPageTests: XCTestCase {
override func setUp() {
super.setUp()
}
override func tearDown() {
super.tearDown()
}
func testRegisterWithEmptyEmail(){
{
"alumnus":[{"id":"213s2","name":"Andri Atmojo","email":"andri@yahoo.com","work":"freelance android"},
{"id":"21324","name":"Joki Widyawan","email":"joki@yahoo.com","work":"freelance web"},
{"id":"21324","name":"Eko Purnawan","email":"eko@yahoo.com","work":"Google"},
{"id":"21324","name":"Susilo Andi S","email":"susilo@yahoo.com","work":"Facebook"},
{"id":"21324","name":"Prakoso Binar","email":"binar@yahoo.com","work":"Microsoft"},
{"id":"21324","name":"Gilang Santoso","email":"gilang@yahoo.com","work":"freelance android"},
{"id":"21324","name":"Atmojo Rakoso","email":"rakoso@yahoo.com","work":"freelance ios"}
]
}
@omayib
omayib / AlumnusListActivity.java
Last active September 21, 2017 22:50
getting data directly from server
/**
* Created by omayib on 18/09/17.
*/
public class AlumnusListActivity extends Activity{
private static final String TAG = "AlumnusListActivity";
private RecyclerView mRecyclerView;
private LinearLayoutManager mLinearLayoutManager;
private RecyclerAdapter mAdapter;
private ArrayList<Person> alumnus;
@omayib
omayib / dummy-api.json
Last active September 8, 2017 01:30
This file is a dummy api response. Run it using https://github.com/typicode/json-server.
{
"users": [
{
"id": "797rtr534",
"name": "Supriyono",
"phone": "087364524354",
"token": "kjashdrfkjhaswkeruy9824hhufdskjn"
}
],
"restaurants": [
@omayib
omayib / SimpleRepositoryPatternIn.swift
Created August 29, 2017 07:53
Introducing repository pattern with swift.
//: Playground - noun: a place where people can play
import UIKit
class Todo{
var tempId: UUID?
var id : Int
var title: String
var isCompleted: Bool
@omayib
omayib / LookingPersonInsideList.java
Last active August 1, 2017 07:37
how to identify an object by specific attribute
/**
* Created by omayib on 01/08/17.
*/
public class YourApps {
public static void main(String[] args) {
Person arif = new Person("Arif", 20, 163);
Person akbarul = new Person("Akbarul", 25, 160);
Person huda = new Person("Huda", 21, 165);
//insert the data into customers list.