Skip to content

Instantly share code, notes, and snippets.

View CharlieEtienne's full-sized avatar
🖖
Hi GitHub!

Charlie Etienne CharlieEtienne

🖖
Hi GitHub!
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',
];
@CharlieEtienne
CharlieEtienne / functions.php
Last active April 20, 2022 07:27
Add custom links to each image in Elementor Carousel
<?php
add_filter( 'attachment_fields_to_edit', function( $form_fields, $post ) {
$form_fields[ 'elementor_carousel_custom_link' ] = array(
'label' => __( 'Custom link', 'elementor' ),
'input' => 'text',
'value' => get_post_meta( $post->ID, 'elementor_carousel_custom_link', true ),
'helps' => __( 'This will add a link to images in Elementor Carousel', 'elementor' ),
);
@CharlieEtienne
CharlieEtienne / splitter.php
Created August 27, 2020 00:02
Split multi SCORM
<?php
define('BASEDIR', "splitted/");
$unite = 0;
foreach( glob("MODULE*/*/imsmanifest.xml") as $file ) {
$chapitre = 0;
$parent_dir = dirname($file);
$dest_parent_dir = BASEDIR . $parent_dir;
$xmlstr = file_get_contents($file);
@CharlieEtienne
CharlieEtienne / profile.ps1
Last active January 22, 2023 09:49
PowerShell Welcome Message
$curUser = (Get-ChildItem Env:\USERNAME).Value
$curComp = (Get-ChildItem Env:\COMPUTERNAME).Value
$pvmaj = $Host.Version.Major
$pvmin = $Host.Version.Minor
$psversion = "$pvmaj.$pvmin"
$identity = "$curUser@$curComp"
#-----------------------------------------------------
# WINDOW TITLE
@CharlieEtienne
CharlieEtienne / paginate-eloquent-collections.php
Created May 13, 2019 07:45
This allows you to call ->paginate() on an Eloquent Collection
<?php
use Illuminate\Database\Eloquent\Collection;
// Register in 'boot()' method in app/Providers/AppServiceProvider.php
// This allows you to call ->paginate() on an Eloquent Collection
Collection::macro('paginate', function ($perPage = 10, $current_page = null, $options = []) {
$current_page = $current_page ?: (Paginator::resolveCurrentPage() ?: 1);
return (new LengthAwarePaginator($this->forPage($current_page, $perPage)->values()->all(), $this->count(), $perPage, $current_page, $options))->withPath('');
});
@CharlieEtienne
CharlieEtienne / dev_deploy
Created May 9, 2019 07:49
Dev/Staging deploy script
#!/bin/bash
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# Replace "username" by your username
ME="username"
@CharlieEtienne
CharlieEtienne / prod_deploy
Created May 8, 2019 20:18
Production deploy script
#!/bin/bash
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# Replace "username" by your username
ME="username"
@CharlieEtienne
CharlieEtienne / display_included_files.php
Last active May 3, 2019 09:59
Display the names of all files that have been included using include, include_once, require or require_once.
<?php
if ( ! function_exists( 'display_included_files' ) ) {
/**
* Display the names of all files that have been included using include, include_once, require or require_once.
*
* @param bool|array $filters Array of strings to filter results. Ex: ['my-template', 'elementor'].
* @param bool $display Display on screen or in javascript console. Default false.
*/
function display_included_files( $filters = false, $display = false ) {
@CharlieEtienne
CharlieEtienne / config
Created March 13, 2019 07:49
Git config with two remote repositories (GitHub + Remote server)
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
[remote "origin"]
url = ssh://username@ssh.server_adress:22/home/username/git/myproject.git
fetch = +refs/heads/*:refs/remotes/origin/*
@CharlieEtienne
CharlieEtienne / copy-ssh-key.sh
Last active October 14, 2018 07:56
Copy SSH Key command on OVH shared hosting
# Copy SSH Key command on OVH shared hosting
# Replace "username", "cluster001" with your personal informations
# Replace "~/.ssh/id_ed25519.pub" by the path to your public rsa key if you have a custom one
cat ~/.ssh/id_ed25519.pub | ssh ssh://username@ssh.cluster001.hosting.ovh.net "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"