Skip to content

Instantly share code, notes, and snippets.

View bmorrisondev's full-sized avatar

Brian Morrison II bmorrisondev

View GitHub Profile
@bmorrisondev
bmorrisondev / migrate-mongodb-collections-mongoose.js
Last active January 16, 2019 23:02
Migrate MongoDB Collections using Mongoose.js
const fs = require('fs')
const mongoose = require('mongoose')
const ModelOne = require('./models/ModelOne')
const ModelTwo = require('./models/ModelTwo')
let source = "mongodb://source.database.com:27017/srcdb"
let destination = "mongodb://dest.database.com:27017/dstdb"
let models = [
ModelOne,
@bmorrisondev
bmorrisondev / app.js
Created January 17, 2019 21:19
A simple shell of an Express app
if(process.env.ENVIRONMENT != "PROD") {
require('dotenv').config()
}
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const morgan = require('morgan')
const routes = require('./routes')
@bmorrisondev
bmorrisondev / s3Helper.js
Created January 18, 2019 11:47
A quick snippet that can be used to upload a file to an S3 bucket.
const AWS = require('aws-sdk');
function putObjectToS3(bucket, key, data){
return new Promise((resolve, reject) => {
let s3 = new AWS.S3();
var params = {
Bucket : bucket,
Key : key,
Body : data
}
@bmorrisondev
bmorrisondev / PrismView.vue
Created January 18, 2019 14:33
A VueJS template to display formatted code on a page using PrismJS
<template>
<div>
<prism language="json" :code="JSON.stringify(data, null, 4)"></prism>
</div>
</template>
<script>
import Prism from 'vue-prismjs'
import 'prismjs/themes/prism.css'
@bmorrisondev
bmorrisondev / VuetifyAppTemplate.vue
Created January 21, 2019 17:17
A VueJS + Vuetify app template with toolbar, navigation drawer, and router configuration.
<template>
<v-app>
<v-navigation-drawer :value="isDrawerVisible" app clipped>
<v-list class="pt-0">
<v-list-tile @click="">
<v-list-tile-action>
<v-icon>dashboard</v-icon>
</v-list-tile-action>
<v-list-tile-content>
@bmorrisondev
bmorrisondev / test-spec.json
Created January 21, 2019 18:25
NPM command to start nodemon & mocha, and run any tests with the 'spec.js' suffix inside the src folder of a node project.
{
"test-spec": "nodemon --exec \"mocha -c --reporter=spec --recursive \"src/**/*.spec.js\"\""
}
@bmorrisondev
bmorrisondev / sampleDynamooseModel.js
Created January 23, 2019 14:51
A sample user model using Dynamoose, an ORM for AWS DynamoDB with a similar API to Mongoose
const dynamoose = require('dynamoose');
let configUpdates = {
region: "us-east-1",
accessKeyId: 'key123',
secretAccessKey: 'secret123'
}
dynamoose.AWS.config.update(configUpdates);
@bmorrisondev
bmorrisondev / dbhelper.js
Created January 24, 2019 14:47
A mongoose connection helper script that builds a connection string from environment variables
// env.test file:
// DB_HOST="localhost"
// DB_PORT="27017"
// DB_NAME="dbname"
// DB_USER="dbusername"
// DB_PASS="dbpassword"
require('custom-env').env(true)
const mongoose = require('mongoose')
@bmorrisondev
bmorrisondev / Remove-AllMsolLicenses.ps1
Created February 8, 2019 21:02
Remove all licenses from a user in Office 365 using PowerShell
$MsolUser = Get-MsolUser -UserPrincipalName $Username
$AssignedLicenses = $MsolUser.licenses.AccountSkuId
foreach($License in $AssignedLicenses) {
Set-MsolUserLicense -UserPrincipalName $Username -RemoveLicenses $License
}
@bmorrisondev
bmorrisondev / Set-NamecheapDdnsRecord.ps1
Last active July 28, 2024 15:47
Update a Dynamic DNS Record in Namecheap using PowerShell
function Set-NamecheapDdnsRecord {
<#
.SYNOPSIS
Update the IP address of a Dynamic DNS record in Namecheap.
.EXAMPLE
PS C:\> Set-NamecheapDdnsRecord -HostRecord www -Domain brianmorrison.me -ApiKey 12345678abcd -Ip 123.234.123.234
Updates the record for www.brianmorrison.me to 123.234.123.234
.NOTES
Author: Brian Morrison II
Date: 4/10/2019