Skip to content

Instantly share code, notes, and snippets.

View danmatthews's full-sized avatar
😃
Working.

Dan Matthews danmatthews

😃
Working.
View GitHub Profile
@danmatthews
danmatthews / SassMeister-input-HTML.html
Created February 25, 2014 20:01
Generated by SassMeister.com.
<h3>Recommend rating</h3>
<div class="simply-widget-container">
<div class="widget-instance">
<div class="simply-link">Provided by Simply Satisfied.</div>
<div class="simply-recommend-rating">49<span class="pc">%</span></div>
<p>Would recommend Simply Satisfied to someone else.</p>
</div>
</div>
<hr />
<h3>Satisfaction rating.</h3>

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

shuffle = (a) ->
# From the end of the list to the beginning, pick element `i`.
for i in [a.length-1..1]
# Choose random element `j` to the front of `i` to swap with.
j = Math.floor Math.random() * (i + 1)
# Swap `j` with `i`, using destructured assignment
[a[i], a[j]] = [a[j], a[i]]
# Return the shuffled array.
a[0]
@danmatthews
danmatthews / gist:5945456
Last active December 19, 2015 11:09
Basic loading image fading in and out using NSTimer and UIImageView / UIImage.
- (void)viewDidLoad
{
[super viewDidLoad];
// Create a container UIView - actually, this part might not be needed at all!.
// Establish this view with a 150x150pt frame, to fit our custom image.
// Note that it's in the top-left for the moment, don't worry about that for now.
UIView *loader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 150, 150)];
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/php");</script>
@danmatthews
danmatthews / awesome-php.md
Created October 29, 2012 10:55 — forked from ziadoz/awesome-php.md
Awesome PHP Libraries
#!/bin/sh
KEY="$HOME/.ssh/id_dsa.pub"
if [ ! -f ~/.ssh/id_dsa.pub ];then
echo "private key not found at $KEY"
echo "* please create it with "ssh-keygen -t dsa" *"
echo "* to login to the remote host without a password, don't give the key you create with ssh-keygen a password! *"
exit
fi
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<rss version="2.0">
<channel>
<title>UKVetsOnline Content for Byre Veterinary Surgery</title>
<link>http://www.ukvetsonline.co.uk/node/313954?&amp;m=&amp;mp=313954</link>
<description>The latest in advice &amp; care, promotions, and news from UKVetsOnline.</description>
<language>en-us</language>
<pubDate>Tue, 18 Jan 2011 02:13:01 +0000</pubDate>
<lastBuildDate>Tue, 07 Aug 2012 11:45:33 +0100</lastBuildDate>
<item>
@danmatthews
danmatthews / gist:3240064
Created August 2, 2012 19:49
Solution to doing some processing for every method of FuelPHP REST controller.
<?php
class ExampleRestController extends Controller_Rest {
/**
* Make sure the router method has the same method signature as the parent::router declaration.
* @see fuel/core/classes/controller/rest.php
*/
public function router($method, array $params) {
SELECT e.date_subscribed,
countries.name
FROM countries
JOIN contacts c
LEFT OUTER JOIN contacts_economic_updates_countries e
ON e.country_name = countries.name
WHERE c.contact_id='80d0624061395e3d9f108165cd163e004a2ed12e37def2995f866d82dd40b3f2'
ORDER BY countries.name