Skip to content

Instantly share code, notes, and snippets.

@austinpray
austinpray / zepto.smoothScroll.js
Last active October 22, 2021 20:27
Zepto.js smooth vertical scrolling method. Implementing this code turns all anchor links with the class "scrollTo" into smooth scrolling anchor links. Rework of the foundation.js library method.
function smoothScroll(el, to, duration) {
if (duration < 0) {
return;
}
var difference = to - $(window).scrollTop();
var perTick = difference / duration * 10;
this.scrollToTimerCache = setTimeout(function() {
if (!isNaN(parseInt(perTick, 10))) {
window.scrollTo(0, $(window).scrollTop() + perTick);
smoothScroll(el, to, duration - 10);
@austinpray
austinpray / flatShadow.scss
Created July 29, 2013 05:02
commonly used flat design shadow
box-shadow:10px 10px 0px rgba(0,0,0,.1);
@austinpray
austinpray / wordpress get page children.php
Created September 16, 2013 22:49
Wordpress get children of current page and list them by menu order. EG to get locations of a locations page. Put me in a page template
<?php
$id = the_ID();
while ( have_posts() ) : the_post();
$gp_args = array(
'post_type' => 'page',
'post_parent' => $id,
'order' => 'ASC',
'orderby' => 'menu_order',
'posts_per_page' => -1
);
@austinpray
austinpray / jquery.redrawKnob.js
Last active December 24, 2015 05:49
Extension for https://github.com/aterrien/jQuery-Knob adds a crude redraw method to the jQuery Knob plugin. Call $(elem).redrawKnob(); where elem is a container for your <input class="[settings.inputClass]"> Disclaimer, this method was written while under deadline. Improvements and suggestions welcome. Hopefully this is a temporary fix.
/*
* redrawKnob()
* teeny tiny jquery plugin: adds a redraw method to knob
* REQUIRES: jquery.knob
* @austinpray 2013-09-29
*/
(function( $ ) {
$.fn.redrawKnob = function( options ) {
// defaults
var settings = $.extend({
@austinpray
austinpray / nav.html
Created September 29, 2013 16:36
Responsive slide-out nav. Ripped out of my most recent project.
<div class="mast__wrapper">
<ul id="nav-to-reveal" class="nav--site">
<li class="nav-item"><a href="#">learn</a></li>
<li class="nav-item"><a href="#">about</a></li>
<li class="nav-item"><a href="#">contact</a></li>
<li class="nav-item"><a href="#">faq</a></li>
</ul>
<a class="nav-reveal" id="nav-reveal-button" href="#">
<span class="icon-list"></span><span class="nav-reveal__label">MENU</span>
</a>
@austinpray
austinpray / matt.js
Created October 2, 2013 19:49
posts matt matt matt over and over at an increasing rate.
var time = 0;
var diff = 1000;
var minTime = 0;
var maxTime = 100000;
function easeOutQuad(t, b, c, d) {return -c * (t/=d)*(t-2) + b;}
for( var i = 0, len = diff; i <= len; i++ ) {
(function(s){
setTimeout(function(){
@austinpray
austinpray / set-text-color.scss
Created October 15, 2013 15:00
Dynamically change text color based on its background with Sass via http://codepen.io/sebastianekstrom/pen/uHAtL
@function set-text-color($color) {
@if (lightness( $color ) > 40) {
@return black;
}
@else {
@return white;
}
}
@austinpray
austinpray / hidpi.scss
Created October 22, 2013 05:33
Cannibalized bourbon.io hiDPI media query
// HiDPI mixin. Default value set to 1.3 to target Google Nexus 7 (http://bjango.com/articles/min-device-pixel-ratio/)
@mixin hidpi($ratio: 1.3) {
@media only screen and (-webkit-min-device-pixel-ratio: $ratio),
only screen and (min--moz-device-pixel-ratio: $ratio),
only screen and (-o-min-device-pixel-ratio: #{$ratio}/1),
only screen and (min-resolution: #{round($ratio*96)}dpi),
only screen and (min-resolution: #{$ratio}dppx) {
@content;
}
}
@austinpray
austinpray / HOC_drinking_game.md
Last active August 29, 2015 13:56
House Of Cards Drinking Game

House Of Cards Drinking Game

Difficulty modes stack.

Easy Mode

  • Drink anytime Kevin Spacey's character talks about food, literal or metaphorically.
  • Drink twice whenever any other character talks about food metaphorically.
  • Drink every time someone cancels all their appointments.
  • Drink every time Spacey knocks twice on a hard surface.
  • Drink every time South Carolina is mentioned.