Skip to content

Instantly share code, notes, and snippets.

@oodavid
oodavid / README.md
Last active October 11, 2024 00:36 — forked from aronwoost/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@oodavid
oodavid / README.md
Created March 26, 2012 17:05
Backup MySQL to Amazon S3

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

@oodavid
oodavid / README.md
Created March 26, 2012 21:21
Restore MySQL from Amazon S3

Restore MySQL from Amazon S3

This is a hands-on way to pull down a set of MySQL dumps from Amazon S3 and restore your database with it

Sister Document - Backup MySQL to Amazon S3 - read that first

1 - Set your MySQL password and S3 bucket, make a temp dir, get a list of snapshots

# Set our variables

export mysqlpass="ROOTPASSWORD"

@oodavid
oodavid / README.md
Created March 27, 2012 08:29
CentOS AMP Server Setup

CentOS AMP Server Setup

I think I'd like to write (for fairly perverse reasons) a script that will setup something like this on a CentOS server:

  • Got CentOS?
  • Got root?
    • Update CentOS
    • Set hostname, timezone etc
    • Install Apache, MySQL, PHP, ImageMagick, S3cmd, Git etc.
  • Setup Git with Apache user and pull from github / bitbucket to /var/www/html/
@oodavid
oodavid / recursive_killing.js
Created March 30, 2012 08:10
Recursive Killing
// Build a deep object of some sort
var ob = {
type: 'windar',
title: 'Hello World',
children: [
{
type: 'BUTTUN',
title: 'click me',
},
{
@oodavid
oodavid / README.md
Created April 6, 2012 13:39
XFCE - "Open any file" via Keyboard Shortcut

Linux - "Open any file" via Keyboard Shortcut

Assign this little shell script to a keyboard shortcut Xfce to open a shell -prompt, then have that file / directory opened by it's native program.

Pretty simple, excellent user-experience!

Thanks to Xfce forum member "ToC" who helped me solve a problem with the script

How to install

@oodavid
oodavid / README.md
Created April 9, 2012 21:41
Sync ./uploads/ with Amazon S3

Sync ./uploads/ with Amazon S3

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

1 - Install s3cmd

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

# Install s3cmd

cd /etc/yum.repos.d/

@oodavid
oodavid / README.md
Created April 12, 2012 20:01
MySQL - Group by grid-square

MySQL - Group by grid-square

Inspired by the police.uk crime maps, where they cleverly cluster data together depending on how far zoomed in you are, this MySQL snippet goes a long way to explaining the logic behind such an operation.

A perfect grid

This snippet groups sites to a perfect grid while the police.uk algorithm has some sort of trickery that moves their points about somewhat, looking at their blogs and documentation I would conclude that they have a predefined set of points, each with a catchment area of postcodes. It looks like a whole lot of scraping and manual labour went into their database and quite frankly I don't have the time nor inclination do attempt such a task.

Example

@oodavid
oodavid / primes.js
Created May 18, 2012 10:25
Prime Numbers Algorythm
/**
* You can check if a number is a prime by looping the known primes to see if it divides.
*/
// Seed the primes array
var primes = [2,3];
// Start counting up...
myCounter : for(n=5; n<10000; n+=2){
// Loop the known primes
for(p=0, l=primes.length; p<l; p++){
@oodavid
oodavid / README.md
Created June 20, 2012 13:32
MySQL to Structured Data (EXPERIMENT)

Found this little experiment in the depths of one of my projects; I've removed it and dumped it here in case I want it in the future