Skip to content

Instantly share code, notes, and snippets.

View nathanpitman's full-sized avatar
💭
I may be slow to respond.

Nathan Pitman nathanpitman

💭
I may be slow to respond.
View GitHub Profile
@nathanpitman
nathanpitman / parse-hls-url.php
Created December 8, 2015 14:12
Used to parse Vimeo HLS URLs to negate issues with redirects and JW Player
/**
* Parse Vimeo M3U8 URLs to negate relative redirect issues with JW Player (See issue #1510)
*
* @return string
*/
public function parseHLSUrl($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); //set url
@nathanpitman
nathanpitman / switch.txt
Last active August 29, 2015 14:28
ExpressionEngine switch, always be closing (Feature Request)
{exp:channel:entries}
{switch values='<div class="row">||'}
<div class="col-md-4">
{sn_programme_block}
</div><!-- / .col-md-4 -->
{switch values='||</div><!-- / .row -->' closing='</div><!-- / .row -->'}
@nathanpitman
nathanpitman / switch.txt
Last active August 29, 2015 14:28
ExpressionEngine switch, always be closing
{exp:channel:entries}
{switch='<div class="row">||'}
<div class="col-md-4">
{sn_programme_block}
</div><!-- / .col-md-4 -->
{if count!=total_results}{switch='||</div><!-- / .row -->'}{/if}
// Returns true or false if flash installed or not. Tested with IE8 on Windows 7 and Chrome on Win7 and Mac.
(function() { var ie_flash; try { ie_flash = (window.ActiveXObject && (new ActiveXObject("ShockwaveFlash.ShockwaveFlash")) !== false) } catch(err) { ie_flash = false; } var _flash_installed = ((typeof navigator.plugins != "undefined" && typeof navigator.plugins["Shockwave Flash"] == "object") || ie_flash); return _flash_installed; })()
(function($){
$(function(){
var $form = $('#search'), // Search form
$target = $('#results'), // Results container
$rp = 'search/ajax-results'; // Template for results only
// Function to execute on success
var success = function(data, status, xhr) {
$target.html(data);
};
@nathanpitman
nathanpitman / gist:4d8512b78f03bbbe9cb7
Created September 16, 2014 13:19
Slow EE Category Query
Time: 0.1710
SELECT DISTINCT(exp_categories.cat_id), parent_id FROM exp_categories
LEFT JOIN exp_category_posts ON exp_categories.cat_id = exp_category_posts.cat_id
LEFT JOIN exp_channel_titles ON exp_category_posts.entry_id = exp_channel_titles.entry_id
WHERE group_id IN ('13','13','13') AND exp_category_posts.cat_id IS NOT NULL AND exp_channel_titles.channel_id IN ('1','8','5','6','10','11','13','18','14','15','16','19','20','22','41','42','30','31','33','34','35','36','37','39','40','43','44') AND exp_channel_titles.status != 'closed' AND exp_channel_titles.entry_date < 1410873364 AND (exp_channel_titles.expiration_date = 0 OR exp_channel_titles.expiration_date > 1410873364) AND parent_id = 0 ORDER BY group_id, parent_id, cat_order
#APP/libraries/Template.php L:1559 Channel::categories()
@nathanpitman
nathanpitman / charge_better_create_member_ext.php
Created July 3, 2014 09:56
Leverages https://github.com/joshfraser/PHP-Name-Parser to better populate ExpressionEngine member fields when using Charge 'create_member'
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* ExpressionEngine - by EllisLab
*
* @package ExpressionEngine
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2003 - 2011, EllisLab, Inc.
* @license http://expressionengine.com/user_guide/license.html
* @link http://expressionengine.com
@nathanpitman
nathanpitman / Auto Store SKU
Created March 28, 2014 16:23
Automatically populates the Expresso Store SKU field with the corresponding entry_id value on save if no custom value is specified.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* ExpressionEngine - by EllisLab
*
* @package ExpressionEngine
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2003 - 2011, EllisLab, Inc.
* @license http://expressionengine.com/user_guide/license.html
* @link http://expressionengine.com
@nathanpitman
nathanpitman / gist:8453950
Last active January 3, 2016 11:09
How to set Shuttle.app up as a convenient tool for connecting to a remote server with a single click from the menu bar.
How to set Shuttle.app up as a convenient tool for connecting to a remote server with a single click from the menu bar.
Install Homebrew (http://brew.sh/) by opening a new terminal window and pasting in:
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
Follow the prompts. After installation is complete install the 'sshpass' formula:
brew install https://raw.github.com/eugeneoden/homebrew/eca9de1/Library/Formula/sshpass.rb
@nathanpitman
nathanpitman / child-cat-count-ee
Last active January 3, 2016 09:59 — forked from zgordon/child-cat-count-ee
Modified to use category IDs instead of category URLs
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$plugin_info = array(
'pi_name' => 'Child Category Count',
'pi_version' =>'1.0',
'pi_author' =>'Nathan Pitman',
'pi_author_url' => 'http://ninefour.co.uk/labs',
'pi_description' => 'Returns number of child categories given a parent category ID',