Skip to content

Instantly share code, notes, and snippets.

View clayrichardson's full-sized avatar

clay richardson clayrichardson

View GitHub Profile
@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 / wallbase.py
Created April 3, 2012 05:30
Grab some random wallpapers from the toplist on wallbase.cc
import re
import time
import pprint
import urllib2
import urllib
from BeautifulSoup import BeautifulSoup as soup
from random import choice
def append_links(thumb_div):
@clayrichardson
clayrichardson / multiprocessing_test.py
Created August 15, 2012 10:35
Python Multiprocessing Queues and Pipes
import sys
import time
import random
import signal
import multiprocessing
processes = []
def launch_process(number, kill_queue, child_connection):
@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 = ''
@clayrichardson
clayrichardson / change_phabricator_prefix.rb
Created February 1, 2014 04:11
Script to migrate phabricator database prefixes
require 'ostruct'
require 'optparse'
require 'awesome_print'
$stdout.sync = true
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: change_phabricator_prefix.rb [options]"