This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check if a directory has been supplied. | |
if [ -z "$1" ]; then | |
echo "You must supply a directory." | |
exit 0 | |
# Check directory exists. | |
elif [ ! -d "$1" ]; then | |
echo "That directory does not exist." | |
exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --------------------------------------------------------------------------- | |
# System aliases. | |
# --------------------------------------------------------------------------- | |
# | |
# Color support. | |
if [ -x /usr/bin/dircolors ]; then | |
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" | |
alias ls='ls --color=auto' | |
alias grep='grep --color=auto' | |
alias fgrep='fgrep --color=auto' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
functionName() { | |
} | |
PS3='Please select an option: ' | |
options=("Reset database and keys (clean install)" "Reinstall all composer dependencies" "Both" "Quit") | |
select opt in "${options[@]}" | |
do | |
case $opt in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# musicsorter.sh | |
# | |
# About: | |
# Will sort a directory of music files by recognising the track name and sorting them into directories like Artist > Track Name.ext. | |
# | |
# How To Use: | |
# `bash musicsorter.sh ./path/to/directory` | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dev images from live domain. | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteRule (.*\.(gif|jpg|png)) http://livedomain.com/$1 [QSA,R,L] | |
</IfModule> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* extract_youtube_video | |
* Extracts a YouTube iframe video from a string. | |
* | |
* @since 1.0.0 | |
* @version 1.0.0 | |
**/ | |
function extract_youtube_video($string, $decode = true){ | |
// Decode string. | |
$content = ($decode) ? html_entity_decode($string, ENT_QUOTES, 'utf-8') : $string; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* word_limit | |
* Cuts a string by word count. | |
* | |
* @since 1.0.0 | |
* @version 1.0.0 | |
**/ | |
function word_limit($string, $limit, $end = '…'){ | |
$words = explode(" ", $string); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* array_contains | |
* Check if string contains word from array. | |
* | |
* @since 1.0.0 | |
* @version 1.0.0 | |
**/ | |
function array_contains($str, array $arr){ | |
foreach($arr as $a){ | |
if(stripos($str, $a) !== false) return true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* array_searchr | |
* Multi dimensional array_search(). | |
* | |
* @since 1.0.0 | |
* @version 1.0.0 | |
**/ | |
function array_searchr($id, $array, $key, $return = false, $query = false){ | |
$matches = array(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* in_arrayr | |
* Multi dimensional in_array(). | |
* | |
* @since 1.0.0 | |
* @version 1.0.0 | |
**/ | |
function in_arrayr($needle, $haystack, $strict = false) { | |
foreach($haystack as $item){ | |
if(($strict ? $item === $needle : $item == $needle) || (is_array($item) && in_arrayr($needle, $item, $strict))){ |
NewerOlder