Skip to content

Instantly share code, notes, and snippets.

View LanciWeb's full-sized avatar

Marco Lancellotti LanciWeb

View GitHub Profile
@LanciWeb
LanciWeb / useScript.js
Created January 15, 2021 13:38
a custom hook to use external script inside a component
import { useEffect } from 'react';
const useScript = (url: string, onLoadCallback?: () => void) => {
useEffect(
() => {
const script = document.createElement('script');
script.src = url;
script.async = true;
script.defer = true;
@LanciWeb
LanciWeb / useSize.js
Created February 20, 2021 14:58
A simple hook to observe size changes of a DOM element in React.js
import { useRef, useEffect, useState, useCallback } from "react";
const useSize = () => {
let observer = useRef();
const nullSize = { width: null, height: null };
const [currentSize, setCurrentSize] = useState(nullSize);
const getSize = (elements) => {

MySQL Cheat Sheet

Help with SQL commands to interact with a MySQL database

MySQL Locations

  • Mac /usr/local/mysql/bin
  • Windows /Program Files/MySQL/MySQL version/bin
  • Xampp /xampp/mysql/bin

Add mysql to your PATH

@LanciWeb
LanciWeb / deploy.sh
Created November 2, 2023 16:32 — forked from BenSampo/deploy.sh
Laravel deploy script
# Change to the project directory
cd $FORGE_SITE_PATH
# Turn on maintenance mode
php artisan down || true
# Pull the latest changes from the git repository
# git reset --hard
# git clean -df
git pull origin $FORGE_SITE_BRANCH
@LanciWeb
LanciWeb / Inertia.md
Created November 21, 2023 17:45
Inertia JS Notes

FAQs

Cos'è Inertia.JS?

Inertia NON è un framework JS e non è inteso a sostituirne uno.

Inertia è una libreria JavaScript che ci permette di utilizzare Vue, React o Svelte all'interno di un qualsiasi backend, creando un'esperienza da SPA, ma senza le complessità tipiche della SPA.

In altre parole, tu continui ad utilizzare i pattern e il routing del tuo framework di backend preferito, ma poi a frontend ti ritrovi con la potenza di un framework JS moderno.

>Nota: Inertia è cucito attorno a Laravel ma non è legato strettamente a Laravel, ma ha per Laravel (e per Rails) degli adaptors ufficiali che ne rendono facile l'implementazione.

@LanciWeb
LanciWeb / layout.ahk
Created May 16, 2024 16:34 — forked from scollovati/layout.ahk
Digita Backtick ` e Tilde ~ su Windows senza Tastierino Numerico
#Requires AutoHotkey v2.0
<^>!'::Send "``" ; AltGr + ' => `
<^>!vkDD::Send "~" ; AltGr + ì => ~