Skip to content

Instantly share code, notes, and snippets.

View adamculpepper's full-sized avatar

Adam Culpepper adamculpepper

View GitHub Profile
var app.url = (location.href); //Cached for heavy general use
app.isOnPage = function(pageName) {
return app.url.split("?")[0].split("/").pop() == pageName;
}
//Usage
if (app.isOnPage("services")) {
alert("on services page");
}
@adamculpepper
adamculpepper / randomNum.js
Last active October 10, 2018 19:42
Random Number (range)
// random number, inputting botht the min and max number
function randomNum(from, to){
return Math.floor(Math.random() * (to - from + 1) + from);
}
// Usage: randomNum(1, 100)
// random number, inputting only the max number
function randomNum(max) {
return Math.floor(Math.random() * max) + 1;
@adamculpepper
adamculpepper / getBoundingClientRect.js
Last active August 29, 2015 14:04
getBoundingClientRect()
var sel = $("selector");
var coords = sel[0].getBoundingClientRect();
// Usage
console.log(coords.top);
console.log(coords.bottom);
console.log(coords.left);
console.log(coords.right);
@adamculpepper
adamculpepper / bootstrap-grid-breakpoint-labels.html
Last active August 29, 2015 14:04
Bootstrap 3.2 Responsive Utilities > Test Cases (modified from the original)
<!-- Bootstrap 3.2 Responsive Utilities > Test Cases - http://getbootstrap.com/css/#responsive-utilities-tests -->
<!-- This can be added to a project as needed -->
<!-- Add the helper class "hidden" to the main div if you want to temporarily hide it -->
<div class="row responsive-utilities-test visible-on">
<div style="position:fixed; bottom:10px; left:10px; z-index:9999; padding:10px; background:rgba(255, 0, 255, 0.70); font-weight:bold; letter-spacing:1px;">
<span class="visible-xs-block">Extra small (xs) | Phones (<768px)</span>
<span class="visible-sm-block">Small (sm) | Tablets (≥768px)</span>
<span class="visible-md-block">Medium (md) | Desktops (≥992px)</span>
<span class="visible-lg-block">Large (lg) | Desktops (≥1200px)</span>
@adamculpepper
adamculpepper / jquery-bootstrap3-subnav-centering.js
Last active August 29, 2015 14:04
Center Element Based On Another Element
// general usage function call: centerElement(selector, target);
// add in: Parent is absolute
// add in: Parent is relative
$("li.dropdown").click(function(event) {
centerElement( $("ul.dropdown-menu"), $(event.target) );
});
function centerElement(selector, target) {
var selector = target.next(selector);
@adamculpepper
adamculpepper / urlVars.js
Created August 4, 2014 19:53
URL Variables
// usage
// url: http://jsfiddle.net/?test=pirates%20&%20ninjas
// url: http://jsfiddle.net/?test=pirates & ninjas
var vars = [], hash;
var q = document.referrer.split('?')[1];
if(q != undefined){
q = q.replace("%20&%20", "%20%26%20") //Fix for passing ampersands through the URL
q = q.split('&');
for(var i = 0; i < q.length; i++){
@adamculpepper
adamculpepper / ee-categories-entries-output
Created August 19, 2014 23:13
ExpressionEngine - Output Entries in each Category
{exp:channel:categories style="linear"}
<h2>{category_name}:</h2>
{exp:channel:entries channel="agent_forms" category="{category_id}" dynamic="no"}
{title}<br>
{body}
{/exp:channel:entries}
{/exp:channel:categories}
@adamculpepper
adamculpepper / stylish-css.css
Last active August 29, 2015 14:06
Stylish CSS Outlines
/* Formatted for GitHub */
a {outline:1px dotted #D68A85!important;}
h1, h2, h3, h4, h5, h6 {outline:1px dotted #E7912D!important;}
li {outline:1px dotted #CECC33!important;}
span {outline:1px dotted #F0F!important;}
div {outline:1px dotted #3AB6F1!important;}
ul, ol {outline:1px dotted #8684D8!important;}
li {outline:1px dotted #DD67AE!important;}
table td {outline:1px dotted lightblue!important;}
i {outline:1px dotted gray!important;}
// Slightly modified version of Angular's method of checking for Internet Explorer (IE), including checking for IE11
function detectIE() {
// check 6-10
msie = parseInt((/msie (\d+)/.exec((navigator.userAgent).toLowerCase()) || [])[1]);
if (isNaN(msie)) {
// not 6-10, check 11
msie = parseInt((/trident\/.*; rv:(\d+)/.exec((navigator.userAgent).toLowerCase()) || [])[1]);
}
@adamculpepper
adamculpepper / ee-body-classes.html
Last active August 29, 2015 14:07
ExpressionEngine Body Class Clean-up (cleans up all the tabs and break lines so the classes are all on one line)
<!--
Stash: http://devot-ee.com/add-ons/stash
Strip Line Breaks: http://devot-ee.com/add-ons/strip-line-breaks
Low Replace: http://devot-ee.com/add-ons/low-replace
-->
{exp:stash:set parse_tags="yes" parse_conditionals="yes" parse_depth="5" type="snippet"}
{exp:strip_line_breaks}
{stash:body_classes}
{exp:low_replace find="\t" replace="" regex="yes"}