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 / simple-promise-retry.js
Created January 27, 2017 21:12 — forked from briancavalier/simple-promise-retry.js
A few general patterns for retries using promises
function keepTrying(otherArgs, promise) {
promise = promise||new Promise();
// try doing the important thing
if(success) {
promise.resolve(result);
} else {
setTimeout(function() {
keepTrying(otherArgs, promise);
@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

<?php
$con = mysql_connect('localhost', 'dbUser', 'dbPassword');
$key = '1234567890123456';
$table = "CREATE TABLE people (
id INT NOT NULL AUTO_INCREMENT,
full_name VARCHAR(255),
ssn VARCHAR(255),
PRIMARY KEY (id)

Here is an example of write subquery in Joomla! 3 using JDatabase method.

<?php
// Initialize variables.
$db       = JFactory::getDbo();
$subQuery = $db->getQuery(true);
$query    = $db->getQuery(true);

// Create the base subQuery select statement.
[client]
host=
user=
password=
database=
@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]