Skip to content

Instantly share code, notes, and snippets.

View Giacomo92's full-sized avatar
🕶️
OFFline

Giacomo Fabbian Giacomo92

🕶️
OFFline
View GitHub Profile
@Giacomo92
Giacomo92 / calculate_apache_mpm_config.sh
Created January 24, 2024 07:57 — forked from Josh5/calculate_apache_mpm_config.sh
A rough calculation of Apache MPM config
#!/bin/bash
#
# @Author: Josh Sunnex
# @Date: 2019-01-31 10:26:00
# @Last Modified by: josh5
# @Last Modified time: 2019-01-31 10:36:07
#
# usage:
# curl -sSL https://gist.githubusercontent.com/Josh5/ff6ccfe4c75ae27a3f1efebcb645e7c4/raw/calculate_apache_mpm_config.sh | bash -s [PID]
#
@Giacomo92
Giacomo92 / deploy.sh
Created December 1, 2022 16:08 — 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
@Giacomo92
Giacomo92 / functions.php
Created February 15, 2022 12:30 — forked from CharlieEtienne/functions.php
Whitelist IPs in Elementor Maintenance Mode
<?php
function my_elementor_maintenance_mode_whitelist_ips() {
// IPs Whitelist
$whitelist = [
'127.0.0.1',
'88.123.181.218',
];
@Giacomo92
Giacomo92 / webview.js
Created December 22, 2021 14:54 — forked from sdiama/webview.js
React Native: Handle hardware back button @ webview
import React, { Component } from 'react';
import { WebView, BackHandler } from 'react-native';
export default class WebViewMoviezSpace extends Component {
constructor(props) {
super(props);
this.WEBVIEW_REF = React.createRef();
}
componentDidMount() {

How to setup AWS lambda function to talk to the internet and VPC

I'm going to walk you through the steps for setting up a AWS Lambda to talk to the internet and a VPC. Let's dive in.

So it might be really unintuitive at first but lambda functions have three states.

  1. No VPC, where it can talk openly to the web, but can't talk to any of your AWS services.
  2. VPC, the default setting where the lambda function can talk to your AWS services but can't talk to the web.
  3. VPC with NAT, The best of both worlds, AWS services and web.
@Giacomo92
Giacomo92 / OrderByField.php
Created October 16, 2019 17:17 — forked from andreshg112/OrderByField.php
It can be used for queries like this in MySQL: `SELECT * FROM `plans` ORDER BY FIELD(`interval`, 'day', 'week', 'month', 'year');`
<?php
namespace App\Traits;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\DB;
/**
* Traits that eases the use of ORDER BY FIELD with an eloquent model.
@Giacomo92
Giacomo92 / 1_Laravel_state-machine.md
Created October 8, 2019 16:10 — forked from iben12/1_Laravel_state-machine.md
Laravel: State-machine on Eloquent Model

Implementing State Machine On Eloquent Model*

* Update (12.09.2017): I have improved the trait so that it can be used with objects other than Eloquent Models.

Some days ago I came across a task where I needed to implement managable state for an Eloquent model. This is a common task, actually there is a mathematical model called "Finite-state Machine". The concept is that the state machine (SM) "can be in exactly one of the finite number of states at any given time". Also changing from one state to another (called transition) depends on fulfilling the conditions defined by its configuration.

Practically this means you define each state that the SM can be in and the possible transitions. To define a transition you set the states on which the transition can be applied (initial conditions) and the only state in which the SM should be after the transition.

That's the theory, let's get to the work.

@Giacomo92
Giacomo92 / MySQL_macOS_Sierra.md
Created October 20, 2017 14:14 — forked from nrollr/MySQL_macOS_Sierra.md
Install MySQL on Sierra using Homebrew

Install MySQL on macOS Sierra

This procedure explains how to install MySQL using Homebrew on macOS Sierra 10.12

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.

Install MySQL

At this time of writing, Homebrew has MySQL version 5.7.15 as default formulae in its main repository :

@Giacomo92
Giacomo92 / vhost.py
Created September 5, 2017 12:05 — forked from fideloper/vhost.py
Create vHost Ubuntu Lamp-Server (bash and python)
#! /usr/bin/python
from sys import argv
from os.path import exists
from os import makedirs
from os import symlink
from os import system
import getopt
#