Skip to content

Instantly share code, notes, and snippets.

@blech75
blech75 / gsmls-image-downloader.rb
Created September 10, 2010 13:50
a script to download images associated with a GSMLS ID
#!/usr/bin/env ruby
# gsmls-image-downloader.rb
# -------------------------
# When passed a GSMLS ID, this script will download all of the listing's
# associated images.
require 'open-uri'
def download_image(mls_id)
@mikeschinkel
mikeschinkel / posts-by-taxonomy.php
Created November 6, 2010 01:50
Class to extended WordPress' 3.0.x WP_Query to allow querying for all terms in a taxonomy.
<?php
/*
PostsByTaxonomy class that extends WP_Query and filters to includes all posts that have any term of a taxonomy.
Author: Mike Schinkel (http://mikeschinkel.com)
This example works, just drop into the root of your website and call directly.
Use the class in your plugins or themes.
See:
@mikeschinkel
mikeschinkel / posts-ordered-by-meta.php
Created November 6, 2010 09:05
Class to extended WordPress' 3.0.x WP_Query to allow sorting by a meta_key.
<?php
/*
PostsOrderedByMetaQuery class that extends WP_Query and sorts posts meta_key
Author: Mike Schinkel (http://mikeschinkel.com)
This example works, just drop into the root of your website and call directly.
Use the class in your plugins or themes.
See: http://stackoverflow.com/questions/4111255/how-to-sort-a-query-posts-function-by-custom-field-while-limiting-posts-by-ano
@tomcritchlow
tomcritchlow / 7books.py
Created November 9, 2010 23:23
The main code for 7books (www.7bks.com)
import cgi
import os
from google.appengine.ext.webapp import template
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
from google.appengine.api import memcache
from google.appengine.api import urlfetch
@drench
drench / wp-ssl-rewrite
Created November 11, 2010 02:06
Wordpress: https for login, admin, shopping; http for everything else
# Did the user hit a page that should be https that should be http?
# Yes: redirect to https:
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(wp-admin|wp-login|wp-register|products-page)/.*$ https://wordpress.example.com/$1 [R=301,L]
# Did the user hit a page that should not be https, under https?
# Yes: redirect to http:
RewriteCond %{HTTPS} on
@straps
straps / SimplestWidget_Widget.php
Created November 12, 2010 00:14
Abstract class to create easily wordpress widgets, documented here http://www.strx.it/2010/11/wordpress-widgets-template/
<?php
class SimplestWidget_Widget extends Strx_Widget {
function w_id(){ return 'simplest-widget'; }
function w_name(){ return 'My Simplest Widget'; }
/** Return the dashboard admin form */
function w_form($instance){
return '<p>'.$this->w_form_input($instance, 'title').'</p>';
}
@mikeschinkel
mikeschinkel / list-custom-post-type-posts-with-ajax.PHP
Created November 13, 2010 10:04
Shows how to create a widget with a dropdown list of posts for a given post type and then retrieve HTML specific to the selected post via AJAX to insert into the page.
<?php
/*
List_Custom_Post_Type_Posts_with_AJAX class.
Shows how to create a widget with a dropdown list of posts for a given post type and
then retrieve HTML specific to the selected post via AJAX to insert into the page.
Yes, the name of the class is insanely long in hopes that you'll be forced to think
about what would be a better name.
<?php
$loop = new WP_Query( array( 'post_type' => 'event', 'posts_per_page' => 10 ) );
if ( $loop->have_posts() ) while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h1 class="entry-title"><?php the_title(); ?></h1>
<div class="entry-content">
<?php the_content(); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'TRBC' ), 'after' => '</div>' ) ); ?>
@pelf
pelf / snow.html
Created November 26, 2010 02:51
html5 canvas snow flakes (as seen on http://goplanapp.com/home/blackfriday)
<!DOCTYPE html>
<head>
<title>Snow</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
<script src="snow.js" type="text/javascript"/></script>
</head>
<body onload="init();">
<canvas id="bgcanvas" width="410" height="316" style="position:absolute;z-index:2"></canvas>
<img src="globe_layers_2.png" style="position:absolute;z-index:3">
<canvas id="fgcanvas" width="410" height="316" style="position:absolute;z-index:4"></canvas>
@jhaus
jhaus / SimplestWidget_Widget.php
Created November 26, 2010 03:47 — forked from straps/SimplestWidget_Widget.php
Abstract class to create easily wordpress widgets, documented here http://www.strx.it/2010/11/wordpress-widgets-template/
<?php
class SimplestWidget_Widget extends Strx_Widget {
function w_id(){ return 'simplest-widget'; }
function w_name(){ return 'My Simplest Widget'; }
/** Return the dashboard admin form */
function w_form($instance){
return '<p>'.$this->w_form_input($instance, 'title').'</p>';
}