Skip to content

Instantly share code, notes, and snippets.

Avatar

Clark Wimberly clarklab

View GitHub Profile
@clarklab
clarklab / transient-example.php
Created Jan 30, 2013
Caching a simple API call using the WP Transient API
View transient-example.php
<?php
//let's get some tweets!!
//first, let's see if I've got the data already cached
$tweets = get_transient("tweets");
//dang it! it looks like I might not. let's grab some tweets from the Twitter API
if( !$tweets ) {
@clarklab
clarklab / waypoint-custom.js
Created Jan 10, 2013
simple jquery waypoint up/down toggle
View waypoint-custom.js
$('.section').waypoint(function(event, direction) {
if (direction === 'down') {
} else {
}
});
@clarklab
clarklab / gist:4036164
Created Nov 8, 2012
mklink (creating a symlink in Windows)
View gist:4036164
mklink /d "C:\Users\clark\AppData\Roaming\Sublime Text 2\Packages\User" "C:\Users\clark\Dropbox\Sublime\Packages\User"
@clarklab
clarklab / package control
Created Nov 7, 2012
Sublime Text Package Control installation command
View package control
import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print 'Please restart Sublime Text to finish installation'
View zencoding.html
<!-- the following shorthand -->
html:5>div.container>nav.main>li.item*4>a
<!-- expands into this clean markup-->
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
</head>
@clarklab
clarklab / sftp-config.json
Created Nov 7, 2012
Sample Sublime SFTP config
View sftp-config.json
{
// The tab key will cycle through the settings when first created
// Visit http://wbond.net/sublime_packages/sftp/settings for help
// sftp, ftp or ftps
"type": "sftp",
"save_before_upload": true,
"upload_on_save": false,
"sync_down_on_open": false,
@clarklab
clarklab / enqueue_script_conditional.php
Created Nov 5, 2012
WordPress conditional JS enqueue
View enqueue_script_conditional.php
<?php
if (is_page('Contact')) {
wp_register_script( 'contact-form', 'http://ajax.googleapis.com/contact-form.js');
wp_enqueue_script( 'contact-form' );
}
?>
@clarklab
clarklab / set_page_template.php
Created Nov 5, 2012
set a page template programmatically in WordPress
View set_page_template.php
update_post_meta( $post_id, '_wp_page_template', 'page-contact.php' );
@clarklab
clarklab / wp_query_php_enclosure.sublime-snippet
Created Oct 29, 2012
WP_Query snippet (with php enclosures) for Sublime Text 2
View wp_query_php_enclosure.sublime-snippet
<snippet>
<content><![CDATA[
<?php \$${1:query} = new WP_Query('${3:posts_per_page=5}'); ?>
<?php while (\$${1:query}->have_posts()) : \$${1:query}->the_post(); ?>
${3:// do something}
<?php endwhile; ?>
]]></content>
<tabTrigger>wpq</tabTrigger>
<description>WP_Query with php enclosures</description>
</snippet>
@clarklab
clarklab / wp_query.sublime-snippet
Created Oct 29, 2012
WP_Query snippet for Sublime Text 2
View wp_query.sublime-snippet
<snippet>
<content><![CDATA[
\$${1:query} = new WP_Query('${2:posts_per_page=5}');
while (\$${1:query}->have_posts()) : \$${1:query}->the_post();
${3:// do something}
endwhile;
]]></content>
<tabTrigger>wpq</tabTrigger>
<scope>source.php</scope>
<description>WP_Query basic loop</description>
You can’t perform that action at this time.