Skip to content

Instantly share code, notes, and snippets.

View luchtech's full-sized avatar
🏠
Working from home

James Carlo Luchavez luchtech

🏠
Working from home
View GitHub Profile
@luchtech
luchtech / guide.md
Last active August 15, 2023 10:25
S3-stored Encryption Keys for Laravel Passport

AWS S3-stored Encryption Keys for Laravel Passport

Note: This guide works for all S3-compatible storage services like Minio, Digital Ocean Spaces, etc.

Introduction

Laravel Passport needs encryption keys to generate access tokens. But, by default, these encryption keys are Git ignored to avoid accidentally exposing it to the internet. When it comes to production environment, we can't just generate these encryption keys every time we deploy since that will result to access tokens not working suddenly.

@luchtech
luchtech / guide.md
Last active June 5, 2024 18:36
How to deploy Laravel PHP to AWS (CodeCommit + S3 + RDS + Elasticache + Pipeline)

How to deploy Laravel PHP to AWS (CodeCommit + S3 + RDS + Elasticache + ElasticBeanstalk + Pipeline)

AWS CodeCommit

To start with, make sure that you already have the AWS ElasticBeanstalk config files. If not, visit this Github repo then copy the .ebextensions and .platform directories to the root of your Laravel app. Another way would be installing luchavez/boilerplate-generator then running php artisan bg:aws:publish. This will also add both slightly-modified .ebextensions and .platform directories to your app.

When the configs are set, we can now push to AWS CodeCommit. If possible, use SSH keys when working with Git remote repositories. When authenticating to multiple hosts (which means multiple SSH keys), you may follow this gist to properly place and test your keys.

When you add a new public SSH key to your AWS IAM account, you will also get an SSH Key ID. If you followed the

@luchtech
luchtech / 01-guide.md
Last active June 10, 2023 22:22
How to deploy GatsbyJS to AWS (CodeCommit + S3 + Pipeline + CodeBuild)

How to deploy GatsbyJS to AWS (CodeCommit + S3 + Pipeline + CodeBuild)

Before we start, I just want to make sure that you are not having errors when you build your GatsbyJS app. To verify, run npm run build or if you are using Yarn, yarn build. If there are errors, fix them first before proceeding.

Btw, this guide is based on this article so make sure to visit that as well while following this guide.

buildspec.yml

When running an app, we have specific steps to do from cloning the app repository to installing dependencies to running the app. The "buildspec.yml" file is like that - a series of steps to do to run the app. Below is a copy of my "buildspec.yml" file. Even on the first look, it is already self-explanatory. The app building will follow a series of steps called "phases". It starts with "install" phase, then "pre_build", then "build", then lastly, the "post_build" phase.

@luchtech
luchtech / Database.java
Created September 23, 2018 03:20
Universal TextFile Manipulator
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
public class Database {
/*
* This Universal Database aims to perform all kinds of operations when it comes to 2D Arrays.
@luchtech
luchtech / Database.java
Created August 22, 2018 09:19
Login System with Database
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
public class Database {
/*
* Create a text file first named "Account.txt" and fill in some usernames and passwords
@luchtech
luchtech / Magic.java
Created August 21, 2018 08:24
Laboratory Activity: List and Sorting Algorithm
import java.util.ArrayList;
import java.util.Vector;
public class Magic {
// DUPLICATE CHECKERS
static boolean isDuplicate(String s, Vector<String> arr) { // String Array
for(String x: arr) {
if(x.equalsIgnoreCase(s)) {
return true;
}
@luchtech
luchtech / numberManipulation.java
Created August 21, 2018 08:08
Laboratory Activity: Methods
import java.util.Scanner;
public class numberManipulation {
static String DecToBinary(int num) {
if(num <= 0) return ""+num;
String hold = "";
while(num!=0) {
hold = (num%2)+hold;
num/=2;
@luchtech
luchtech / EvenNum.java
Created August 21, 2018 07:59
Laboratory Activity: Loop Structure
import java.util.Scanner;
public class EvenNum {
public static void main(String[] args) {
Scanner sc = new Scanner (System.in);
System.out.println("Program: EVEN NUMBERS FROM 1-50\n");
System.out.println("Even Number from 1 to 50...");
System.out.println("----------using for loop----------");
for(int i = 1; i<=50; i++) {
@luchtech
luchtech / BowlingGame.java
Created August 21, 2018 07:51
Laboratory Activity: Selection Structure
import java.util.Scanner;
public class BowlingGame {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Program: BOWLING SCOREBOARD\n");
int score, total1 = 0, total2 = 0;
try{
System.out.println("\nFirst Try\n");
@luchtech
luchtech / PhotoCopier.java
Created August 21, 2018 07:24
Real-Life Processes (Constructors, Setters, Getters)
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;