Skip to content

Instantly share code, notes, and snippets.

View adamculpepper's full-sized avatar

Adam Culpepper adamculpepper

View GitHub Profile
@adamculpepper
adamculpepper / strip-trailing-slash.js
Created October 28, 2015 19:50
JavaScript: Strip Trailing Slash
function stripTrailingSlash(str) {
if(str.substr(-1) === '/') {
return str.substr(0, str.length - 1);
}
return str;
}
@adamculpepper
adamculpepper / detectFrame.js
Created September 15, 2015 13:52
JavaScript/jQuery: Detect if content is inside iframe
function detectFrame() {
if (window.frameElement) {
// in frame
alert('framed: YES');
$('body').addClass('framed');
} else {
// not in frame
alert('framed: NO');
$('body').removeClass('framed');
}
@adamculpepper
adamculpepper / ontime-nyan-cat-loader.css
Created June 22, 2015 14:43
Replaces the super tiny loader image with Nyan Cat!
/* OnTime Loader */
.yui3-cardgrid-loading {background:rgba(255, 0, 255, 0.5) url('data:image/gif;base64,R0lGODlhKQF4AMMJAAICAgKa/v6aAv7+Av4CApqamv7OmjL+AmYy/v4C/v6a+f7+/v4ymgAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQJBgANACwAAAAAKQF4AAAE/7DJSau9OOvNu/9g2ABkaZ5oqq5s676pKM90bd94PsJ87/8+nXBILBprwKRy2Ts6n9DojUmtWqXYrFZr7XqD27B4PP2azzHyh8Buu9/wuHxOINPv+PjJwO/7/4CBgoOEhYaHgSdqGnmNjm52j5Jwe4iWl5iZmIqLGJOfc5Ggk5WapqeoiJydFqOubaKvjaWptbapq6wUsq6xvHe0t8LDh7lQv8jJysttKJgK0NHS09TV1tfY2dabxkPM3+Dhec6X2ubn6OnS3CZO4u/w4uSW6vX29+wl7vH8/bzziO4JHJgtH4l9/hIqdATwEMGHEKEZBIBwocWLbxoaishR4MSKGP9DLtT4pyM1BihTakuJ0mQhFCBFyuRH0o/JaSxbZsvpkhDMIzOD9qvZ56a0nAxWsuw56KcRoVDfEeVjNBpSpSo7vuwmJKrXb1MNVIV2dedSrT656vjKNlnYsQrKYuOJtqnaHJIE6N3Lt6/fv4ADC7gouLBhAQ2xZoXL+Nofp0XyHp5MeS/hypgTmz3buPO0x3dxSMZMOvDl0oc1z6XrubUC0O2APkJNu+/p2oFVX5PrujNsfbId4cZ9e7hf3dZ492b8++AR49CjS58OGHk15cvHNqf4nLr37+ArW89+rcXmxY79QJbQIkT49/DjIw5G/pz51ZzT91m/Y4V7+QAGaNz/ePVRc99urOnHB3/tgSDggxBmRl+B2RyYXILbqNdNgx9E6OGH1U1IYXksnKcTNttZwKEHILbYIoHkoVDAjDTWWAAKBG0no4028leBi0B
@adamculpepper
adamculpepper / sticky-element.js
Created January 14, 2015 16:22
Sticky Elements (jQuery required)
// demo: http://jsfiddle.net/adamculpepper/mvcjbwbv
$(window).scroll(makeSticky).trigger("scroll");
$(window).load(function () {
$(".sticky-element").each(function () {
var el = $(this);
if (!el.attr("data-offset-top")) {
el.attr("data-offset-top", el.offset().top);
el.attr("data-offset-left", el.offset().left);
@adamculpepper
adamculpepper / center-vertically.js
Last active August 29, 2015 14:13
Vertically Centering Elements with offset (jQuery)
/*
usage:
call function: centerThings();
add class: "center-vert"
add offset (optional): data-center-offset="-3"
example: <div class="center-vert" data-center-offset="-3">text</div>
demo: http://jsfiddle.net/adamculpepper/kns0osky
*/
function centerThings() {
//Calculate percentage of two numbers
$user1 = 100;
$user2 = 50;
echo ($user2 / $user1) * 100; //output: 50
@adamculpepper
adamculpepper / css_resources.md
Last active August 29, 2015 14:12 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

@adamculpepper
adamculpepper / javascript_resources.md
Last active August 29, 2015 14:12 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@adamculpepper
adamculpepper / 0_reuse_code.js
Last active August 29, 2015 14:12
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@adamculpepper
adamculpepper / script-processing-time.php
Created November 10, 2014 14:52
Calculate the page/script processing time
<?
$start = (float) array_sum(explode(' ',microtime()));
?>
<!-- CONTENT HERE -->
<?
$end = (float) array_sum(explode(' ',microtime()));
echo "Processing time: ". sprintf("%.4f", ($end-$start))." seconds";
?>