Skip to content

Instantly share code, notes, and snippets.

View dellow's full-sized avatar

Stew Dellow dellow

  • J&S Accessories
  • UK
View GitHub Profile
#!/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
@dellow
dellow / .bash_aliases
Last active July 19, 2018 16:10
Dot Files
# ---------------------------------------------------------------------------
# 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'
#!/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
@dellow
dellow / musicsorter.sh
Last active September 13, 2016 23:18
Music Files Sorter
#!/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`
#
@dellow
dellow / .htaccess
Created August 4, 2015 13:27
Dev images from live domain
# 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>
@dellow
dellow / extract_youtube_video.php
Last active October 5, 2021 10:09
Extracts a YouTube iframe video from a string.
/**
* 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;
@dellow
dellow / word_limit.php
Last active August 29, 2015 14:18
Cuts a string by word count.
/**
* word_limit
* Cuts a string by word count.
*
* @since 1.0.0
* @version 1.0.0
**/
function word_limit($string, $limit, $end = '&hellip;'){
$words = explode(" ", $string);
@dellow
dellow / array_contains.php
Last active September 20, 2022 03:27
Check if string contains word from array.
/**
* 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;
@dellow
dellow / array_searchr.php
Last active October 5, 2021 10:13
Multi dimensional array_search().
/**
* 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();
@dellow
dellow / in_arrayr.php
Last active October 5, 2021 10:10
Multi dimensional in_array().
/**
* 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))){