Skip to content

Instantly share code, notes, and snippets.

@tybruffy
tybruffy / elscroll.js
Created July 3, 2014 17:45
Simple jQuery plugin to scroll the browser to the position of a jQuery element
$.fn.elScroll = function(settings) {
var defaults = {
duration: 600,
queue: false,
offset: 0,
}
var options = $.extend(true, {}, defaults, settings);
var callback = options.complete || function() {};
@tybruffy
tybruffy / agnoster.zsh-theme
Last active March 24, 2016 10:40 — forked from agnoster/README.md
My tweaks to the agnoster ZSH theme
# vim:ft=zsh ts=2 sw=2 sts=2
#
# agnoster's Theme - https://gist.github.com/3712874
# A Powerline-inspired theme for ZSH
#
# # README
#
# In order for this theme to render correctly, you will need a
# [Powerline-patched font](https://gist.github.com/1595572).
#
@tybruffy
tybruffy / get_meta_values.php
Created August 16, 2013 20:52
Get all distinct values of a meta field in Wordpress
function _get_all_meta_values($key) {
global $wpdb;
$result = $wpdb->get_col(
$wpdb->prepare( "
SELECT DISTINCT pm.meta_value FROM {$wpdb->postmeta} pm
LEFT JOIN {$wpdb->posts} p ON p.ID = pm.post_id
WHERE pm.meta_key = '%s'
AND p.post_status = 'publish'
ORDER BY pm.meta_value",
$key
@tybruffy
tybruffy / Readme.md
Last active December 17, 2015 11:19
LessCSS loop for adjacent sibling selectors.See Readme.markdown for usage

Less.js Loop for manipulating adjacent siblings. Defaults to add the style to all X number of siblings as specified in the call.

.testcase {
    .adjacents-content() {
    	display: inline;
	}
	.adjacents(4, ".item" );
}
@tybruffy
tybruffy / placeholder.js
Last active December 14, 2015 19:19
IE Placeholder support
if(!$.support.placeholder) {
var active = document.activeElement;
$('[type="text"], [type="email"], textarea').focus(function () {
if ($(this).attr('placeholder') != '' && $(this).val() == $(this).attr('placeholder')) {
$(this).val('').removeClass('hasPlaceholder');
}
}).blur(function () {
if ($(this).attr('placeholder') != '' && ($(this).val() == '' || $(this).val() == $(this).attr('placeholder'))) {
$(this).val($(this).attr('placeholder')).addClass('hasPlaceholder');
}
@tybruffy
tybruffy / slider.html
Last active December 13, 2015 19:18
Code for sliding open hidden content left/right
<div class="slider-container">
<label class="slider-trigger">Join Our Mailing List</label>
<input type="text" class="slider-target" data-width="206px" data-padding="5px" />
</div>