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 / 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
stresspop
----------------------------------------------------------------------------
the markup :
----------------------------------------------------------------------------
<style>
#stresspop { display:none; width:572px; height:286px;
background:#fff;
position:fixed;
top:154px;
@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') {
@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 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 / 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 / gist:1719681
Created February 1, 2012 21:48
quick WordPress custom URL variables
<?php // quick WordPress custom URL variables for /en/page-name & /fr/page-name
function flush_rewrite() {
flush_rewrite_rules( false );
}
add_action( 'init', 'flush_rewrite' );
function my_insert_query_vars( $vars ) {
array_push( $vars, 'lang' );
return $vars;
@stresslimit
stresslimit / gist:2931849
Created June 14, 2012 18:03
WordPress: get_posts() grouped by category
<?php
/*
* This class returns you an object that you can foreach() loop through, passing regular
* get_posts() args, and the results will be grouped by category or custom taxonomy.
* It's designed right now to work with posts in only one category [taxonomy term].
*
* Usage:
$args = array(
'taxonomy' => 'my_taxonomy',
@stresslimit
stresslimit / gist:2938770
Created June 15, 2012 21:22
Almost working: recursively pre-populate taxonomy terms
add_action( 'init', 'sld_prepopulate' );
function sld_prepopulate() {
$terms = array(
'term1',
'term2',
'Faculty' => array(
'booze',
'jeans',
),
@stresslimit
stresslimit / .bash_profile
Created July 15, 2012 15:29
useful shortcuts and settings for .bash_profile
# directory listing shortcut
alias ll='ls -la'
# hardening wordpress file permissions shortcuts
alias setpermd='find . -type d -exec chmod 755 {} \;'
alias setpermf='find . -type f -exec chmod 644 {} \;'
# set vi as svn propeditor
export SVN_EDITOR=vi