Skip to content

Instantly share code, notes, and snippets.

@wilhelser
wilhelser / gist:9426046
Created March 8, 2014 05:59
Easy Authorization
before_filter :validate_user
def validate_user
redirect_to home_path unless current_user and current_user.id == params[:id]
end
jQuery(document).ready(function($) {
items = $('#menu-main-menu-1 li');
$.each(items, function() {
parent = $(this);
target = $(parent).find('.sub-menu-item-image');
image = $(parent).find('img');
src = $(image).prop('src');
$(target).html("<img class='menu-image' src='" + src + "' alt='menu image'>");
$(image).hide();
});
@wilhelser
wilhelser / gist:15203afae6c314a4f134
Created July 19, 2014 21:55
Smooth Scrolling to Anchor
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
@wilhelser
wilhelser / gist:86af55fc339e066d247b
Last active August 29, 2015 14:04
Foundation Accordion
<div class="medium-3 columns">
<h4 id="accordion">Accordion</h4>
<dl class="accordion" data-accordion>
<dd>
<a href="#panel1">Section 1</a>
<div id="panel1" class="content active">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sunt placeat recusandae, quos quis dicta quod.</p>
</div>
</dd>
<dd>
.online-course-icon {
display: block;
float: right;
height: 20px;
width: 20px;
background: url("/wp-content/themes/InfiniteFoundation/assets/img/online.png") no-repeat;
}
@wilhelser
wilhelser / gist:067e50efff9a725201b5
Created August 27, 2014 16:49
Identity IQ Code
- if @template.blank?
%section.content.interior
.row
.medium-10.columns.medium-offset-1
- @benefits.each do |benefit|
.benefits-heading.medium-12
.inner
.outer
.inner.benefit-inner
= benefit.title
@wilhelser
wilhelser / gist:62cbcf451ca0a6ee2561
Created February 26, 2015 20:30
Dakotas Gallery
<?php
/* Template Name: Gallery */
get_header(); ?>
<main role="main">
<section class="hero gallery-hero">
<div class="menus-headline">
<h1>Gallery</h1>
</div>
@wilhelser
wilhelser / ie.css
Created October 2, 2015 21:58
IE Specific Media Queries
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
}
@wilhelser
wilhelser / gist:2650319
Created May 10, 2012 01:34
Mobile site re-direction
<?php
/**
* Check to see if the visitor is coming from the mobile site link
*
*/
$token = isset($_GET['token']) ? $_GET['token'] : null;
/**
* If they are coming from the mobile site, set a cookie that expires in 1 hour