Skip to content

Instantly share code, notes, and snippets.

View roborourke's full-sized avatar
🤠

Robert O'Rourke roborourke

🤠
View GitHub Profile
@remy
remy / gist:804414
Created January 31, 2011 17:24
Simple CSS parser
function parseCSS(str) {
function trim(str) {
return (str||'').replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}
var i, j, k,
split = '}',
cur_key = '',
cur_key_split,
css = str.replace(/\t*/g, '').replace(/\s{2}/, ' ').replace(/[\n|\r]/g, ' ').replace(/\/\*.*?\*\//g, '').split(split),
@gferreira
gferreira / elementar.jquery.js
Created September 9, 2011 16:24
Elementar jQuery plugin [DRAFT]
/* Elementar jQuery plugin [DRAFT] */
// use Elementar fonts via Typotheque's web font system
// args: family name, style name, webfont key
$('.myClass').eFont('Sans A', '13 21 2', 'WF-XXXXXX-XXXXX')
// use self-hosted fonts
// args: family name, style name, path to fonts folder
$('.myClass').eFont('Sans A', '13 21 2', '../fonts/')
@roborourke
roborourke / reload-buttons.js
Created November 1, 2011 12:41
Reloading Facebook like, Google +1 and Twitter share buttons for content loaded via AJAX
function reload_buttons() {
// facebook buttons
FB.XFBML.parse( document );
// gplus buttons
gapi.plusone.go();
// twitter buttons
twttr.widgets.load();
// img unautop, Courtesy of Interconnectit http://interconnectit.com/2175/how-to-remove-p-tags-from-images-in-wordpress/
// add img class and alignment to figure by @_RickBenetti
function img_unautop($pee) {
$class = apply_filters('get_image_tag_class', $class, $id, $align, $size);
$pee = preg_replace('/<p>\\s*?(<a .*?><img.*?><\\/a>|<img.*?>)?\\s*<\\/p>/s', '<figure class="'. $class+$align .'">$1</figure>', $pee);
return $pee;
}
add_filter( 'the_content', 'img_unautop', 30 );
@dimadin
dimadin / gist:4247285
Created December 9, 2012 22:27
Load only admin bar translation on WordPress frontend
/**
* Set en_US lang code if not in admin.
*/
function md_set_en_us_locale( $locale ) {
if ( ! is_admin() ) {
if ( ! defined( 'MD_REAL_LANG' ) )
define( 'MD_REAL_LANG', $locale );
$locale = 'en_US';
}
@willmot
willmot / gist:1277790
Created October 11, 2011 10:33
WordPress attachment category plugin
<?php
/*
Plugin Name: Attachment Categories
Description: Allows attachments to be categorised
Version: 1.0
Author: Human Made Limited
Author URI: http://hmn.md
*/
<?php
/**
* Plugin Name: (WCM) Backbone/Underscore template loader
* Description: Loads Underscore (or other) templates using the WP Dependency API
*/
/**
* @author Franz Josef Kaiser http://unserkaiser.com/
* @link http://chat.stackexchange.com/transcript/message/19439060#19439060
*/
@shadyvb
shadyvb / scoped-cache.php
Last active September 19, 2016 13:13
WordPress Scoped Cache helper
<?php
/**
* WordPress Scoped Cache Helper
*
* This addresses the problem of obsolete cached data for an object after it is updated.
*
* Sometimes we need to cache specific bits of data related to a certain object, and keep the cached data in sync
* with the object's state. This helper makes it easier to tap into object update process to clear ( and optionally
* rebuild ) the cache.
*
@mlconnor
mlconnor / oembed_endpoints.js
Created April 24, 2013 12:45
List of oEmbed endpoints found here http://api.embed.ly/1/services
[{"regex": ["http://*youtube.com/watch*", "http://*.youtube.com/v/*", "https://*youtube.com/watch*", "https://*.youtube.com/v/*", "http://youtu.be/*", "http://*.youtube.com/user/*", "http://*.youtube.com/*#*/*", "http://m.youtube.com/watch*", "http://m.youtube.com/index*", "http://*.youtube.com/profile*", "http://*.youtube.com/view_play_list*", "http://*.youtube.com/playlist*"], "about": "YouTube is the world's most popular online video community, allowing millions of people to discover, watch and share originally-created videos. YouTube provides a forum for people to connect, inform, and inspire others across the globe and acts as a distribution platform for original content creators and advertisers large and small.", "displayname": "YouTube", "name": "youtube", "domain": "youtube.com", "subdomains": ["m.youtube.com"], "favicon": "http://c2548752.cdn.cloudfiles.rackspacecloud.com/youtube.ico", "type": "video"}, {"regex": ["http://*twitch.tv/*", "http://*justin.tv/*/b/*", "http://*justin.tv/*/w/*"], "about":
@ramv
ramv / kirby.conf
Created March 6, 2014 23:49
Kirby NGINX configuration
##############################
## Kirby configuration
##############################
location /kirby/ {
include /etc/nginx/mime.types;
index index.php;
root /var/www/addons88/;
if (!-e $request_filename){