Skip to content

Instantly share code, notes, and snippets.

View pontusab's full-sized avatar
🦁

Pontus Abrahamsson pontusab

🦁
View GitHub Profile
@millermedeiros
millermedeiros / gist:891886
Created March 29, 2011 06:21
iPad HTML5 video quirks and hacks
/*
* Example how to preload HTML5 video on the iPad (iOS 3.2+)
* @author Miller Medeiros
* Released under WTFPL
*/
var vid = document.createElement('video');
vid.src = 'lol_catz.mp4';
document.getElementById('video-holder').appendChild(vid);
@mjangda
mjangda / better-author-urls.php
Created May 28, 2012 21:14
Better author URLs for WordPress. This enables author URLs like /author/firstname-lastname/ or /author/display_name/ instead of the usual /author/user_login/ but comes at a performance cost.
<?php
/**
* Handle author request to change query string as username
*
* This enables author URLs like /author/firstname-lastname/ or /author/display_name/ instead of the usual /author/user_login/
*/
function tc_handle_author_request( $query_vars ) {
if ( ! empty( $query_vars['author_name'] ) ) {
@5eleven
5eleven / Capistrano.Mysql
Created July 26, 2012 01:19
Capistrano task to pull MySQL production data to develoment database
# Fetches the production database on the server contents into the development
# database
#
# Assumes you have dbuser, dbhost, dbpassword, and application defined somewhere in your
# task. Modify as needed - database.yml is used for importing data, just not for exporting.
#
# Only supports MySQL.
desc "Load production data into development database"
task :fetch_remote_db, :roles => :db, :only => { :primary => true } do
require 'yaml'
@p2k
p2k / class.couchdb.php
Created August 21, 2012 11:31
PHP class for easy use of CouchDB databases
<?php
/*
* class.couchdb.php - A class for easy use of CouchDB databases in PHP
*
* Copyright (C) 2012 Patrick "p2k" Schneider <patrick.p2k.schneider@gmail.com>
*
* This is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@damienlabat
damienlabat / start.php
Created September 13, 2012 16:24
modified version of Laravel URL Class to get relative or absolute path
<?php
// bundles/url2/start.php
Autoloader::map(array(
'URL2' => Bundle::path('url2').'url2.php'
));
@franz-josef-kaiser
franz-josef-kaiser / wpmail_exceptions.php
Last active May 28, 2024 07:30
WP Mail Error/Exception handling and SMTP settings
<?php
defined( 'ABSPATH' ) OR exit;
/**
* Plugin Name: (WCM) PHPMailer Exceptions & SMTP
* Description: WordPress by default returns <code>FALSE</code> instead of an <code>Exception</code>. This plugin fixes that.
*/
add_action( 'phpmailer_init', 'WCMphpmailerException' );
function WCMphpmailerException( $phpmailer )
{
@gregrickaby
gregrickaby / html5-schema.org-markup.html
Last active August 2, 2022 00:05
Proper SCHEMA.ORG markup
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="robots" content="noodp, noydir" />
<link rel="dns-prefetch" href="//cdnjs.cloudflare.com">
<link rel="canonical" href="http://mysite.com/" />
<link rel="stylesheet" href="http://mysite.com/style.css" type="text/css" />
@franz-josef-kaiser
franz-josef-kaiser / wcm_fields.class.php
Created July 25, 2013 21:16
(WCM) Fields - A set of classes to build reusable form fields, labels, descriptions and tables. This is work in progress. The final version (which will possibly never happen), will be used in the WordPress admin UI. But lots of the code should be reusable in some standalone solution as well, as it mainly utilizes the DOMDocument class and similar.
<?php
namespace WCMFields;
defined( 'ABSPATH' ) OR exit;
/**
* Plugin Name: (WCM) Fields
* Plugin URl:
* Description: <strong>Needs PHP 5.3+!</strong>
* Author: wecodemore, Franz Josef Kaiser
* Author URl: http://unserkaiser.com
@franz-josef-kaiser
franz-josef-kaiser / toggle_metabox_bug.php
Last active December 21, 2015 06:08
Plugin to reproduce a bug that seems to toggle Admin Menu items, The whole post/post-new screen contents and user preferences for Screen Options (showing Meta Boxes). Everything needs confirmation. The plugin logs the responsible JavaScript Events to the console.
<?php
namespace WCMTest;
defined( 'ABSPATH' ) OR exit;
/** Plugin Name: Toggle MetaBox: Bug Inspect */
\add_action( 'admin_menu', array( __NAMESPACE__.'\AddMetaBox', 'getInstance' ) );
class AddMetaBox
{
@franz-josef-kaiser
franz-josef-kaiser / Example.php
Last active December 21, 2015 06:18
A simple class based file (semi-auto-)loader that needs a path, relative to the plugins root directory as input argument.
<?php
$fileLoader = new FileLoader( 'assets/php' );
foreach ( $fileLoader as $file )
$fileLoader->loadFile( $file );