Skip to content

Instantly share code, notes, and snippets.

View dorelljames's full-sized avatar
👨‍💻
Available for work

Dorell James dorelljames

👨‍💻
Available for work
View GitHub Profile
@dorelljames
dorelljames / laravel-nginx-config-make-http-exception-url-and-make-all-others-https.md
Last active July 12, 2024 10:07
Laravel nginx config to redirect all requests to https and an exception URL that can still be accessible via http

Pre-condition

One day in your Laravel app, you were required to redirect all http requests to https but need to make a certain URL route accessible via http for a certain reason; perhaps a portion of your javascript code needs to redirect to http URL but it can't because redirection to secure URL to insecure is prohibited. Therefore, in cases like this, you need to just allow just one URL to make an http connection.

NOTE: There are obvious security implications here so don't just follow this blindly and understand if this is really the solution you're looking for. The nginx config can somehow be improved, I just don't have the time yet. It sure do look redundant.

Understanding and examples

  • Redirect everything from http to https
@dorelljames
dorelljames / letsencrypt-guide-nginx-acme.sh.md
Last active March 16, 2024 10:34
SSL via Let's Encrypt (nginx server)

Nginx SSL via Let's Encrypt and acme.sh

This guide is intended to walk you through installation of a valid SSL on your server for your site at example.com. This example is using root user, you may need to use sudo if you encounter problems such as write permissions.

Pre-requisites

  • Install acme.sh on your server. This will create a acme.sh folder in your home directory and more importantly create an everyday cron job to check and renew certificates if needed.
  • Install nginx server (different per distibution so just make sure you have it up and running)
@dorelljames
dorelljames / encryptForGitHub
Created February 28, 2024 05:45
Encrypt values for storing on GitHub Secrets
import sodium from "libsodium-wrappers";
// publicKey is from GET /repos/{owner}/{repo}/actions/secrets/public-key
// secretValue is the value you want to get encrypted
export async function encryptForGitHub(secretValue: string, publicKey: string) {
await sodium.ready;
// Convert the secret and key to a Uint8Array.
const binkey = sodium.from_base64(publicKey, sodium.base64_variants.ORIGINAL);
const binsec = sodium.from_string(secretValue);
@dorelljames
dorelljames / recover-schema.md
Created March 14, 2023 13:09 — forked from bjoerge/recover-schema.md
How to recover lost schema from *.sanity.studio.md

First, go to https://<yourname>.sanity.studio (or to the url of your studio if it's hosted elsewhere). Then open the developer console (usually by one of the keyboard shortcuts Command+Option+I, F12 or Control+Shift+I depending on what browser/platform you are using)

Steps

  1. Open the Sources tab
  2. Find the app.bundle.js file in the sidebar tree view.
  3. Hit the pretty print source button
  4. Locate your schema types by searching (e.g. try searching for one of your custom types) it in the source view.
@dorelljames
dorelljames / adding-messenger-customer-chat-plugin-to-your-site.md
Last active September 17, 2022 08:34
Adding Messenger Customer Chat Plugin To Your Site

Requirements

  1. Install the Facebook SDK on your website.
<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId            : '1678638095724206', // REPLACE IF YOU WANT TO USE YOUR OWN FB APP
      autoLogAppEvents : true,
@dorelljames
dorelljames / machine.js
Created August 26, 2022 10:23
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@dorelljames
dorelljames / machine.js
Last active August 26, 2022 05:21
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@dorelljames
dorelljames / machine.js
Last active September 29, 2021 16:49
Generated by XState Viz: https://xstate.js.org/viz
const allProducts = ["Auction! Desktop", "Auction! Cloud", "Auction! Online", "Auction! Mobile", "Auction! Reservations"];
const orderMachine = Machine({
id: 'order',
initial: 'idle',
context: {
cart: [],
loggedInuser: {
organizations: null,
profile: null
@dorelljames
dorelljames / osx-vscode-xdebug-configuration.md
Last active June 25, 2021 13:41
OS X: Configuring XDebug on Visual Studio Code

OS X (MacOS): Configuring XDebug on Visual Studio Code

This guide is intended to get you up and running with XDebug for Visual Studio Code on OS X.

My Setup

  • Visual Studio Code (Insiders) 1.10.0
  • OSX El Capitan 10.11.6
  • PHP 7.0.15 (installed via homebrew)
  • XDebug 2.5.0 (installed via homebrew)
@dorelljames
dorelljames / machine.js
Created October 30, 2020 17:46
Generated by XState Viz: https://xstate.js.org/viz
Machine({
id: "electricFan",
type: "parallel",
states: {
power: {
id: "power",
initial: "turnedOff",
states: {
turnedOff: {
on: {