Skip to content

Instantly share code, notes, and snippets.

@drmikecrowe
drmikecrowe / search-aws-amis.sh
Created October 13, 2017 23:09
Search for the latest releases for a given search string. Assumes that vendors release in bulk, so it looks for over 2 images released in a day and shows those matches
#!/bin/bash
LINES=6
if [ $# -ne 1 ];then
echo "Usage:"
echo " $0 keyword"
exit 1
fi
@drmikecrowe
drmikecrowe / find_latest_ubuntu_amis.sh
Last active October 13, 2017 22:31 — forked from antimius/find_latest_ami.sh
Script to find and print the latest stable, Ubuntu version
#!/bin/bash
# prints latest, stable, HVM, EBS GP2 backed AMIs for major OSs
UBUNTU=099720109477
REGIONS="us-east-1 us-east-2 us-west-1 us-west-2"
for REGION in $REGIONS; do
echo -n "$REGION: "
aws ec2 describe-images --region=$REGION --owners $UBUNTU --filters 'Name=name,Values=*hvm-ssd*16.04*' --query 'Images[*].[ImageId,CreationDate,Name]' --output text | sort -k2 -r | head -n 1
#!/bin/bash
usage() {
cat << EOF
Usage: $0 [OPTION]... COMMAND
Execute the given command in a way that works safely with cron. This should
typically be used inside of a cron job definition like so:
* * * * * $(which "$0") [OPTION]... COMMAND
Arguments:
@drmikecrowe
drmikecrowe / Dockerfile
Created January 14, 2017 04:01
Working PHP Docker Compose System with PhantimJS testing
# Build using docker build -t php-drmikecrowe
FROM php:5.6-apache
MAINTAINER Emilien Kenler <[email protected]>
RUN apt-get update && apt-get install -y git libpq-dev libmcrypt-dev zlib1g-dev libicu-dev g++ graphviz && rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-install pdo_pgsql pdo_mysql mbstring mcrypt zip sockets intl bcmath mysqli
RUN curl -o /usr/local/bin/composer https://getcomposer.org/composer.phar && \
@drmikecrowe
drmikecrowe / DisableAllMethods.js
Last active September 5, 2019 06:58
Loopback mixin to disable or expose methods
// based on https://github.com/strongloop/loopback/issues/651#issuecomment-259540469
'use strict';
const
relationMethodPrefixes = [
'prototype.__findById__',
'prototype.__destroyById__',
'prototype.__updateById__',
'prototype.__exists__',
@drmikecrowe
drmikecrowe / Account.js
Last active June 17, 2021 16:38
Auto-incrementing ID's in Loopback
module.exports = function (Account) {
Account.observe('before save', function addAccountId(ctx, next) {
if (!ctx.isNewInstance) {
debug('id is already set, returning', ctx.data);
return next();
}
app.dataSources.db.connector.collection("Sequences").findAndModify({name: 'Account'}, [['_id', 'asc']], {$inc: {value: 1}}, {new: true}, function (err, rec) {
if (err) {
console.err(err);
@drmikecrowe
drmikecrowe / setup.js
Created January 19, 2016 18:05
Set debug log level for MongoClient
var MongoClient = require('mongodb').MongoClient
, Logger = require('mongodb').Logger;
Logger.setLevel('debug');
docker-yml() {
docker inspect -f $'
{{.Name}}
image: {{.Config.Image}}
entrypoint: {{json .Config.Entrypoint}}
environment: {{range .Config.Env}}
- {{.}}{{end}}
' $1
}
@drmikecrowe
drmikecrowe / app.yml
Last active August 29, 2015 14:17 — forked from Zolmeister/app.yml
---
# file: roles/app/tasks/main.yml
- name: ensure logging directory exists
file: path=/var/log/acme state=directory
tags:
- install
- name: ensure config directory exists
file: path=/etc/acme/app state=directory
@drmikecrowe
drmikecrowe / README.md
Last active August 29, 2015 14:16
Reformat Gherkin test scripts to line up properly

Setup/Configuration

Here's how our tests are setup:

  • Tests are grouped in subdirectories
  • Each directory/filename is prefixed with a number between 100-999, typically incremented by 10. This allows us to insert new tests into the stream of sequential tests
  • Tests start at 100, but configuration setup tests start at 010.
  • Tests are tagged according to the directory, and directory/file

This is very easy to understand/use, especially when you get 1000s of steps/scenarios and complex tests in your setup.