Skip to content

Instantly share code, notes, and snippets.

View arfon's full-sized avatar
:shipit:

Arfon Smith arfon

:shipit:
View GitHub Profile
<div id="into_the_lab">
<div class="arrow"></div>
<p><%= link_to "Go into the lab", "http://ec2-50-17-36-93.compute-1.amazonaws.com", :target => "_blank" %></p>
</div>
<script>
// Make the whole div clickable
$("#into_the_lab").click(function(){
window.location=$(this).find("a").attr("href");
return false;
@arfon
arfon / mysql_backup.sh
Created May 14, 2012 12:57
Backup all MySQL databases
#!/bin/bash
# Daniel Verner
# CarrotPlant LLC
# 2011
# Backup each mysql databases into a different file, rather than one big file
# Optionally files can be gzipped (dbname.gz)
#
# Usage: dump_all_databases [ -u username -o output_dir -z ]
#
# -u username to connect mysql server
@arfon
arfon / super.rb
Created June 10, 2012 11:31
Supernova classification exporter
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => "mysql",
:host => "localhost",
:username => "root",
:password => "",
:database => "super"
)
@arfon
arfon / gist:4152089
Created November 27, 2012 02:55
Rickshaw example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Spotty plots</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="https://raw.github.com/shutterstock/rickshaw/master/vendor/d3.min.js"></script>
<script src="https://raw.github.com/shutterstock/rickshaw/master/rickshaw.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://raw.github.com/shutterstock/rickshaw/master/rickshaw.min.css">
</script>
@arfon
arfon / gist:4157786
Created November 27, 2012 22:58
Serengeti folder walker
traps = Dir.glob('*')
count = 0
traps.each do |trap|
if File.directory? trap
Dir.chdir(trap)
rolls = Dir.glob('*')
rolls.each do |roll|
if File.directory? roll
@arfon
arfon / spot_pricing.rb
Created January 1, 2013 00:31
Retrieve and persist pricing histories for AWS spot
require 'aws-sdk'
require 'pry'
require 'mongoid'
Mongoid.configure do |config|
config.sessions = {
:default => {
:hosts => ["somewhere.mongohq.com:27083"], :database => "development", :username => "username", :password => "password" }
}
end
@arfon
arfon / response.js
Last active December 10, 2015 17:48
Spotty Process: Get all instances of a given type
// Request using instance API names defined here: http://aws.amazon.com/ec2/instance-types/
// curl http://spot.arfon.org/instances/m1.large
// Example response below
[{
"availability_zone": "us-east-1d",
"current_price": 0.066,
"id": "50b196d2a2fc8eef10000048",
"name": "m1.large",
"pricing_history": {
@arfon
arfon / response.js
Created January 6, 2013 20:12
Spotty Process: Get all instances in a given availability zone
// Request using availability zone codes
// curl http://spot.arfon.org/availability_zones/us-east-1b
// Example response below
[{
"availability_zone": "us-east-1b",
"current_price": 0.0635,
"id": "50c070e7884b630002000005",
"name": "m3.xlarge",
"pricing_history": {
@arfon
arfon / response.js
Created January 6, 2013 20:16
Spotty Process: Price for a given instance size in a single availability zone
// Request using availability zone codes and instance type codes
// curl http://spot.arfon.org/instances/m1.large/us-east-1b
// Example response below
[{
"availability_zone": "us-east-1b",
"current_price": 0.026,
"id": "50b196d8a2fc8eef100000c0",
"name": "m1.large",
"pricing_history": {
@arfon
arfon / response.js
Created January 6, 2013 20:53
Spotty Process: Current cheapest price for a give instance type
// Request using availability zone codes
// curl http://spot.arfon.org/cheapest/m1.large
// Example response below
{
"linux": {
"availability_zone": "us-east-1a",
"current_price": 0.026,
"id": "50b196d2a2fc8eef1000004d",
"name": "m1.large",