Skip to content

Instantly share code, notes, and snippets.

View tylersticka's full-sized avatar

Tyler Sticka tylersticka

View GitHub Profile
@tylersticka
tylersticka / .profile
Last active August 29, 2015 13:56
Helpful Pattern Lab aliases for your bash profile.
alias plbuild="php core/builder.php -gc" # Pattern Lab: Build/Clean
alias plwatch="php core/builder.php -rw" # Pattern Lab: Watch/Sync
@tylersticka
tylersticka / chrome-webfont-fix.js
Last active August 29, 2015 13:57
Quick and dirty fix for Chrome 32/33 webfont issue.
/**
* Chrome 32/33 webfont issue fix.
* Requires jQuery.
* More info: http://blog.cloudfour.com/chrome-webfont-issues/
*/
(function($, window){
// only proceed if this is Chrome
if (window.navigator.userAgent.indexOf('Chrome') === -1) return;
// only proceed if the version is 32 or greater
@tylersticka
tylersticka / gulpfile.js
Last active August 29, 2015 13:57
Example of bespoke Gulp task that includes Knockout templates
/**
* This project's actual gulpfile contains much more than this,
* but these are the relevant bits.
*/
// Node libraries
var fs = require('fs');
var path = require('path');
// Gulp + plugins
@tylersticka
tylersticka / gulpfile.js
Created July 17, 2014 21:53
Simple Knockout template inclusion with Gulp
// include gulp + template plugin
var gulp = require('gulp');
var template = require('gulp-template');
// include the koTemplates module locally
var koTemplates = require('./koTemplates');
// create the 'templates' task
gulp.task('templates', function () {
// single-page app, so just pipe through index
gulp.src('./src/templates/index.html')
@tylersticka
tylersticka / moment.js
Last active August 29, 2015 14:22
Simple moment helper for Handlebars
/*
* Format a date using Moment.
* Usage: {{moment date format="MMMM YYYY"}}
*/
var Handlebars = require('handlebars'),
_ = require('lodash'),
moment = require('moment');
Handlebars.registerHelper('moment', function (context, block) {
@tylersticka
tylersticka / times.js
Created August 4, 2015 23:42
Simple iteration helper for Handlebars
/**
* Iterate over a block a given number of times.
*
* Usage:
* <ul>
* {{#times 5}}<li>Item {{@index}}</li>{{/times}}
* </ul>
*/
var Handlebars = require('handlebars');
@tylersticka
tylersticka / comment.php
Created January 9, 2012 23:00
Sample WP comment callback function
<?php
function tsticka14_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
// I kind of cheat here by not doing anything for pingbacks
// and trackbacks, which means the amount of stuff that
// displays may differ from the comment count unless
// pingbacks and trackbacks are disabled in the admin.
switch ( $comment->comment_type ) :
case 'pingback' :
/*
* Variation of fitvids.js I wrote to behave the way I want to.
*/
(function($){
$.fitStuff = function (el, options) {
var base = this;
base.$el = $(el);
base.selectors = [
"iframe[src^='http://player.vimeo.com']",
/*
* Plugin for creating new windows in JS
*/
(function($){
$.newWindow = function (el, w, h) {
var base = this;
base.$el = $(el);
base.init = function () {
base.features = 'width=' + w + ',height=' + h + ',left=' + ((screen.width-w)/2) + ',top=' + ((screen.height-h)/2 - 110);
@tylersticka
tylersticka / gist:1773755
Created February 8, 2012 20:57
Terrible share drop-down example
// This... stores the current href. Pretty amazing.
var lastHREF = location.href;
// This is the dirtiest way to build the HTML of the share drop-down ever
function getShareHTML(url,title) {
var niceURL = escape(url);
var niceTitle = escape(title);
return '<li id="global-nav-share-facebook"><iframe src="http://www.facebook.com/plugins/like.php?href=' + niceURL + '&amp;layout=button_count&amp;show_faces=true&amp;width=90&amp;action=like&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px;" allowTransparency="true"></iframe></li>' +
'<li><a href="http://twitter.com/home?status=' + niceTitle + '+' + niceURL + '" target="_blank" id="global-nav-share-twitter">Twitter</a></li>' +
'<li><a href="mailto:?subject=' + niceTitle + '&amp;body=' + niceURL + '" id="global-nav-share-email">E-mail</a></li>' +