Skip to content

Instantly share code, notes, and snippets.

View stresslimit's full-sized avatar

Colin stresslimit

  • sorry most activity is private...
View GitHub Profile
@stresslimit
stresslimit / gist:943745
Created April 27, 2011 05:09
WP order posts by number of facebook likes
<?php
// get fb likes from fb graph api
// put this block in single.php, or somewhere you have $post and have setup postdata [inside a Loop]
$obj = json_decode( file_get_contents( 'http://graph.facebook.com/?id='.get_permalink() ) );
$likes = $obj->shares;
update_post_meta($post->ID, '_fb_likes', $likes, false);
// make a Loop [in a template page or whatever] to query and display posts ordered by fb like popularity
$args = array(
@stresslimit
stresslimit / jquery offsite links in new windows
Created February 21, 2011 15:52
jquery offsite links in new windows to not leave the current site
@stresslimit
stresslimit / jquery input.alt toggler
Created February 19, 2011 23:48
jquery input.alt toggler [mostly replaced by input placeholder=""]
// will take the alt tags from all input fields and make it the default text
// default text will disappear on focus and reappear on blur if field is blank
$('input').each(function(){
$(this).click(function(){ if(this.type=='submit') this.blur(); });
if(this.alt) {
this.value = this.alt;
this.onfocus=function(){if(this.value==this.alt){this.value='';} }
this.onblur=function(){if(this.value==''){this.value=this.alt;} }
}
});
@stresslimit
stresslimit / jquery bg image resizer
Created February 19, 2011 23:45
jquery bg image resizer
<script>
$(document).ready(resizebg);
$(window).resize(resizebg);
function resizebg() {
var w,h,x,y;
var ratio = 4/3;
x = $(window).width();
y = $(window).height();
var constrain = x/y > ratio ? 'w' : 'h';
if(constrain=='w') {
stresspop
----------------------------------------------------------------------------
the markup :
----------------------------------------------------------------------------
<style>
#stresspop { display:none; width:572px; height:286px;
background:#fff;
position:fixed;
top:154px;
@stresslimit
stresslimit / wp .htaccess
Created July 29, 2010 19:56
Standard Stresslimit WordPress .htaccess file
#######################
# php settings
# do not display php errors which can give system and path info
php_value display_errors 0
# uncomment for development
# php_value error_reporting 2047
# php_value display_errors 1