Skip to content

Instantly share code, notes, and snippets.

@clarklab
clarklab / transient-example.php
Created January 30, 2013 20:00
Caching a simple API call using the WP Transient API
<?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 January 10, 2013 16:26
simple jquery waypoint up/down toggle
$('.section').waypoint(function(event, direction) {
if (direction === 'down') {
} else {
}
});
@clarklab
clarklab / gist:4036164
Created November 8, 2012 02:22
mklink (creating a symlink in Windows)
mklink /d "C:\Users\clark\AppData\Roaming\Sublime Text 2\Packages\User" "C:\Users\clark\Dropbox\Sublime\Packages\User"
@clarklab
clarklab / package control
Created November 7, 2012 20:24
Sublime Text Package Control installation command
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'
@clarklab
clarklab / zencoding.html
Created November 7, 2012 16:46
ZenCoding example
<!-- 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 November 7, 2012 02:04
Sample Sublime SFTP config
{
// 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 November 5, 2012 21:54
WordPress conditional JS enqueue
<?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 November 5, 2012 18:06
set a page template programmatically in WordPress
update_post_meta( $post_id, '_wp_page_template', 'page-contact.php' );
@clarklab
clarklab / wp_query_php_enclosure.sublime-snippet
Created October 29, 2012 20:50
WP_Query snippet (with php enclosures) for Sublime Text 2
<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 October 29, 2012 20:49
WP_Query snippet for Sublime Text 2
<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>