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:96b39ffb4d0ef098bfc0
Created October 17, 2014 20:37
Tuxlite for local dev
$ sudo ./domain.sh add vagrant default
@betweenbrain
betweenbrain / README.md
Last active August 29, 2015 14:18 — forked from oodavid/README.md

Backup MySQL to Amazon S3

This is a simple way to backup your MySQL tables to Amazon S3 for a nightly backup - this is all to be done on your server :-)

Sister Document - Restore MySQL from Amazon S3 - read that next

1 - Install s3cmd

this is for Centos 5.6, see http://s3tools.org/repositories for other systems like ubuntu etc

@betweenbrain
betweenbrain / gist:e7c9ccc76df5ac8efe66
Created June 3, 2015 19:41
Get random image from Joomla directory
/**
* Returns a random image from /image/homeslides/
*
* @return mixed
*/
function randomImage()
{
// Use full system path for security
$files = glob(JPATH_BASE . '/images/homeslides/*.jpg');
// Get random image
@betweenbrain
betweenbrain / gist:cf019ca40071de4e0e3c
Created June 9, 2015 15:10
Joomla JDatabase return array indexed by key
$db->loadAssocList('value', 'key');
@betweenbrain
betweenbrain / osx-10.10-apache.md
Created September 23, 2015 13:56
Mac OSX 10.10 Apache 2.4 Working Sites Directory

Create file /etc/apache2/users/{username}.conf

Add contents

<Directory "/Users/{username}/Sites/">
AllowOverride All
Options Indexes MultiViews FollowSymLinks
Require all granted
</Directory>
@betweenbrain
betweenbrain / gist:1277937
Created October 11, 2011 12:21
Regex to find name attribute containing any single word
name\=\"\b[a-zA-Z0-9_]*"
  • More complex usage using a tagged expression to move contents of the anchor to after it

Search with \<a name="">([a-zA-Z0-9_]*)\&lt;\/a\&gt; to replace with \</a><a name="">\&lt;\/a\&gt;$2

@betweenbrain
betweenbrain / gist:1336627
Created November 3, 2011 14:31
Example Joomla 1.7 Menu Image Sprite CSS for Construct Template Framework
#nav ul.menu li a {
display:block;
text-indent: -999em;
width:55px;
height:46px;
background-image:url('../images/menu.png');
background-repeat: no-repeat;
}
#nav ul.menu li.item-435 a{
background-position: -170px 0.9px;
@betweenbrain
betweenbrain / gist:1650746
Created January 21, 2012 01:58
Automatically Detect and Insert Image [name based on alias] Into Joomla Template
<?php
$itemId = JRequest::getInt('Itemid', 0);
if ($itemId) {
$currentAlias = JSite::getMenu()->getActive()->alias;
$altText = str_replace("-"," ",$currentAlias);
$fileTypes = array('png','jpg','jpeg','gif');
foreach ($fileTypes as $fileType) {
$headerImage = JPATH_BASE . '/images/banners/' . $currentAlias . '.' . $fileType;
if(JFile::exists($headerImage)) {
list($width, $height, $type, $attr) = getimagesize($headerImage);
@betweenbrain
betweenbrain / gist:1731407
Created February 3, 2012 17:58 — forked from ryanlindsey/gist:1332237
.htaccess
AddDefaultCharSet utf-8
DefaultLanguage en-US
# Activate rewrite engine
Options +FollowSymLinks
RewriteEngine on
# Redirect to wwww
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]