Skip to content

Instantly share code, notes, and snippets.

View JT501's full-sized avatar
🚀

Johnny Tsoi JT501

🚀
View GitHub Profile
@JT501
JT501 / BaseNavigationController.swift
Last active November 16, 2019 08:32
Add Back Default Swipe Back Gesture & Transition
//
// BaseNavigationController.swift
// Mention
//
// Created by Johnny Choi on 21/10/2019.
// Copyright (c) 2019 [email protected]. All rights reserved.
//
import UIKit
@JT501
JT501 / TestHelper.swift
Created September 20, 2019 06:22
In order to call UIView's becomeFirstResponser in Unit Test, you need to add it to keyWindow.,
static func embedViewIntoMainApplicationWindow(_ view: UIView) {
guard let keyWindow = UIApplication.shared.keyWindow else {
fatalError()
}
guard let controller = keyWindow.rootViewController else {
fatalError()
}
controller.view.addSubview(view)
@JT501
JT501 / String+Ex.swift
Created September 20, 2019 06:19
Check if string is valid email
extension String {
var isValidEmail: Bool {
let regex = "(?:[\\p{L}0-9!#$%\\&'*+/=?\\^_`{|}~-]+(?:\\.[\\p{L}0-9!#$%\\&'*+/=?\\^_`{|}" +
"~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\" +
"x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[\\p{L}0-9](?:[a-" +
"z0-9-]*[\\p{L}0-9])?\\.)+[\\p{L}0-9](?:[\\p{L}0-9-]*[\\p{L}0-9])?|\\[(?:(?:25[0-5" +
"]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-" +
"9][0-9]?|[\\p{L}0-9-]*[\\p{L}0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21" +
"-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])"
@JT501
JT501 / MyDatabaseTokenRepository.php
Last active May 4, 2024 01:31
Laravel Custom Reset Password Token
<?php
namespace App\Providers\Passwords;
use Illuminate\Auth\Passwords\DatabaseTokenRepository;
class MyDatabaseTokenRepository extends DatabaseTokenRepository
{
/**
* [Override]
@JT501
JT501 / MyTabBarController.swift
Last active October 25, 2018 08:48
Create Custom Tab Bar with Large Center Icon
//
// MyTabBarController.swift
//
// Created by Johnny on 25/10/2018.
// Copyright © 2018 [email protected]. All rights reserved.
//
import UIKit
import RxSwift
import RxCocoa
@JT501
JT501 / EventTableSeeder.php
Created October 16, 2018 14:58
Seeding Database with Random Data using Faker.
<?php
use App\Event;
use Illuminate\Database\Seeder;
class EventTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
@JT501
JT501 / ServerSetup.md
Last active December 6, 2019 13:15
Google Cloud Server (CentOS 7) Setup Steps
@JT501
JT501 / UIReusable+Rx.swift
Created September 3, 2018 09:54
An extension to avoid duplicate subscriptions in UITableCell & UICollectionViewCell
//
// Created by Johnny on 3/9/2018.
// Copyright (c) 2018 [email protected]. All rights reserved.
//
import UIKit
import RxCocoa
import RxSwift
private var prepareForReuseBag: Int8 = 0
@JT501
JT501 / PDFViewVC.swift
Last active November 24, 2021 08:01
PDFView Setup
//
// PDFViewVCVC.swift
// CindyChao
//
// Created by Johnny on 19/8/2018.
// Copyright © 2018 [email protected]. All rights reserved.
//
import UIKit
import SwiftySound
@JT501
JT501 / Install_Git.md
Last active November 17, 2019 06:19
Install Latest Git for CentOS 7

Install Latest Git for CentOS 7

You can use WANDisco's CentOS repository to install Git 2.x: for CentOS 7

Install WANDisco repo package:

yum install http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm

Install the latest version of Git 2.x: