Skip to content

Instantly share code, notes, and snippets.

View paulgibbs's full-sized avatar

Paul Wong-Gibbs paulgibbs

View GitHub Profile
@paulgibbs
paulgibbs / html5-notifications.md
Created June 12, 2012 14:04
OS X Notification Center in Safari 5.2

OS X Notification Center in Safari 5.2

OS X Mountain Lion adds Notification Center for managing alerts. Just like growl, but better.

Safari 5.2 exposes HTML5 notifications API to sites. Every site need to have permission for showing notifications.

Specification is very new and completely different from older version Chrome has. Developer doesn't have to watch for complicated NotificationCenter.

The syntax is very simple:

@paulgibbs
paulgibbs / gist:2928916
Created June 14, 2012 08:05
Twitter Open Graph addditions for Twitter Cards
nyt:
<meta name="twitter:card" value="summary">
<meta name="twitter:site" value="@nytimes">
<meta name="twitter:creator" value="@markoff">
wsj:
<meta name="twitter:player:width" value="512" />
<meta name="twitter:player:height" value="363" />
<meta name="twitter:card" value="player" />
<meta name="twitter:site" value="@WSJ" />
@paulgibbs
paulgibbs / wp-plugin-path.php
Created June 16, 2012 11:00 — forked from alexkingorg/wp-plugin-path.php
Defining symlink compatible paths for WordPress plugins
<?php
// include this near the top of your plugin file
$my_plugin_file = __FILE__;
if (isset($plugin)) {
$my_plugin_file = $plugin;
}
else if (isset($mu_plugin)) {
@paulgibbs
paulgibbs / gist:2993756
Created June 26, 2012 06:29
Gravatar lookup from via WordPress.org user name
http://wordpress.org/grav-redirect.php?user=DJPaul&s=100 -> http://0.gravatar.com/avatar/3bc9ab796299d67ce83dceb9554f75df?d=retro&s=100
@paulgibbs
paulgibbs / gist:3045932
Created July 4, 2012 07:37
Load WordPress via another PHP script
<?php
$site_name = 'news_blog'; // e.g. "example.com/news_blog"
$site_domain = 'example.com';
/**
* Construct a fake $_SERVER global to get WordPress to load a specific site.
* This avoids alot of messing about with switch_to_blog() and all its pitfalls.
*/
$_SERVER = array(
'HTTP_HOST' => $site_domain,
@paulgibbs
paulgibbs / gist:3104460
Created July 13, 2012 11:40
Show page comments in BuddyPress' activity stream
<?php
/*
Plugin Name: Plugin Name
Plugin URI: http://example.com/
Description: Description
Version: 0.1
Author: Your Name
Author URI: http://example.com/
*/
@paulgibbs
paulgibbs / gist:3199341
Created July 29, 2012 14:46
Web Notifications POC
// very rough, basic javascript calls to use the W3 Web Notifications api, rather than all the webkitNotifications stuff which you find in google.
(function($) {
$(document).ready(function() {
// Ask for permission
$('#ask_permission').click(function(e) {
e.preventDefault();
// webkitNotifications.requestPermission(function(){}); // use this for safari / w3 standards
// window.Notification.requestPermission(function(e) { alert(e); }); // use this for chrome (w3 standard causes a crash)
@paulgibbs
paulgibbs / gist:4573121
Created January 19, 2013 15:19
Achievements 3 shortcodes (as of Beta 4)
[dpa-achievements-index]
[dpa-single-achievement 1]
[dpa-breadcrumb]
<?php
function x_allow_ids_on_tags() {
global $allowedposttags;
$tags = array( 'section', 'article' );
$new_attributes = array( 'id' => array() );
foreach ( $tags as $tag ) {
if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) )
$allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes );
<?php
function pg_test_dk( $reply_url, $redirect_to, $reply_id ) {
error_log('redirecting: ' . print_r(compact($reply_url, $redirect_to, $reply_id), true));
}
add_filter( 'bbp_new_reply_redirect_to', 'pg_test_dk', 10, 3 );