Skip to content

Instantly share code, notes, and snippets.

<?php
// Set Special Formats in TinyMCE
function ts_beforemce( $settings ) {
$style_formats = array(
array(
'title' => 'Button',
'selector' => 'a',
@ryanburnette
ryanburnette / _sgrid.sass
Last active December 18, 2015 08:09
A really simple Sass grid.
/*
* A Really Simple Sass Grid
* Forked from "Don't Overthink It Grids" by Chris Coyier http://css-tricks.com/dont-overthink-it-grids/
* Supported in IE8+
*/
// Variables
$sgridPadding: 20px
$sgridMinColumns: 3
$sgridMaxColumns: 6
@ryanburnette
ryanburnette / php-parse-http-headers-for-status-code.php
Last active December 19, 2015 18:19
This PHP snippet returns a status code when given HTTP headers in an array where each object is a string of one line.
function parse_http_headers_for_status($headers) {
foreach ( $headers as $line ) {
preg_match('#HTTP/\d+\.\d+ (\d+)#', $line, $matches);
if ( $matches[1] ) {
$status_code = $matches[1];
}
}
return $status_code;
}
@ryanburnette
ryanburnette / jquery-events.js
Last active December 19, 2015 20:08
A better pattern for binding jQuery events to DOM elements. This avoids event mangling.
var $events = $('body')
, submitButton = '.login form .submit'
;
function saveForm(ev) {
var $form = $(this)
, data
;
ev.preventDefault();
@ryanburnette
ryanburnette / prototype.js
Created July 24, 2013 02:32
JavaScript prototype pattern.
(function () {
'use strict';
var proto
, bob
, alice
, bobby
;
function Person(name) {
@ryanburnette
ryanburnette / config.rb
Last active December 20, 2015 07:58 — forked from nathansmith/config.rb
http_path = '/'
css_dir = 'assets/stylesheets'
sass_dir = 'assets/sass'
images_dir = 'assets/images'
javascripts_dir = 'assets/javascripts'
relative_assets = true
preferred_syntax = :sass
@ryanburnette
ryanburnette / readme.md
Last active May 15, 2020 14:36 — forked from joelverhagen/README.md
A Jekyll plugin for creating YouTube or Vimeo embed codes.

This is a Jekyll plugin for creating YouTube or Vimeo embed codes.

Usage

Put the plugin file video-embeds.rb in your _plugins directory. Create a tag specifying the type of video you want to embed with the first required argument, the video id.

{% youtube ab1234ab1 %}
@ryanburnette
ryanburnette / wordpress-widget-template.php
Created November 24, 2013 18:41
A WordPress Widget Example/Template. Based on example from Pippin's Plugins. http://pippinsplugins.com/simple-wordpress-widget-template/
<?php
class example_widget extends WP_Widget {
function example_widget() {
parent::WP_Widget(false, $name = 'Example Text Widget');
}
function widget($args, $instance) {
extract( $args );
$title = apply_filters('widget_title', $instance['title']);
$message = $instance['message'];
@ryanburnette
ryanburnette / get-list.rb
Last active December 29, 2015 14:29
This Ruby script uses Mechanize to script a URL list searching within a particular div to provide a value on how many time a particular string was present.
require 'rubygems'
require 'csv'
require 'mechanize'
require 'uri'
require 'addressable/uri'
file = ARGV[0]
div = ARGV[1]
word = ARGV[2]
@ryanburnette
ryanburnette / jquery.sectionToc.js
Last active December 29, 2015 18:29
Call this jQuery function on an empty div and it will populate a table of contents based on your parameters. Each toc anchor scrolls the window to that heading.
(function($){
$.fn.sectionToc = function(params) {
var defaults
, settings
, headingsSelectors = []
, headingsSelectorsString
, $headings
, $list = $('<ul></ul>')
, $toc = $(this)
;