Skip to content

Instantly share code, notes, and snippets.

View ajsharp's full-sized avatar

Alex Sharp ajsharp

View GitHub Profile
@ajsharp
ajsharp / migrate-eb-env
Created May 5, 2020 21:13
Migrate the environment variables from one elastic beanstalk environment to another
#!/usr/bin/env ruby
# Usage: migrate-eb-env FROM_ENV TO_ENV
from, to = ARGV
if !from || !to
$stderr.puts "FROM_ENV and TO_ENV are required"
exit(1)
end
@ajsharp
ajsharp / associate-elastic-ip.js
Last active February 18, 2020 01:06
This script assigns newly launched elastic beanstalk instances to an elastic IP. It's triggered by a Cloudwatch Rule that gets triggered when a new instance transitions to the pending state. This script is intended be run as an AWS Lambda function.
const AWS = require('aws-sdk');
const ec2 = new AWS.EC2();
const PROD_ENV_NAME = 'my-prod-env-name';
// Example Event
// {
// "version": "0",
// "id": "ee376907-2647-4179-9203-343cfb3017a4",
// "detail-type": "EC2 Instance State-change Notification",
// "source": "aws.ec2",
var global = global || this;
var self = self || this;
var console = { history: [] };
['error', 'log', 'info', 'warn'].forEach(function (fn) {
console[fn] = function () {
console.history.push({level: fn, arguments: Array.prototype.slice.call(arguments)});
};
});
function getStackTrace() {
var stack;
TYPEMAP = {
String => 'String',
Integer => 'Int',
DateTime => 'ISO8601DateTime',
Boolean => 'Boolean',
BSON::ObjectId => 'String'
}
def get_type(field_type)
TYPEMAP[field_type] || "Types::#{field_type}Type"
{
"dependencies": {
"react": "^16.8"
}
}
@ajsharp
ajsharp / gist:3cdc7bda232c6f886c6b66e88f0f3a68
Created November 28, 2018 03:16
A set of commands to clone environment vars from one heroku app to another
heroku config -s -a SOURCE_APP | ruby -e '`heroku config:set #{$stdin.read.split("\n").join(" ")} -a DEST_APP`'
@ajsharp
ajsharp / simple-ec2-process-monitor.sh
Created November 27, 2018 05:27
A simple EC2 process monitor. Invoke this script via cron every minute to make sure the process is still running. If not, log an event to cloudwatch, and restart the service.
#!/bin/bash
PROCESS_NAME='my-process'
ps aux | pgrep -f $PROCESS_NAME > /dev/null
if [ $? -eq 0 ]; then
echo "Process is running."
else
echo "Process is not running."
aws events put-events --entries '[{"Source":"com.myorg.server-name","DetailType":"$PROCESS_NAME","Detail":"{\"status\":\"down\"}"}]'
/// <reference path="passwordless-tokenstore.d.ts" />
declare module 'passwordless-mongostore' {
import TokenStore from 'passwordless-tokenstore'
export default class MongoStore extends TokenStore {
constructor(connection: string, options?: any)
}
}
export declare class Passwordless {
constructor();
acceptToken(options: any): any;
addDelivery(name: any, sendToken: any, options: any): void;
init(tokenStore: any, options: Passwordless.InitOptions): Passwordless;
logout(options: any): any;
requestToken(getUserID: any, options: any): any;
restricted(options: any): any;

Keybase proof

I hereby claim:

  • I am ajsharp on github.
  • I am ajsharp (https://keybase.io/ajsharp) on keybase.
  • I have a public key ASDjOxYpFxr14hQmOmeYo2Dre34nWzgtztY_cFQetIk_oAo

To claim this, I am signing this object: