Skip to content

Instantly share code, notes, and snippets.

View olivertappin's full-sized avatar
😁

Oliver Tappin olivertappin

😁
View GitHub Profile
@olivertappin
olivertappin / update-bower-dependencies.sh
Created November 2, 2016 23:58
Update all dependencies for Bower using --save in the expected way
if hash jq 2>/dev/null; then
brew install jq
fi
for module in $(jq '.dependencies | keys' bower.json | strings); do
bower install --save $(echo $module | tr -d '",')
done
@olivertappin
olivertappin / wordpress.cron
Created November 29, 2016 08:33
WordPress cron: Cron job
0,30 * * * * wget -qO- --delete-after https://yourdomain.com/wp-cron.php?doing_wp_cron
@olivertappin
olivertappin / gist:055c16637831dc456b3ceb47beea7aee
Last active December 9, 2016 08:30
Backup and restore public_html
# Backup a directory
cd ~
tar cvfz public_html.tar.gz public_html/
# Restore a directory
cd ~/public_html/
tar xvfz ../public_html.tar.gz
@olivertappin
olivertappin / gist:494c253e3a3333e3dfade66d5ff3cf7c
Created December 23, 2016 09:52
Gem command not found: DeployBot issue when using Docker Containers (via AtomicFTP)
# Preparing custom image for running build commands.
# /usr/local/rvm/scripts/override_gem: line 19: gem: command not found
# ...
# events.js:85
# output throw er; // Unhandled 'error' event
# output ^
# output Error: Gem sass is not installed.
##
# To fix, add the following code to the start of your container setup scripts
@olivertappin
olivertappin / gist:68dccee93ee78a8bd481a4b4be257fcd
Created March 1, 2017 19:18
Remove file extension with .htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
CREATE USER 'dev'@'localhost' IDENTIFIED BY 'dev';
GRANT ALL PRIVILEGES ON *.* TO 'dev'@'localhost';
CREATE USER 'dev'@'%' IDENTIFIED BY 'dev';
GRANT ALL PRIVILEGES ON *.* TO 'dev'@'%';
FLUSH PRIVILEGES;
@olivertappin
olivertappin / random.php
Created May 14, 2017 19:25
A page which randomly loads items from an array, without repeating itself.
<?php
session_start();
if (!array_key_exists('items', $_SESSION) || [] === $_SESSION['items']) {
$_SESSION['items'] = [
'Go to the park',
'Draw something',
'Go to the zoo',
'Play a musical instrument',
@olivertappin
olivertappin / create-phar.php
Created June 6, 2017 21:14
Create a Phar file
<?php
$phar = new Phar('project.phar', 0, 'project.phar');
$phar->buildFromDirectory(dirname(__FILE__) . '/phar');
$phar->setStub($phar->createDefaultStub('index.php'));
// To generate the .phar file, run the following commands from the current directory:
// mkdir -p phar
// cp -R ./*.php phar/.
// cd phar && php ../build-phar.php
<?php
print('foo') && print(' ') && print('bar'); // bar11
print('foo') || print(' ') && print('bar'); // 1
print('foo') && print(' ') || print('bar'); // 11
print('foo') || print(' ') || print('bar'); // 1
@olivertappin
olivertappin / gist:5a7c58c500f701430c1cd2becd53fe1d
Created July 30, 2017 15:59
Laravel .htaccess from public_html directory for a shared hosting environment
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>