Skip to content

Instantly share code, notes, and snippets.

View smonteverdi's full-sized avatar

Sean Monteverdi smonteverdi

View GitHub Profile
@smonteverdi
smonteverdi / gist:3440448
Created August 23, 2012 19:08
jQuery: Get URL Variable
$.urlParam = function(name){
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
return results[1] || 0;
}
// example.com?param1=name&param2=&id=6
$.urlParam('param1'); // name
$.urlParam('id'); // 6
$.urlParam('param2'); // null
@smonteverdi
smonteverdi / gist:3428075
Created August 22, 2012 18:14
CSS: Prevent Text Breakouts
.prevent-text-breakouts {
-ms-word-break: break-all;
word-break: break-all;
word-break: break-word;
-webkit-hyphens: auto;
-moz-hyphens: auto;
hyphens: auto;
}
@smonteverdi
smonteverdi / gist:3380075
Created August 17, 2012 15:51
jQquery: Clear input on focus, restore on blur
var default_value = "Select by city,state or zip";
$('#searchform #s').val(default_value);
$('#searchform #s').focus(function(){
if(this.value == default_value) {
this.value = '';
}
});
@smonteverdi
smonteverdi / gist:3172755
Created July 24, 2012 21:25
WordPress: Embed YouTube vid with custom field
Make a custom field in post first.... ex. video_url
// Get the video URL and put it in the $video variable
$video = get_post_meta($post->ID, 'video_url', true);
// Echo the embed code via oEmbed
echo wp_oembed_get( $video, array( 'width' => 218, 'height' => 127 ));
@smonteverdi
smonteverdi / gist:3138144
Created July 18, 2012 19:09
CSS: Image Replacement
.hide-text {
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
}
@smonteverdi
smonteverdi / gist:3123964
Created July 16, 2012 17:43
WordPress: Custom login logo
// Change Login Logo
add_action("login_head", "my_login_head");
function my_login_head() {
echo "
<style>
body.login #login h1 a {
background: url('".get_bloginfo('template_url')."/assets/images/admin-logo.png') no-repeat scroll center top transparent;
height: 128px;
width: 325px;
}
@smonteverdi
smonteverdi / gist:2989563
Created June 25, 2012 16:23
Rails: Partial: Display Form Errors
<% if object.errors.any? %>
<div id="error_explanation">
<h2>Oops, looks like <%= pluralize(object.errors.count, "error") %>
occured:</h2>
<br />
<ul>
<% object.errors.each do |key, msg| %>
<li><%=key%> <%= msg %></li>
<% end %>
</ul>
@smonteverdi
smonteverdi / gist:2980703
Created June 24, 2012 00:24
Rails: Helper: Status Tag
def status_tag(boolean, options={})
options[:true] ||= ''
options[:true_class] ||= 'status true'
options[:false] ||= ''
options[:false_class] ||= 'status false'
if boolean
content_tag(:span, options[:true], :class => options[:true_class])
else
content_tag(:span, options[:false], :class => options[:false_class])
@smonteverdi
smonteverdi / gist:2822016
Created May 29, 2012 01:14
jQuery: Display favicon next to external link
$("a[href^='http']").each(function() {
$(this).css({
background: "url(http://www.google.com/s2/u/0/favicons?domain=" + this.hostname +
") left center no-repeat",
"padding-left": "20px"
});
});
@smonteverdi
smonteverdi / gist:2731668
Created May 19, 2012 17:44
WordPress: Custom WordPress Footer
// Custom WordPress Footer
function remove_footer_admin () {
echo '&copy; 2012 - WordPress Channel, Aur&eacute;lien Denis';
}
add_filter('admin_footer_text', 'remove_footer_admin');