Skip to content

Instantly share code, notes, and snippets.

View chrisguitarguy's full-sized avatar

Christopher Davis chrisguitarguy

View GitHub Profile
@chrisguitarguy
chrisguitarguy / api.php
Created September 6, 2011 21:09
Use dlvr.it shortlinks in WordPress
<?php
// http://pmg.co
class wpDlvrit
{
protected $key;
function __construct( $key = false )
{
$this->set_key( $key );
}
@chrisguitarguy
chrisguitarguy / rss-footer.php
Created September 13, 2011 22:32
Quickly add a footer to your WordPress feed
@chrisguitarguy
chrisguitarguy / get-links.py
Created September 14, 2011 17:04
Get specific links from a page using python and BeautifulSoup
@chrisguitarguy
chrisguitarguy / comments-example.php
Created September 21, 2011 21:44
How to add custom fields to WordPress comments
<?php
/*
Plugin Name: Add Extra Comment Fields
Plugin URI: http://pmg.co/category/wordpress
Description: An example of how to add, save and edit extra comment fields in WordPress
Version: n/a
Author: Christopher Davis
Author URI: http://pmg.co/people/chris
License: MIT
*/
@chrisguitarguy
chrisguitarguy / jquery-tabs.html
Created September 23, 2011 15:17
Generic jQuery tab navigation
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('ul.tab-nav li').click(function(e){
var tab_id = jQuery(this).attr('id');
jQuery('ul.tab-nav li').removeClass('active');
$(this).addClass('active');
jQuery('.tab-container div.tab').hide();
jQuery('.tab-container div#' + tab_id + '-tab').show();
});
@chrisguitarguy
chrisguitarguy / email-reminder.php
Created September 28, 2011 02:08
Sends an email reminder if you haven't posted on your WordPress blog in a week
<?php
/*
Plugin Name: Reminder Emails
Plugin URI: http://www.christopherguitar.net/
Description: Sends a reminder email if you haven't posted in seven days.
Version: n/a
Author: Christopher Davis
Author URI: http://www.christopherguitar.net
License: GPL2, Creative Commons
*/
@chrisguitarguy
chrisguitarguy / menu-padding.js
Created October 10, 2011 01:51
Dynamically adjust menu padding with jQuery
jQuery(document).ready(function(){
var leftover = jQuery('#top-nav').width() - jQuery('#top-nav ul.menu').width();
var item_width = leftover / (jQuery('#top-nav ul.menu > li').size() - 1);
jQuery('#top-nav ul.menu > li').css('padding-right', item_width);
jQuery('#top-nav ul.menu > li:last-child').css('padding-right', '0');
});
@chrisguitarguy
chrisguitarguy / cpt-permalinks.php
Created October 10, 2011 17:28
How to add fields to the WordPress permalinks page
@chrisguitarguy
chrisguitarguy / widget-tut.php
Created October 11, 2011 22:18
An example of how to build your own WordPress widget
<?php
/*
Plugin Name: PMG Widget Tututorial
Plugin URI: http://pmg.co/category/wordpress
Description: How to create WordPress Widgets.
Version: 1.0
Author: Christopher Davis
Author URI: http://pmg.co/people/chris
License: GPL2
*/
@chrisguitarguy
chrisguitarguy / get-products.py
Created October 17, 2011 16:01
Trying out the requests library for Python
import requests
from BeautifulSoup import BeautifulSoup as Soup
def get_products(url):
r = requests.get(url)
if 200 != r.status_code:
return False
s = Soup(r.content)
products = s.findAll('li', {'class': 'item'})
out = []