Skip to content

Instantly share code, notes, and snippets.

View clayrichardson's full-sized avatar

clay richardson clayrichardson

View GitHub Profile
#!/bin/bash
set -ex
# Swap file commands from:
# https://www.digitalocean.com/community/articles/how-to-add-swap-on-ubuntu-12-04
# Create swapfile
echo "Creating swap file..."
dd if=/dev/zero of=/swapfile bs=1024 count=4096k

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

#include <SD.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_LSM303_U.h>
#include <Adafruit_BMP085_U.h>
#include <Adafruit_L3GD20_U.h>
#include <Adafruit_10DOF.h>
/* Assign a unique ID to the sensors */
@clayrichardson
clayrichardson / create_cluster.py
Created March 21, 2012 20:55
Create and tag Cassandra cluster on RightScale
import sys, urllib, httplib2, base64, json, re, time, paramiko
from operator import itemgetter
import pprint
headers = {}
cookie = ''
url_tail = '?api_version=1.0&format=js'
def create_url(method=None):
base_url = 'https://my.rightscale.com/api/acct/%s/' % account_id
@clayrichardson
clayrichardson / rs_tags.py
Created March 21, 2012 22:21
Grab info from rs_tag
import json, commands, re
import pprint
machines = json.loads(commands.getstatusoutput('rs_tag -q "ip:internal"')[1])
internal_addresses = []
external_addresses = []
host_string = ''
for machine,tags in machines.items():
@clayrichardson
clayrichardson / rs_tag_json.py
Created March 22, 2012 19:23
rs_tag --list output into json
import sys, subprocess, json, re
import pprint
def get_local_tags():
# rs_tag_list_command = 'rs_tag --list | awk \'{print "\\""$2"\\","}\'' terrible
rs_tag_list_command = 'rs_tag --list | awk \'{print $2}\''
p = subprocess.Popen(rs_tag_list_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
output, errors = p.communicate()
return output.split()
@clayrichardson
clayrichardson / hack.sh
Created March 31, 2012 21:33 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@clayrichardson
clayrichardson / random_jpeg_multiprocessing.py
Last active October 11, 2015 12:48
Create jpegs with random content using multiple processes
import sys
import os
import time
import uuid
import random
import signal
import multiprocessing
import numpy
from optparse import OptionParser
from django.db import models
class Manufacturer(models.Model):
uuid = models.CharField(max_length = 100)
name = models.CharField(max_length = 100)
class Car(models.Model):
uuid = models.CharField(max_length = 100)
manufacturer = models.ForeignKey(Manufacturer)
""" base58 encoding / decoding functions """
import unittest
alphabet = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'
base_count = len(alphabet)
def encode(num):
""" Returns num in a base58-encoded string """
encode = ''