Skip to content

Instantly share code, notes, and snippets.

@ramonchito2
ramonchito2 / Helpful bash aliases and functions
Last active February 28, 2018 23:37
Helpful bash aliases and functions for .bashrc. -- Includes function to easily navigate to a specified folder with <tab> auto completion
##### NOTE - The following aliases and functions use my Cygwin directory. Be sure to edit these for your use case. ####
# Override source alias to default to this file
alias source='source /home/jglynn/.bashrc'
# Override 'ls' command
alias ls='ls -AhF --color=tty' #classify files in colour by default
alias ll='ls -lhA' #long list
# Demo - quick ssh into sites
@ramonchito2
ramonchito2 / README.md
Last active September 26, 2017 20:17
Nginx location rules for fallback images from live (Homestead)

Dynamically update nginx config files for each site on provision so location rules aren't lost.

When using Laravel's Homestead, one thing that can be a pain is having to constantly re-add configuration rules in your site's nginx config upon provisioning. This is infinitely worse when you have to configure multiple sites 😤 . However with this setup, you can put those days behind you. The following instructions focus on location, however this can be applied to pretty much anything.

The location rule here pulls images from your live site if they don't exist on your local dev environment. Helps reduce GBs of unnecessary assets on your local machine In order for the following code to work, your site folder must have the same name as the live site.

Edit Homestead's default nginx config shell script

  • Inside of the ~/Homestead/scripts folder, edit "serve-laravel.sh".

  • Insert the accompaning code in its respective places.

@ramonchito2
ramonchito2 / gist:00da8d09f9c913117673281dc4babe66
Last active January 11, 2017 19:03
Load Wordpress media files from prod if they don't exist locally via .htaccess
# Load media files from production server if they don't exist locally
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^local\.dev$
RewriteRule ^wp-content/uploads/(.*)$ http://remote.com/wp-content/uploads/$1 [NC,L]
</IfModule>
# Make sure 'local.dev' and 'remote.com' are replaced by your own domains respectively.
@ramonchito2
ramonchito2 / checkPageVisibility.js
Created January 27, 2016 21:36
Check to see if the current tab is visible
// CHECK TO SEE IF THE CURRENT TAB IS VISIBLE
// Set the name of the hidden property and the change event for visibility
var hidden, visibilityChange;
if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support
hidden = "hidden";
console.log('I have been hidden');
visibilityChange = "visibilitychange";
} else if (typeof document.mozHidden !== "undefined") {
hidden = "mozHidden";
console.log('Moz has been hidden');