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 8, 2024 08:58
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:

@ankurk91
ankurk91 / laravel_horizon.md
Last active January 23, 2025 05:08
Laravel Horizon, redis/valkey-server, supervisord on Ubuntu server

Laravel Horizon, redis-server, supervisord on Ubuntu 20/22/24 server

Laravel 10+, Horizon 5.x, Redis/Valkey 7+

Prepare application

  • Install and configure Laravel Horizon as instructed in docs
  • Make sure you can access the Horizon dashboard like - http://yourapp.com/horizon
  • For now; it should show status as inactive on horizon dashboard

Install redis-server

@JT501
JT501 / ServerSetup.md
Last active December 6, 2019 13:15
Google Cloud Server (CentOS 7) Setup Steps
@slightfoot
slightfoot / timestamp_converter.dart
Created April 22, 2020 16:28
Timestamp/DateTime Converter for Cloud Firestore and Dart/Flutter.
// MIT License
//
// Copyright (c) 2020 Simon Lightfoot
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@skymobilebuilds
skymobilebuilds / carthage-xc12.sh
Last active May 17, 2022 12:36
Xcode 13 and 12 Carthage Build Workaround
#!/bin/bash -e
echo "🤡 Applying carthage 12 and 13 workaround 🤡"
xcconfig=$(mktemp /tmp/static.xcconfig.XXXXXX)
# For Xcode 12 make sure EXCLUDED_ARCHS is set to arm architectures otherwise
# the build will fail on lipo due to duplicate architectures.
CURRENT_XCODE_VERSION=$(xcodebuild -version | grep "Build version" | cut -d' ' -f3)
echo 'EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1200 = arm64 arm64e armv7 armv7s armv6 armv8' > $xcconfig
echo "EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1200__BUILD_$CURRENT_XCODE_VERSION = arm64 arm64e armv7 armv7s armv6 armv8" >> $xcconfig
@JT501
JT501 / DelayRedirect.tsx
Created October 17, 2020 09:53
React Router - DelayRedirect
import * as React from 'react';
import { useEffect, useState } from 'react';
import { Redirect, RedirectProps } from 'react-router';
interface DelayProps {
delay: number;
}
const DelayRedirect = ({ delay, ...rest }: RedirectProps & DelayProps) => {
const [timeToRedirect, setTimeToRedirect] = useState(false);
@JT501
JT501 / useCountDown.ts
Last active July 18, 2023 04:25
React useCountDown Hook
import { useEffect, useRef, useState } from 'react';
export const useCountDown: (
total: number,
ms?: number,
) => [number, () => void, () => void, () => void] = (
total: number,
ms: number = 1000,
) => {
const [counter, setCountDown] = useState(total);
@JT501
JT501 / docker-compose-gcr-gar.md
Last active March 27, 2025 10:45
Run docker-compose on Container Optimized OS (GCE) with access to GCR & GAR

docker-compose on Container Optimized OS (GCE) with access to GCR & GAR

For Docker Compose V2.0, please read the comment below.

Docker Compose V1.0

Since GCE's Container-Optimized OS do not include docker-compose by default. So, we need to use the official docker/compose image as a workaround. However, docker/compose cannot access GCR or GAR to pull private images. Therefore we have to create a custom docker-compose image which is authenticated to GCR / GAR.