Skip to content

Instantly share code, notes, and snippets.

View macariojames's full-sized avatar
💭
Making things. All the things. Ahh!

Macario James macariojames

💭
Making things. All the things. Ahh!
View GitHub Profile
@macariojames
macariojames / apache2.conf
Created January 27, 2019 20:16
For gzip compression - Add to Apache conf file
<Directory /var/www/html/>
<IfModule mod_mime.c>
AddType application/x-javascript .js
AddType text/css .css
</IfModule>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/plain text/xml application/javascript
<IfModule mod_setenvif.c>
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
@macariojames
macariojames / .htaccess
Last active January 26, 2019 16:06
Leverage Browser Caching - Apache - Add this to .htaccess file
# Thank you to this gist for some edits (check history! lol) https://gist.github.com/Zodiac1978/3145830
# Leverage Browser Caching
# Fonts
# Add correct content-type for fonts
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-ttf .ttf
AddType application/x-font-opentype .otf
AddType application/x-font-woff .woff
AddType image/svg+xml .svg
@macariojames
macariojames / .htaccess
Created January 26, 2019 15:51
Enable Gzip Compression - Apache - Add this to the .htaccess file
# Enable Compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
@macariojames
macariojames / display-active-functions.php
Last active October 29, 2018 19:50
WordPress/PHP: display active functions
echo "<pre>"; print_r( get_defined_functions() );
@macariojames
macariojames / mobile-map-clicker-jquery.js
Last active October 29, 2018 18:40
Link opens Google Maps, iOS Maps on mobile device; normal browser link otherwise (jQuery)
// Checks if on mobile device
// Changes link to go to Google Maps
// Which should open automatically in Apple or Google Maps on Android/iOS device ~mj
function mobileMapClicker() {
console.log(navigator.userAgent);
// Checks userAgent if mobile device
if (/Mobi/.test(navigator.userAgent)) {
console.log('Mobile Device Detected!');
/* if we're on iOS, open in Apple Maps */
@macariojames
macariojames / remove-password-protected-posts-from-the-loop.php
Last active August 31, 2018 20:53
Remove password protected posts from the Loop
<?php // WordPress Stuffs!
// Add this to functions.php
// for removing password protected posts from the Loop
function wpb_password_post_filter( $where = '' ) {
if (!is_single() && !is_admin()) {
$where .= " AND post_password = ''";
}
return $where;
}
@macariojames
macariojames / instagram-feed.js
Created August 31, 2018 20:47
Sorta vanilla javascript instagram feed
// thank you https://ariasthompson.com/2018/02/08/adding-instagram-feed-website-without-plugin/
// for the basis of this feed grab
var getInstagramFeed = function () {
var request = new XMLHttpRequest();
var token = 'ACCESS_TOKEN';
var count = 3;
request.open('GET', 'https://api.instagram.com/v1/users/self/media/recent/?access_token='+token+'&count='+count, true);
request.onload = function(container) {
@macariojames
macariojames / wp_-sql-query.sql
Created August 27, 2018 18:17
SQL to change default WordPress tables (wp_ to wp_customname_)
RENAME table `wp_commentmeta` TO `wp_localapi_commentmeta`;
RENAME table `wp_comments` TO `wp_localapi_comments`;
RENAME table `wp_links` TO `wp_localapi_links`;
RENAME table `wp_options` TO `wp_localapi_options`;
RENAME table `wp_postmeta` TO `wp_localapi_postmeta`;
RENAME table `wp_posts` TO `wp_localapi_posts`;
RENAME table `wp_terms` TO `wp_localapi_terms`;
RENAME table `wp_termmeta` TO `wp_localapi_termmeta`;
RENAME table `wp_term_relationships` TO `wp_localapi_term_relationships`;
RENAME table `wp_term_taxonomy` TO `wp_localapi_term_taxonomy`;
@macariojames
macariojames / nginx.conf
Last active August 20, 2018 19:08 — forked from jaxbot/gist:5748513
Block nginx from serving .git directories; Block apache from serving .gif directories
# For nginx -- goes in the /sites-available/domainnamehere.com file
location ~ /\.git {
return 404;
#deny all;
}
# or, all . directories/files in general (including .htaccess, etc)
# i like to use 'deny all' for all . files ~mj
location ~ /\. {
@macariojames
macariojames / gzip-compression-nginx.conf
Created August 16, 2018 19:09
gzip compression with nginx
via Jack Wallen @jlwallen
-- This goes in /etc/ngnix/ngnix.conf
gzip on;
gzip_vary on;
gzip_min_length 10240;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
gzip_disable "MSIE [1-6]\.";