Skip to content

Instantly share code, notes, and snippets.

View LanciWeb's full-sized avatar

Marco Lancellotti LanciWeb

View GitHub Profile
@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 + ì => ~
@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 / 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

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 / 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) => {
@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 / markdown_reference.md
Last active January 29, 2024 15:42
Mardown Reference

Tutorial Markdown

Headings

Gli headings si ottengono con il #. Più cancelletti inseriamo, più piccolo sara l'heading.

# Heading 1
## Heading 2
### Heading 3
@LanciWeb
LanciWeb / postsActions.js
Last active November 28, 2020 17:05
example of async action
export const fetchPosts = () => async (dispatch, getReduxStore) => {
const posts = await fetch('/posts');
// some other code...
/* this will return the current store
allowing us to make tests based on
current values if we need to */
const store = getReduxStore();
@LanciWeb
LanciWeb / index.js
Created November 28, 2020 16:56
Wiring up redux thunk
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import { createStore, applyMiddleware } from 'redux'; //applyMiddleware comes from redux
import { Provider } from 'react-redux';
import reducers from './reducers';
import thunk from 'redux-thunk';
const store = createStore(combinedReducers, applyMiddleware(thunk)); //applyMuddleware adds thunk to the store
@LanciWeb
LanciWeb / MyList.js
Created November 28, 2020 16:32
useDispatch example
import React from 'react';
import {useSelector} from 'react-redux';
const MyList = () => {
const dispatch = useDispatch();
const list = useSelector(state => state.itemsList.items);
return (
<div>
{props.list.map(i => (