Skip to content

Instantly share code, notes, and snippets.

Avatar

Bold Move makeitaboldmove

View GitHub Profile
@makeitaboldmove
makeitaboldmove / retain-selected-input-type-file-files.js
Created Nov 26, 2019
If input (upload) file isn't changed keep previous file attached with jQuery
View retain-selected-input-type-file-files.js
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 Nov 10, 2019
Create Google Drive symlinks for fresh macOS install or new user.txt
View create-google-drive-symlinks-fresh-macos-install-new-user
@makeitaboldmove
makeitaboldmove / functions--example-wp_ajax_-wp_ajax_nopriv_-actions.php
Last active Sep 11, 2018
How To Create Custom WordPress Ajax Endpoint That Works For Both Admins and Visitors
View functions--example-wp_ajax_-wp_ajax_nopriv_-actions.php
<?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 Sep 16, 2018
How to minify HTML using WordPress functions.php
View functions--wordpress-minify-class.php
<?php
/*********
*********
Minify
*********
*********/
class WP_Minify{
protected $compress_css = true;
protected $compress_js = false;
@makeitaboldmove
makeitaboldmove / nginx.conf (gzip_types)
Last active Sep 10, 2018
Speed up your website on an nginx server by adding modern gzip_types to nginx.conf in the http block
View nginx.conf (gzip_types)
##
# 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 Sep 11, 2018
How To Detect Middle Eastern Users Using PHP
View isMENA-function-example.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 Nov 4, 2018
How to speed up your WordPress website hosted on Apache2 using htaccess
View .htaccess (Speed Up WordPress)
<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 Nov 10, 2019
Fresh Ubuntu, NodeJS, LetsEncrypt, Etc. Installation
View 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