Skip to content

Instantly share code, notes, and snippets.

View tonylegrone's full-sized avatar

Tony Legrone tonylegrone

  • Chronicle
  • Birmingham Alabama
View GitHub Profile
@tonylegrone
tonylegrone / gist:501306
Created July 30, 2010 20:56
jQuery - dynamically wrap words in specific tags
/*
Wrap specified words in the specified tag with jQuery
h1, h2, and h3 are preselected because of the project this was made for.
Separate the words you wish to wrap by the "pipe" symbol.
You should note that this cascades down through all child elements. So you can be as broad or narrow as you want with the selector.
*/
$(document).ready(function(){
var pattern = /\b(of|the|in|and)/gi; // target whole words globally and case insensitive
var replaceWith = '<span>$1</span>'; // wrap in the tag you want
@tonylegrone
tonylegrone / between.php
Last active September 23, 2015 21:47
Detects if an integer is between the provided range.
<?php
/**
* Detects if an integer is between the provided range.
*
* @param int $int
* The integer to test against.
* @param int $min
* The minimum number $int can be.
* @param int $max
* The maximum number $int can be.
@tonylegrone
tonylegrone / gist:639090
Created October 21, 2010 19:05
WP Feedburner Widget
// Place in your themes functions.php
// feedburner subscription form
add_action( 'widgets_init', 'custom_load_widgets' );
function custom_load_widgets() {
register_widget( 'FB_subscribe' );
}
class FB_subscribe extends WP_Widget {
@tonylegrone
tonylegrone / list-to-array.php
Created June 30, 2011 16:11
Prints a formatted array from a per line list
<?php
/**
* prints a formatted array from a per line list
*
* Each value is converted to it's own key with
* spaces replaced with underscores and strtolower().
* Values are converted to uppercase first letters with ucwords().
*/
function list_to_array($string) {
$string = explode("\n",$string);
@tonylegrone
tonylegrone / gist:3372602
Created August 16, 2012 18:50
Limits an integer within the provided range.
<?php
/**
* Limits an integer within the provided range.
*
* @param int $int
* The integer to test against.
* @param int $min_limit
* The minimum number $int allowed to return.
* @param int $max_limit
* The maximum number $int allowed to return.
@tonylegrone
tonylegrone / gist:3374056
Created August 16, 2012 22:10
Scales and integer to defined steps.
<?php
/**
* Scales and integer to defined steps.
*
* @param int $int
* The integer to test against.
* @param int $min
* The minimum number of the range.
* @param int $max
* The maximum number of the range.
@tonylegrone
tonylegrone / gist:4270524
Created December 12, 2012 18:56
Provides a new method to the Date object with properties similar to PHP. Not all PHP date options were ported for the sake of not duplicating too many methods already available.
// Pad a number with zeros to specified length.
Number.prototype.pad = function(length)
{
var str = '' + this.valueOf();
while (str.length < length) {
str = '0' + str;
}
return str;
}
<?php
/**
* Injects a string into an existing string in the designated position.
* HTML should not be effected, but who knows.
*
* @param string $inject
* The new string to be injected.
* @param string $string
* The original string to be alter.
set -g status-position top
set -g status-left-length 32
set -g status-right-length 150
set -g status-fg blue
set -g status-bg black
set -g window-status-activity-attr bold
set -g pane-border-fg brightgreen
set -g pane-active-border-fg brightgreen
set -g message-fg yellow
set list listchars=tab:\ \ ,trail:·
set timeoutlen=0
let g:UltiSnipsSnippetsDir="~/.vim/bundles/UltiSnips/UltiSnips/"
let g:airline_theme='badwolf'
let g:airline_powerline_fonts=1
let g:airline_section_c = '%<%t%m'
let g:bufferline_echo = 0
" make sure vimgutter looks good