Skip to content

Instantly share code, notes, and snippets.

View makeitaboldmove's full-sized avatar

Bold Move makeitaboldmove

View GitHub Profile
@makeitaboldmove
makeitaboldmove / retain-selected-input-type-file-files.js
Created November 26, 2019 06:47
If input (upload) file isn't changed keep previous file attached with jQuery
let $clones = {};
$(document).ready(function(){
$(document).on('click', 'input[type="file"]', function($e){
if($(this).val() != ''){
$clones[$e.target.id] = $(this).clone();
}
});
$(document).on('change', 'input[type="file"]', function($e){
if($(this).val() == ""){
$clones[$e.target.id].insertBefore($(this));
@makeitaboldmove
makeitaboldmove / create-google-drive-symlinks-fresh-macos-install-new-user
Last active November 10, 2019 02:32
Create Google Drive symlinks for fresh macOS install or new user.txt
@makeitaboldmove
makeitaboldmove / functions--example-wp_ajax_-wp_ajax_nopriv_-actions.php
Last active November 4, 2021 12:54
How To Create Custom WordPress Ajax Endpoint That Works For Both Admins and Visitors
<?php
// Add wp_ajax_ and wp_ajax_nopriv_ actions
add_action('wp_ajax_locations', 'wp_ajax_get_locations');
add_action('wp_ajax_nopriv_locations', 'wp_ajax_get_locations');
// Get locations function
function wp_ajax_get_locations(){
// Latitude and longitude (defaults to Dayton, Ohio)
$lat = isset($_POST['lat']) ? $_POST['lat'] : 39.758949;
@makeitaboldmove
makeitaboldmove / functions--wordpress-minify-class.php
Last active September 16, 2018 19:43
How to minify HTML using WordPress functions.php
<?php
/*********
*********
Minify
*********
*********/
class WP_Minify{
protected $compress_css = true;
protected $compress_js = false;
@makeitaboldmove
makeitaboldmove / nginx.conf (gzip_types)
Last active September 10, 2018 15:08
Speed up your website on an nginx server by adding modern gzip_types to nginx.conf in the http block
##
# Gzip Settings
##
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_http_version 1.1;
gzip_disable "msie6";
gzip_static always;
@makeitaboldmove
makeitaboldmove / isMENA-function-example.php
Last active September 11, 2018 03:32
How To Detect Middle Eastern Users Using PHP
<?php
if(isMENA()){
echo '<img src="/images/mena-image.png" alt="MENA Image" />';
} else {
echo '<img src="/images/other-image.png" alt="Other Image" />';
}
@makeitaboldmove
makeitaboldmove / .htaccess (Speed Up WordPress)
Last active November 4, 2018 14:53
How to speed up your WordPress website hosted on Apache2 using htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
<IfModule mod_deflate.c>
@makeitaboldmove
makeitaboldmove / Fresh Ubuntu, NodeJS, LetsEncrypt, Etc. Installation
Last active November 10, 2019 02:33
Fresh Ubuntu, NodeJS, LetsEncrypt, Etc. Installation
# THIS IS OUT OF DATE, PLEASE FIND ANOTHER GIST OR TUTORIAL.
# Update Ubuntu and Packages
sudo apt-get update
sudo apt-get dist-upgrade -y
sudo apt-get upgrade -y
# Install NGINX