Skip to content

Instantly share code, notes, and snippets.

View JT501's full-sized avatar
🚀

Johnny Tsoi JT501

🚀
View GitHub Profile
@JT501
JT501 / webmin_oath_2FA.md
Last active November 17, 2019 06:16
Webmin: Install Authen::OATH for 2FA

Webmin: Install Authen::OATH for 2FA

For people having trouble running the CPAN or MCPAN commands via command line or through the Perl Module manager in Webmin (meaning it fails to install via CPAN so it tried to install via source), you need to first install CPAN:

yum -y install perl-CPAN

Update CPAN if needed.

And the approximate sequence of commands thereafter:

@JT501
JT501 / jail_sftp_user.md
Last active November 17, 2019 06:16
Jail SFTP user into their directories

Jail SFTP user into their directories

  1. Create user group sftpgroup

  2. Add user into sftpgroup

  3. Modify etc/ssh/sshd_config :

#Subsystem sftp /usr/lib/openssh/sftp-server
@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:

@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 Johnny@Co-fire.com. All rights reserved.
//
import UIKit
import SwiftySound
@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 Johnny@Co-fire.com. All rights reserved.
//
import UIKit
import RxCocoa
import RxSwift
private var prepareForReuseBag: Int8 = 0
@JT501
JT501 / ServerSetup.md
Last active December 6, 2019 13:15
Google Cloud Server (CentOS 7) Setup Steps
@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 / 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 Johnny@Co-fire.com. All rights reserved.
//
import UIKit
import RxSwift
import RxCocoa
@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 / 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])+)\\])"