Skip to content

Instantly share code, notes, and snippets.

View ajsharp's full-sized avatar

Alex Sharp ajsharp

View GitHub Profile
var $body = $('body');
var children = $body.children();
var newDiv = $('<div>');
newDiv.append(children);
$body.append(newDiv);
@ajsharp
ajsharp / Makefile
Last active January 9, 2021 05:36
This Makefile exposes commands to do a manual deploy to AWS Elastic Beanstalk using the AWS CLI. Normally, you would do a deploy with the `eb` command, but using the AWS CLI is more convenient for orchestrating continuous deployment from a CI server.
VERSION=$(shell git rev-parse --short HEAD)
DESC=$(shell git log -1 --pretty=%B)
BUCKET_NAME="my-bucket"
PROJECT_NAME="my-project"
REGION="us-east-1"
ENV_NAME="elasticbeanstalk-environment-name"
archive:
git archive --format=zip -o $(VERSION).zip HEAD
@ajsharp
ajsharp / mqtt.js
Created October 26, 2015 17:05
Browserify'd version of mqtt.js 1.4.3
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.mqtt = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function (process,global){
'use strict';
/**
* Module dependencies
*/
/*global setImmediate:true*/
var events = require('events'),
Store = require('./store'),
eos = require
class Location < ActiveRecord::Base
# fields: name, street1, city, state, zip
end
class DateStep < ActiveRecord::Base
# fields: start_time
end
@ajsharp
ajsharp / config.rb
Last active October 5, 2015 04:50
Middleman config file for frothlogic.com
# Change Compass configuration
# compass_config do |config|
# config.output_style = :compact
# end
###
# Page options, layouts, aliases and proxies
###
# Per-page layout changes:
@ajsharp
ajsharp / fading_nav.js
Last active October 6, 2015 00:43
Fading navbar implementation on http://frothlogic.com
$(window).on('scroll', function() {
var scrollY = window.scrollY;
var $jumbotron = $('.jumbotron');
var $nav = $('nav:first');
var fullBlack = $jumbotron.height() - $jumbotron.position().top;
var blackNess = (scrollY / fullBlack);
$nav.css({'background-color' : 'rgba(0,0,0,'+blackNess+')'});
});
@ajsharp
ajsharp / heroku-env-to-opsworks
Created April 23, 2015 00:38
This handy little script makes it super easy to add all your heroku environment configuration to an AWS Opsworks app. Very handy if you're moving off Heroku and onto opsworks.
#!/usr/bin/env ruby
require 'json'
app_name = 'APP_NAME'
opsworks_app_id = 'APPID'
config = `heroku config -s --app #{app_name}`.strip
json = []
@ajsharp
ajsharp / migrate-route53-dns
Last active July 3, 2023 18:35
This script makes it very easy to migrate an entire DNS zone from one AWS Route53 zone to another. This script expects you to have downloaded the old zone file via the AWS CLI to a json file called DOMAIN.zone.json. It uses the AWS CLI to perform the request, so make sure that your credentials are properly configured.
#!/usr/bin/env ruby
require 'json'
# This is the json output of the old zone, fetched using the AWS CLI.
zone = JSON.parse(File.read('DOMAIN.zone.json'))['ResourceRecordSets']
new_zone_id = 'NEW_ZONE_ID'
# We don't want to migrate the SOA and NS records from the old zone.
{
"steps": {
"original": {
"use": ":original",
"robot": "/image/resize"
},
"pdf": {
"use": ":original",
"robot": "/document/thumbs",
"page": 1