Skip to content

Instantly share code, notes, and snippets.

@tannerhodges
tannerhodges / get-property-names.php
Last active December 30, 2015 03:39
Get the property names of an object. Helpful when parsing JSON data or large arrays with an unknown structure.
/**
* Get property names of an object
* @return array Property names, else error message.
*/
function getPropertyNames($object = null)
{
if (!$object) {
return array('getPropertyNames() was passed an empty object.');
}
@tannerhodges
tannerhodges / li3-RedirectsController.php
Last active January 3, 2016 14:19
Redirect URLs within the Lithium framework via simple routes.
<?php
namespace app\controllers;
/**
* Redirects Controller | This controller is designed to work in conjunction
* with `routes.php` by routing the desired URL to a new one. E.g.,
* redirecting '/keepinitreal' to the static directory '/mycard/loyalty-card'.
*
* ```php
@tannerhodges
tannerhodges / slideshow-tracking.js
Created May 1, 2014 14:29
GA Tracking for jQuery Slideshow
$(document).ready(function() {
// Default tracking settings
var slider_event = 'slide';
var slider_source = 'navigation';
// Create slideshow instances
var $s = $('.slideshow').slides({
onupdate: function(slide_index) {
// Track based on slider_event
if (slider_source !== 'link') {
@tannerhodges
tannerhodges / round-up-to-quarter.php
Last active August 29, 2015 14:04
Rounds value up to next quarter integer
<?php
/**
* Rounds value up to next quarter integer
* @param mixed $n
* @return float
*/
function roundUpToQuarter($n)
{
if ( ! is_numeric($n)) { return $n; }
@tannerhodges
tannerhodges / htaccess
Created January 5, 2015 17:23
Password protect a directory using basic authentication
# Password protect a directory using basic authentication
# https://wiki.apache.org/httpd/PasswordBasicAuth
AuthType Basic
AuthName "Restricted Files"
AuthUserFile /var/www/vhosts/.htpasswd
Require valid-user
# To update the user's password, use the following:
# htpasswd /var/www/vhosts/.htpasswd username
@tannerhodges
tannerhodges / getting-up-and-running-with-ruby-on-rails
Created June 12, 2015 00:01
Getting up and running with Ruby on Rails
# Getting up and running with Ruby on Rails
TODO: Polish and send to Cayla
## Let’s get introduced to the Terminal!
- Open Spotlight and type in `terminal`
- You should see the application come up — open it
- Tada! You’ve opened the app and can start running fancy computer commands now
@tannerhodges
tannerhodges / _a11y-hover.scss
Created June 15, 2015 18:29
Accessible Hover Mixin
/**
* Accessible hover styles. Applies :hover styles to :focus and :active.
* http://24ways.org/2007/css-for-accessibility
*/
@mixin hover {
&:focus, &:hover, &:active {
@content;
}
}
/**********************************************************
ADOBE SYSTEMS INCORPORATED
Copyright 2005-2010 Adobe Systems Incorporated
All Rights Reserved
NOTICE: Adobe permits you to use, modify, and
distribute this file in accordance with the terms
of the Adobe license agreement accompanying it.
If you have received this file from a source
@tannerhodges
tannerhodges / index.html
Last active August 29, 2015 14:26 — forked from anonymous/index.html
CSS Diagonal Strikethrough // source http://jsbin.com/oqibus/1
<!-- Found at http://stackoverflow.com/a/14593540/1786459 -->
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
<style id="jsbin-css">
.strikethrough {
position: relative;
}
@tannerhodges
tannerhodges / responsive-font-size.css
Created October 6, 2015 19:38 — forked from AllThingsSmitty/responsive-font-size.css
Font size based on viewport size
/* base font size + viewport height + viewport width */
h1 {
font-size: calc(2rem + 4vh + 4vw);
}
/* responsive font-size responsive */
html {
font-size: calc(100% + .2vh + .2vw);
}