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 / .bash_profile
Last active October 13, 2018 10:14
File ".bash_profile" located in "/home/username/"
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# Replace "username" by your username
ME="username"
@CharlieEtienne
CharlieEtienne / post-update
Last active October 13, 2018 10:30
Git hook "post-update" located in "/home/username/.git/hooks/"
#!/bin/bash
#
# Hook script to pull automatically
# stage branch in /stage folder and master branch in /prod folder
# when a push is detected
# Replace "username" by your username
ME="username"
@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"
@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 / 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 / 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 / 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 / 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 / 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 / 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);