Skip to content

Instantly share code, notes, and snippets.

View adamculpepper's full-sized avatar

Adam Culpepper adamculpepper

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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;
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");
}