Skip to content

Instantly share code, notes, and snippets.

View ajsharp's full-sized avatar

Alex Sharp ajsharp

View GitHub Profile
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:

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