Skip to content

Instantly share code, notes, and snippets.

View rxnlabs's full-sized avatar

De'Yonte W. rxnlabs

View GitHub Profile
@rxnlabs
rxnlabs / js-read-get.js
Last active December 25, 2015 05:18
Javascript - Read URL parameters from URL string
//source http://papermashup.com/read-url-get-variables-withjavascript/
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
@rxnlabs
rxnlabs / js-scroll-show-element.js
Last active December 25, 2015 07:29
Javascript - Show Elements on page after a page scroll
var isVisible = false;
$(window).scroll(function(){
var shouldBeVisible = $(window).scrollTop()>200;
if (shouldBeVisible && !isVisible) {
isVisible = true;
$('#mybutton').show();
} else if (isVisible && !shouldBeVisible) {
isVisible = false;
$('#mybutton').hide();
}
@rxnlabs
rxnlabs / js-todays-date.js
Last active August 29, 2015 13:56
Javascript - Show Today's Date
//http://stackoverflow.com/questions/1531093/how-to-get-current-date-in-javascript
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10){dd='0'+dd} if(mm<10){mm='0'+mm} today = mm+'/'+dd+'/'+yyyy;
document.write(today);
@rxnlabs
rxnlabs / mongodb-cpanel-install
Last active July 8, 2021 19:20
Install MongoDB on cPanel/WHM
http://www.webmaster.net/how-install-mongodb-centos-6x-or-whm-server
http://linuxdiviner.wordpress.com/2012/07/25/compile-and-install-php-module-without-easyapache-on-cpanel-servers/
1. cd /etc/yum.repos.d
2. vi mongodb.repo
3. Add this code to file
[mongodb]
name=MongoDB Repo
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
@rxnlabs
rxnlabs / js-gravityform-save-multistep.js
Last active July 7, 2022 12:29
WordPress - Save and submit a multistep form using Gravity Forms. Multistep forms don't allow you to submit the form if the user decides to leave before completing the form. This allows the user to submit the form at any step.
//clone the form submit button for the form
var save_btn = jQuery('#gform_submit_button_2').clone();
//change the label of the midway submit button
save_btn.val('Save and Submit');
//get the ID of the gravity form
var gravity_form = jQuery('#gform_submit_button_2').closest('form');
var gravity_form_id = gravity_form.attr('id');
gravity_form_id = gravity_form_id.split("_");
gravity_form_id = gravity_form_id[1];
//get the last page of the form
@rxnlabs
rxnlabs / js-optimizely-luckyorange.js
Last active August 29, 2015 13:58
Grab the Optimizely experiment information uisng javasacript and tag experiments in LuckyOrange
var experimentID = window['optimizely'].data.state.activeExperiments[0];
var variationIndex = window['optimizely'].data.state.variationMap[experimentID];
var variationName = window['optimizely'].data.state.variationNamesMap[experimentID];
var variationID = window['optimizely'].data.state.variationIdsMap[experimentID];
var experiment_name = window['optimizely'].data.experiments[experimentID].name;
if (optimizely_experiment_id === "optimizely_experiment_id_i_wanna_track"){
var _loq = window._loq || []; // ensure queue available
_loq.push(["tag_recording", window['optimizely'].data.experiments[experimentID].name +"-"+window['optimizely'].data.state.variationIdsMap[experimentID]]); // this will tag, won't star, and will append the tag
@rxnlabs
rxnlabs / php-no-cache-headers.php
Last active April 13, 2017 08:59
Send no cache headers using PHP (Great for staging)
<?php
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
@rxnlabs
rxnlabs / php-wp-add-tinymce-button.php
Last active July 2, 2022 15:28
WordPress - Add button to TinyMCE editor in WordPress. Great for creating menus so users can add shortcodes without having to remember the syntax
<?php
/*Add this code to your functions.php file of current theme OR plugin file if you're making a plugin*/
//add the button to the tinymce editor
add_action('media_buttons_context','add_my_tinymce_media_button');
function add_my_tinymce_media_button($context){
return $context.=__("
<a href=\"#TB_inline?width=480&inlineId=my_shortcode_popup&width=640&height=513\" class=\"button thickbox\" id=\"my_shortcode_popup_button\" title=\"Add My Shortcode\">Add My Shortcode</a>");
}
@rxnlabs
rxnlabs / htaccess-non-www-to-www-subdomains
Created April 14, 2014 12:11
htaccess - redirect non-www to www and stop subdomains from redirecting to folder
#redirect non-www to www and stop subdomains from redirecting to folder
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain.com$
RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L]
@rxnlabs
rxnlabs / php-wp-woocommerce-paypal-redirect.php
Last active August 29, 2015 14:00
WooCommerce/WordPress: redirect to checkout page after successful PayPal purchase
<?php
#encode the return URL for PayPal so user's are redirected back to site after completing payment
add_filter( 'woocommerce_paypal_args','woocommerce_paypal_args_repair');
function woocommerce_paypal_args_repair( $paypal_args ) {
global $woocommerce;
if (!array_key_exists(‘cbt’,$paypal_args))
$paypal_args['cbt'] = $woocommerce->cart->get_checkout_url();
return $paypal_args;
}