Skip to content

Instantly share code, notes, and snippets.

Avatar

Franck franckweb

View GitHub Profile
@franckweb
franckweb / filesloader.php
Last active Apr 14, 2021
Read files from local directory with PHP, performance comparison between glob, scandir, readdir and DirectoryIterator.
View filesloader.php
<?php
/*
* Prints out time the specified method takes to run.
* Just need to add a bunch of files in your specified directory
*
* From console: php index.php [name_of_method] (ex: php index.php runiterator)
* From web request: go to http://yourdomain.test/?test=[name_of_method] (ex: http://yourdomain.test/?test=runglob)
*
*/
@franckweb
franckweb / tmux.md
Last active Sep 4, 2020
Tmux shortcuts
View tmux.md

add to ~/.tmux.conf

set-option -g default-shell /bin/zsh
set -g mouse on
bind e set-window-option synchronize-panes

list sessions

tmux ls

@franckweb
franckweb / bulk_dir_rename.sh
Created May 6, 2020
Bash script to bulk rename subdirectories to lowercase and change spaces for underscore
View bulk_dir_rename.sh
#!/bin/bash
# use: "bash bulk_dir_rename.sh path"
source_dir=$1
for found_dir in $source_dir/*;
do
original_dir_name=$(basename "${found_dir}")
lowercase_name=${original_dir_name,,}
no_space_dir=$(echo "$lowercase_name" | sed -e 's/ /_/g')
@franckweb
franckweb / bulk-image-process.sh
Last active Apr 25, 2020
Convert optimize resize multiple images through bash script
View bulk-image-process.sh
# USAGE
# bash bulk-image-process.sh [path/to/images]
# current exec folder is used as destination
destination_dir=$(pwd)
source_dir=$1
for photo in $source_dir/*.jpg;
do
View alias.sh
# Prints permissions in octal format
# perms filename.jpg
# perms *
alias perms='stat -c "%a %n"'
@franckweb
franckweb / mysql-workbench-install.txt
Created Feb 9, 2020
Mysql Workbench for Ubuntu 16.04 installation
View mysql-workbench-install.txt
# MYSQL WORKBENCH installation
# download archive version for Ubuntu 16.04 from
# https://downloads.mysql.com/archives/workbench/
# running
sudo dpkg -i mysql-workbench-community-6.3.10-1ubuntu16.04-amd64.deb
# throws error
(Reading database ... 278976 files and directories currently installed.)
Preparing to unpack mysql-workbench-community-6.3.10-1ubuntu16.04-amd64.deb ...
@franckweb
franckweb / automate-virtualmin.ssh
Created Oct 6, 2018
Move non-Virtualmin accounts into Virtualmin transferring data and databases
View automate-virtualmin.ssh
# Move non-Virtualmin accounts into Virtualmin transferring data and databases
# When its done update config files
# TODO: automate the updating of common config files
# Connects to the destination server to create the Virtualmin server
#Then connects to the source to move files and databases across
set -e
# New Site Settings
@franckweb
franckweb / woocommerce-functions.php
Created Jun 28, 2018
Personalized woocommerce for wordpress
View woocommerce-functions.php
/*
* Personalized sorting options
*/
add_filter( 'woocommerce_get_catalog_ordering_args', 'custom_woocommerce_get_catalog_ordering_args' );
function custom_woocommerce_get_catalog_ordering_args( $args ) {
$orderby_value = isset( $_GET['orderby'] ) ? woocommerce_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
$fallback = apply_filters( 'wc_extra_sorting_options_fallback', 'title', $orderby_value );
$fallback_order = apply_filters( 'wc_extra_sorting_options_fallback_order', 'ASC', $orderby_value );
View programs-installs.sh
# ALBERT A fast and flexible keyboard launcher
## installation taken from
## https://software.opensuse.org//download.html?project=home%3Amanuelschneid3r&package=albert
## For xUbuntu 18.04 run the following
echo 'deb http://download.opensuse.org/repositories/home:/manuelschneid3r/xUbuntu_18.04/ /' | sudo tee /etc/apt/sources.list.d/home:manuelschneid3r.list
curl -fsSL https://download.opensuse.org/repositories/home:manuelschneid3r/xUbuntu_18.04/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/home_manuelschneid3r.gpg > /dev/null
sudo apt update
sudo apt install albert
View vim-plugins.sh
# VIM PLUGINS
## Install Pathogen (vim plugins manager)
mkdir -p ~/.vim/autoload ~/.vim/bundle;
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
## Create ~/.vimrc and add these contents
" contents of minimal .vimrc
execute pathogen#infect()
syntax on
filetype plugin indent on