Skip to content

Instantly share code, notes, and snippets.

@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
Last active April 6, 2024 18:45 — 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 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 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 / ssl-letsencrypt-auto-renew.sh
Last active January 11, 2023 22:17
Automatically renew letsencrypt SSL certificates via cron.
#!/bin/bash
# Source
# https://gist.github.com/oodavid/54cadfb92ff49618797d
# Adapted from
# https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-14-04
# Make sure this is added to the crontab, ie:
# sudo crontab -e
# 30 2 * * 1 /home/ubuntu/khan-draw/ssl-letsencrypt-auto-renew.sh >> /var/log/ssl-letsencrypt-auto-renew.log
# Config
@oodavid
oodavid / server.gitready.sh
Last active August 6, 2022 10:37
Execute this file from a local git repo to create repos on your webserver to act as a remote AND working master branch
#!/bin/bash
# This script is no good for servers with multiple-users, I simply
# designed it to quickly push my git tinkerings to my EC2 test server.
#
# Use at your own risk!
#
# cd to a local directory under git control and execute this script, it will:
# create repos on your server
# modify your local remotes to push to the server
/// 0 - Example `Streams`
Stream<MyUserModel> userStream => FirebaseAuth
.instance
.onAuthStateChanged
.map((user) => MyUserModel.fromFirebase(user));
String documentPath = 'my/document';
Stream<MyDocumentModel> documentStream = Firestore.instance
.document(documentPath)
.snapshots()
@oodavid
oodavid / clone.md
Created June 22, 2017 12:09
Create a new repo from a directory within an existing repo

Make sure you have this git alias

git config --global alias.clone-branches '! git branch -a | sed -n "/\/HEAD /d; /\/master$/d; /remotes/p;" | xargs -L1 git checkout -t'

Clone the remote, pull all branches, change the remote, filter your directory, push

git clone git@github.com:user/existing-repo.git new-repo
cd new-repo
git clone-branches

git remote rm origin

@oodavid
oodavid / main.dart
Created January 22, 2020 17:17
Dart > Sort List<Map> by multiple keys
extension SortBy on List {
sortBy(List<String> keys) {
this.sort((a, b) {
for(int k=0; k<keys.length; k++) {
String key = keys[k];
int comparison = Comparable.compare((a[key]??""), (b[key]??""));
if(comparison != 0){
return comparison;
}
}
# http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true