Skip to content

Instantly share code, notes, and snippets.

@fitzhaile
fitzhaile / file_exists.rb
Last active December 14, 2015 01:29
Ruby: Custom file_exists Sass Function
module Sass::Script::Functions
def file_exists(image_file)
path = Dir.getwd + "/" + image_file.value
Sass::Script::Bool.new(File.exists?(path))
end
end
@fitzhaile
fitzhaile / *.php
Last active December 12, 2015 12:48
WP: Typical Testimonials Markup
<?php $testimonials = new WP_Query('post_type=testimonial'.ks_query('testimonials')); ?>
<div class="testimonials">
<?php while( $testimonials->have_posts() ): $testimonials->the_post(); ?>
<blockquote class="testimonial">
<?php the_content(); ?>
<footer>
<p>
<?php the_title(); ?>
</p>
<?php $attachments = new Attachments( 'attachments' ); ?>
<?php if( $attachments->exist() ) : ?>
<h3>Attachments</h3>
<ul>
<?php while( $attachments->get() ) : ?>
<li>
ID: <?php echo $attachments->id(); ?><br />
Type: <?php echo $attachments->type(); ?><br />
Subtype: <?php echo $attachments->subtype(); ?><br />
URL: <?php echo $attachments->url(); ?><br />
<?php
function my_attachments( $attachments )
{
$args = array(
// title of the meta box (string)
'label' => 'My Attachments',
// all post types to utilize (string|array)
@fitzhaile
fitzhaile / is_blog.php
Created October 16, 2012 16:31 — forked from wesbos/is_blog.php
WordPress is_blog()
function is_blog () {
global $post;
$posttype = get_post_type($post );
return ( ((is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_single()) || (is_tag())) && ( $posttype == 'post') ) ? true : false ;
}
Usage:
<?php if (is_blog()) { echo 'You are on a blog page'; } ?>
@fitzhaile
fitzhaile / *.scss
Created October 3, 2012 21:39
SASS: Bordered Box Arrow
@import "compass/css3";
// Add outward pointing arrows (triangles) to the sides of a box that has borders. (CSS triangles obviously
// based on Chris Coyier's CSS triangle. http://css-tricks.com/snippets/css/css-triangle.)
//
// Parameters:
//
// * `direction` -- What side of the box and direction of the arrow
// * `flatten` -- An *even numbered* factor of flattening the triangle (MUST be a even number)
// * `arrowBaseLength` -- Width or height of the arrow's base
@fitzhaile
fitzhaile / css-stats-ack.sh
Created October 2, 2012 17:56 — forked from pjkix/css-stats-ack.sh
shell script to generate some css file statistics
#!/bin/bash
## v1.0.6
## this script will gernerate css stats
### example output
# CSS STATS
# ----------
# Floats: 132
@fitzhaile
fitzhaile / *.scss
Created September 26, 2012 20:52
SASS: Quotes Mixin
// Add quotes to an element.
//
// Parameters:
//
// * [optional] `size` -- Size, in em of the quotes
// * [optional] `padding` -- Top-left padding on lefthand quote
// * [optional] `left` -- Left quote glyph
// * [optional] `right` -- Right quote glyph
@mixin my-quotes($size: 1.3em, $padding:false, $left:'\201C', $right:'\201D') {
&:after, &:before { font-size: $size; }
@fitzhaile
fitzhaile / *.php
Created September 26, 2012 15:27
PHP: Get Twitter Timeline
/**
* Simple Twitter status getter.
* @param string $handle User Twitter handle
* @param integer $count Desired number of tweets
* @return array Indexed array of tweets
*/
function dev_get_twitter_timeline($handle, $count = 3) {
// WP template tag
$save = get_stylesheet_directory() . '/assets/twitter.json';
$time = time();
<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
<script type="text/javascript">FB.init("INSERT-YOUR-API-KEY");</script>
<fb:fan profile_id="INSERT-YOUR-PAGE-ID" connections="10" width="300" height="210" css="http://yoursite.com/path-to-your-stylesheet/style.css?5"></fb:fan>