Skip to content

Instantly share code, notes, and snippets.

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables

@ryanriatno
ryanriatno / functions.php
Created August 27, 2012 15:43 — forked from billerickson/functions.php
Add Custom Image Sizes to Media Uploader
<?php
/**
* Add Custom Image Sizes to Media Uploader
* @author Pippin Williamson
* @link http://pippinsplugins.com/add-custom-image-sizes-to-media-uploader/
*
* @param array $sizes
* @return array
*/
@ryanriatno
ryanriatno / wp-image-crop-position.php
Created September 8, 2012 09:54 — forked from bradt/wp-image-crop-position.php
WordPress: Set an image's crop position and rotates images based on EXIF information if necessary
<?php
/* Example Usage:
* bt_add_image_size( 'product-screenshot', 300, 300, array( 'left', 'top' ) );
* bt_add_image_size( 'product-feature', 460, 345, array( 'center', 'top' ) );
*/
add_filter( 'intermediate_image_sizes_advanced', 'bt_intermediate_image_sizes_advanced' );
add_filter( 'wp_generate_attachment_metadata', 'bt_generate_attachment_metadata', 10, 2 );
/**
@ryanriatno
ryanriatno / gist:3846045
Created October 6, 2012 20:41
HTML: Starting Template
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script src="ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
</body>
</html>
@ryanriatno
ryanriatno / gist:3846104
Created October 6, 2012 20:59 — forked from padolsey/gist:527683
Detect IE
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@ryanriatno
ryanriatno / wp-query-ref.php
Created October 6, 2012 21:09 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@ryanriatno
ryanriatno / gist:4404803
Created December 29, 2012 05:53
Insert Ads inside Post Content
<?php
add_filter('the_content', 'rr_add_ad_inside_post');
function rr_add_ad_inside_post($content) {
if ( is_single() ) {
$paragraphAfter= 3; //display after the first paragraph
$content = explode("", $content);
for ($i = 0; $i <count ($content); $i++ ) {
if ($i == $paragraphAfter) { ?>
<p class="alignleft">
<script type="text/javascript"><!--
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
@media only screen
and (min-width : 321px) {

Template Components

Used to provide structural templates.

Pattern

t-template-name
t-template-name--modifier-name
t-template-name__subcomponent-name--subcomponent-modifier-name
@ryanriatno
ryanriatno / gist:a559d4eb8986c126227b
Created December 20, 2014 21:17
Fire $(window).resize() function after the browser window resize is completed
// http://stackoverflow.com/a/4541963
var waitForFinalEvent = (function () {
var timers = {};
return function (callback, ms, uniqueId) {
if (!uniqueId) {
uniqueId = "Don't call this twice without a uniqueId";
}
if (timers[uniqueId]) {
clearTimeout (timers[uniqueId]);