Skip to content

Instantly share code, notes, and snippets.

View Giacomo92's full-sized avatar
🕶️
OFFline

Giacomo Fabbian Giacomo92

🕶️
OFFline
View GitHub Profile
@CharlieEtienne
CharlieEtienne / functions.php
Created December 12, 2021 21:23
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',
];
@wpbean
wpbean / functions.php
Created February 29, 2020 08:12
LearnPress add custom tabs to courses
<?php
/**
* Add Custom Tab
* Add this code to your theme or child theme functions.php file
*/
add_filter( 'learn-press/course-tabs', 'wp_education_course_tab_customize' );
function wp_education_course_tab_customize( $tabs ){
<?php
/**
* Get the user's roles
* @since 1.0.0
*/
function wcmo_get_current_user_roles() {
if( is_user_logged_in() ) {
$user = wp_get_current_user();
$roles = ( array ) $user->roles;
return $roles; // This returns an array
@Josh5
Josh5 / calculate_apache_mpm_config.sh
Last active June 19, 2024 13:26
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]
#
@andreshg112
andreshg112 / OrderByField.php
Last active April 6, 2023 09:25
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;
/**
* Traits that eases the use of ORDER BY FIELD with an eloquent model.
* https://github.com/laravel/ideas/issues/1066
*/
trait OrderByField
{
@NassimRehali15
NassimRehali15 / 2018_02_13_142413_add_renews_at_column_to_subscriptions.php
Last active November 15, 2023 20:23 — forked from garygreen/2018_02_13_142413_add_renews_at_column_to_subscriptions.php
Sync Stripe Renewal Date for all subscriptions - Laravel Console Command
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddRenewsAtColumnToSubscriptions extends Migration
{
/**
* Run the migrations.
@xenogew
xenogew / Dockerfile
Created October 30, 2018 06:32
Example of PHP 7.2.x Docker image install with MS SQL Server extensions
FROM php:7.2.11-fpm
WORKDIR /application
ENV ACCEPT_EULA=Y
# Fix debconf warnings upon build
ARG DEBIAN_FRONTEND=noninteractive
# Install selected extensions and other stuff
RUN apt-get update \
@BenSampo
BenSampo / deploy.sh
Last active June 18, 2024 01:44
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
@ollieread
ollieread / builder.php
Last active February 15, 2022 15:48
Laravel query builder recursive CTE support
<?php
$recursive = $this->query()
->recursive('parents', function (Builder $query) {
$query
->select([
'*',
new Alias('slug', 'fullslug'),
new Alias(0, 'depth'),
new Alias('id', 'tree_id'),
new Alias('name', 'path'),
@achmadfatoni
achmadfatoni / guzzle_raw_post_request.php
Created August 29, 2017 09:21
Guzzle Raw POST request
$client = new Client();
$array = [];
$res = $client->request('POST', $url, [
'body' => json_encode($array),
'headers' => [
'Content-Type' => 'application/json',
]
]);