Skip to content

Instantly share code, notes, and snippets.

View adamculpepper's full-sized avatar

Adam Culpepper adamculpepper

View GitHub Profile
@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

//Calculate percentage of two numbers
$user1 = 100;
$user2 = 50;
echo ($user2 / $user1) * 100; //output: 50
@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() {
@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 / 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 / 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 / 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 / url-slug-slicer.js
Created October 28, 2015 19:54
JavaScript: Strip off slugs from a URL
function cutUrl(str, num) {
var matched = str.match("([^/]*\/){" + num + "}");
return matched ? matched[0] : str; /* or null */
}
//usage
//var url = location.pathname;
var url = "http://domain.com.com/page/subpage/fsdf/dsfg/dgff/gsd/fsdfsg/sddfsdf/gds/fsdf/";
console.log( cutUrl(url, 4) );
print("<pre>" . print_r($array, true) . "</pre>");
//https://stackoverflow.com/questions/4414623/loop-through-an-array-php
//Using foreach loop without key
foreach($array as $item) {
echo $item['filename'];
echo $item['filepath'];
// to know what's in $item
echo '<pre>'; var_dump($item);
@adamculpepper
adamculpepper / wordpress-stuff.php
Last active October 25, 2017 15:04
Random Wordpress snippets
get_category($category_id)->count //items in category
//just posts in category
$query = new WP_Query( array('posts_per_page' => -1, 'category__in' => $category) );
$count = $query->post_count;
echo 'count: ' . $count;
INSIDE LOOP