Skip to content

Instantly share code, notes, and snippets.

View betweenbrain's full-sized avatar
🎯
Focusing

Matt Thomas betweenbrain

🎯
Focusing
View GitHub Profile
@betweenbrain
betweenbrain / gist:5038980
Created February 26, 2013 14:53
JCacheStorageDb for storing cache files in database from http://forum.joomla.org/viewtopic.php?p=1380543
<?php
// Check to ensure this file is within the rest of the framework
defined('JPATH_BASE') or die();
/**
* DB cache storage handler
*
* @author Geraint Edwards (http://www.gwesystems.com)
* @package Joomla.Framework
* @subpackage Cache
@betweenbrain
betweenbrain / gist:5405671
Created April 17, 2013 16:26
Use cURL and SimpleXML to retrieve and parse Wordpress RSS feed
<?php
$curl = curl_init();
curl_setopt_array($curl, Array(
CURLOPT_URL => 'http://blogs.guggenheim.org/map/feed/',
CURLOPT_USERAGENT => 'spider',
CURLOPT_TIMEOUT => 120,
CURLOPT_CONNECTTIMEOUT => 30,
CURLOPT_RETURNTRANSFER => TRUE,
@betweenbrain
betweenbrain / gist:5431322
Last active April 8, 2019 23:11
Stan's Awesome Hummus Recipe
2 cans garbanzo beans (1 drained)
1/2 cup Sesame Tahini
1 TBS Tamari or Ponzu
Juice of one lemon (3 TBS ReaLemon)
Optional:
1-4 cloves garlic, to liking
Add ingredients to a good blender and blend until smooth.
@betweenbrain
betweenbrain / gist:5544043
Created May 8, 2013 22:08
User configurable Joomla! 1.5 module select element
class JElementFoo extends JElement {
var $_name = 'foo';
function fetchElement($name, $value, &$node, $control_name) {
$cid = JRequest::getVar('cid');
$db = JFactory::getDBO();
$options = array();
@betweenbrain
betweenbrain / gist:5561375
Last active December 17, 2015 05:58
Proposed change to allow `JHtml::_('bootstrap.loadCss')` usage auto detect language direction
/**
* Loads CSS files needed by Bootstrap
*
* @param boolean $includeMainCss If true, main bootstrap.css files are loaded
* @param string $direction rtl or ltr direction. If empty, ltr is assumed
* @param array $attribs Optional array of attributes to be passed to JHtml::_('stylesheet')
*
* @return void
*
* @since 3.0
@betweenbrain
betweenbrain / gist:5672035
Last active December 17, 2015 21:08
Wrap K2 Items in "row" elements
<?php
$count = count($this->leading);
if (isset($this->leading) && $count) :
?>
<div class="item-list">
<!-- start first row -->
<div class="row">
<?php foreach ($this->leading as $key => $item) :
$fmod = fmod($key + 1, $this->params->get('num_leading_columns'));
?>
@betweenbrain
betweenbrain / gist:5730931
Created June 7, 2013 17:30
PHP Session Storage Performance Tests
/*
* Store random data in array and use in_array() for duplicate checking
*/
$then = microtime(TRUE);
$i = 1;
while ($i <= 1000) {
$rand = rand();
$now = microtime(TRUE);
@betweenbrain
betweenbrain / gist:5767388
Created June 12, 2013 17:30
Joomla 1.5 multiple select menu item custom parameter type
<?php defined('_JEXEC') or die;
/**
* File menuitems.php
* Created 6/12/13 11:37 AM
* Author Matt Thomas | matt@betweenbrain.com | http://betweenbrain.com
* Support https://github.com/betweenbrain/
* Copyright Copyright (C) 2013 betweenbrain llc. All Rights Reserved.
* License GNU GPL v3 or later
*/
@betweenbrain
betweenbrain / gist:5849869
Created June 24, 2013 13:01
Ems related reading
http://www.w3.org/WAI/GL/css2em.htm
http://filamentgroup.com/lab/how_we_learned_to_leave_body_font_size_alone/
http://alistapart.com/article/relafont
@betweenbrain
betweenbrain / gist:5910633
Created July 2, 2013 16:05
Manually parse Joomla! 1.5 plugin database field [name=value\n]
$plugins = new stdClass();
$pluginsData = explode("\n", $item->plugins);
foreach ($pluginsData as $pluginData) {
$parts = explode("=", $pluginData);
if ($parts[0]) {
$name = $parts[0];
$value = $parts[1];
$plugins->$name = $value;
}
}