Skip to content

Instantly share code, notes, and snippets.

View beaucollins's full-sized avatar
🃏
Special Author

Beau Collins beaucollins

🃏
Special Author
View GitHub Profile
class Object
def if_present?(&blk)
return self unless present?
if blk.arity == -1
instance_eval(&blk)
else
blk.call(self)
end
self
<?php
query_posts( array(
'post_type' => 'event', // only query events
'meta_key' => 'event_date', // load up the event_date meta
'orderby' => 'meta_value', // sort by the event_date
'order' => 'asc', // ascending, so earlier events first
'meta_query' => array( // restrict posts based on meta values
'key' => 'event_date', // which meta to query
'value' => array('2011-01-01','2011-02-01'), // value for comparison

Turns any webpage into a mobile web app:

Step 1) Copy this javascript

javascript:d=document;m=document.createElement('meta');m.setAttribute('name','apple-mobile-web-app-capable');m.setAttribute('content','yes');d.getElementsByTagName('head')[0].appendChild(m);

Step 2) Go to the mobile app you want to use (e.g. mail.google.com on your iphone/ipad)

Step 3) Clear the location field in the browser and paste the code you copied and hit "GO"

<?php
// Checks an array for a given $key, if it exists, returns the value stored at that
// key. If it doesn't exist it returns the $default value.
function array_var($array, $key, $default = false){
if (array_key_exists($key, $array)) {
return $array[$key];
}else{
return $default;
}
From dc92e690ccd6a5028448e1544bb69a7a9f2fe615 Mon Sep 17 00:00:00 2001
From: Beau Collins <[email protected]>
Date: Fri, 3 Jun 2011 10:13:59 -0700
Subject: [PATCH] initializing Post with default values
---
compose/source/Compose.js | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/compose/source/Compose.js b/compose/source/Compose.js
@beaucollins
beaucollins / events.php
Created June 8, 2011 21:16 — forked from anonymous/events.php
events.php
<?php
$today = date("o-m-d");
$future = strtotime ( '+6 days' , strtotime ( $today ) ) ;
$future = date ( 'o-m-d' , $future );
$event_query = new WP_Query(
array(
'post_type' => 'event',
'meta_key' => 'event-date',
'orderby' => 'meta_value',
'order' => 'asc',
var fs = require('fs');
var http = require('http');
var url = require('url');
var sys = require('sys');
var file = './hyperdrive.jpg';
var blogId = 10231312;
var username = 'redacted';
var password = 'redacted';
var endpoint = 'http://example.com';
var fs = require('fs');
var http = require('http');
var url = require('url');
var file = './hyperdrive.jpg';
var blogId = 10231312;
var username = 'redacted';
var password = 'redacted';
var endpoint = 'http://example.com';
var destination = url.parse(endpoint);
var fs = require('fs');
var http = require('http');
var url = require('url');
var file = './hyperdrive.jpg';
var blogId = 10231312;
var username = 'redacted';
var password = 'redacted';
var endpoint = 'http://example.com/';
var destination = url.parse(endpoint);
@beaucollins
beaucollins / gist:1107264
Created July 26, 2011 17:17 — forked from anonymous/gist:1107220
functions.php
add_action( 'init', 'event_rewrites' );
function event_rewrites()
{
add_rewrite_rule( "/\/events\/day\/([\d]{4}-[\d]{2}-[\d]{2})\/?/", 'index.php?post_type=event&event-date=$matches[1]', 'top' );
}
add_filter( 'query_vars', 'event_vars' );
function event_vars ( $vars )
{
$vars[] = 'event-date';
return $vars;