Skip to content

Instantly share code, notes, and snippets.

View travismillerweb's full-sized avatar

Travis Miller travismillerweb

View GitHub Profile
@travismillerweb
travismillerweb / pop-out-format.php
Created November 6, 2012 21:52
PHP - Pop Out and Format First Word
<?php
$myvalue = [string]
$arr = explode(' ',trim($myvalue));
$arr = array_reverse($arr);
$callout = array_pop($arr);
$arr = array_reverse($arr);
echo '<span style="[style]">' . $callout . "</span> " . implode(" ", $arr);
?>
@travismillerweb
travismillerweb / validation.js
Created December 3, 2012 04:47
JS - Basic Form Validation (Mailchimp Styling)
$(document).ready(function(){
if($('#mc-embedded-subscribe-form')) {
$('#mc-embedded-subscribe-form').bind("submit", function(e){
// Form Errors Stack, push a required field to this array
var errors = [];
// Error Validations (Basic)
// -- First Name --
if($('input[name="FNAME"]').val() == '') {
@travismillerweb
travismillerweb / confirm_continue
Created December 19, 2012 20:19
GIT Common and Useful Commands
read -p "Continue? ( y ): " cont
if [ "$cont" != "y" ] ; then
exit 1;
fi
@travismillerweb
travismillerweb / environment-hide.php
Created December 19, 2012 20:42
PHP - Environment Hide Script
<?php
$environments = array("env1", "env2", "env3");
if (!in_array($_SERVER['HTTP_HOST'], $environments)) { ?>
<!-- Something To Hide -->
<?php } ?>
@travismillerweb
travismillerweb / detect-mobile-device.js
Created January 16, 2013 19:58
JS - Detect Mobile Device Script
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
// some code..
}
//Credits go to "sweets-BlingBling"
//http://stackoverflow.com/questions/3514784/best-way-to-detect-handheld-device-in-jquery
@travismillerweb
travismillerweb / wordpress-environment.php
Created April 24, 2013 15:52
PHP - Wordpress Environment Case Logic
global $offline_mode;
global $prod_mode;
$prod_mode = "local";
//$prod_mode = "staging";
//$prod_mode = "production";
//$prod_mode = "content";
switch ($prod_mode) {
case "production":
define('DB_NAME', '');
@travismillerweb
travismillerweb / dom-menu-placement.js
Created May 13, 2013 19:44
jQuery - Menu Placement
//Menu Placement, ateempting to shift this around before the DOM loads in order to improve SEO of the page
var menuPlacement = {
init: function(){
$(document).ready(function() {
//$('#header_nav').fadeIn('slow');
$('#menu-space-content').hide();
$('#menu-space-content').insertAfter('#menu-space-area');
$('#menu-space-content').show();
@travismillerweb
travismillerweb / view-only.js
Created May 14, 2013 13:25
JS - View Only jQuery
var viewOnly = {
init: function(){
$(document).ready(function() {
var pathname = window.location.pathname;
var menu_options = $('#header ul.header-nav li');
// If you are in the state of "signed in"
@travismillerweb
travismillerweb / detect-mobile-page.js
Created May 14, 2013 14:14
JS - Detect Mobile on Specific Page
$(document).ready(function() {
// If user is on a product page and on a mobile device
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
// Hide widgets tab from this specific page
if(window.location.href.indexOf("/product/") > -1) {
$('.widgets').hide();
}
}
@travismillerweb
travismillerweb / html5-element-create.html
Created May 20, 2013 15:52
HTML/JS - Create HTML5 Elements for Cross Browser
<!--[if lt IE 9]>
<script>
document.createElement('header');
document.createElement('nav');
document.createElement('section');
document.createElement('article');
document.createElement('aside');
document.createElement('footer');
</script>
<![endif]-->