Skip to content

Instantly share code, notes, and snippets.

View JT501's full-sized avatar
🚀

Johnny Tsoi JT501

🚀
View GitHub Profile
@JT501
JT501 / 1-Laravel-Docker-SSL.md
Last active May 2, 2024 16:25
Laravel + nginx-proxy + docker-letsencrypt-nginx-proxy-companion

Laravel + nginx-proxy + acme-companion

(Updated on 7/8/2023)

Deploy Laravel on Docker using nginx-proxy + acme-companion (formerly called docker-letsencrypt-nginx-proxy-companion)

  1. Prepare two seperate docker compose file i.e docker-compose.nginx.yml & docker-compose.app.yml

  2. Create nginx directory and move docker-compose.nginx.yml into it.

  3. Create YOUR_DOMAIN.conf and YOUR_DOMAIN_location_override.conf in nginx directory.

@JT501
JT501 / docker-compose-gcr-gar.md
Last active January 17, 2024 06:16
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.

@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 / 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);
@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
@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:
@JT501
JT501 / ServerSetup.md
Last active December 6, 2019 13:15
Google Cloud Server (CentOS 7) Setup Steps
@ankurk91
ankurk91 / laravel_horizon.md
Last active May 31, 2024 01:57
Laravel Horizon, redis-server, supervisord on Ubuntu server

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

Laravel 8+, Horizon 5.x, Redis 6+

Parepare 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 dashbaord

Install redis-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 / 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