Skip to content

Instantly share code, notes, and snippets.

View bmorrisondev's full-sized avatar

Brian Morrison II bmorrisondev

View GitHub Profile
@bmorrisondev
bmorrisondev / handler.js
Created August 18, 2020 20:14
Lambda Adapter w/Examples
const { adapter } = require('./lambdaAdapter')
exports.handler = async (event, context) => await adapter(event, context, options)
@bmorrisondev
bmorrisondev / Tail-File.ps1
Created April 14, 2020 13:40
A #powershell one liner that mimics `tail` in Linux #100daysofcode #developers
# -Tail grabs the previous N lines, -Wait will watch the file and log out the changes to the session.
Get-Content ./mylog.log -Tail 5 –Wait
@bmorrisondev
bmorrisondev / getDataUrl.js
Created April 2, 2020 16:23
You can use this function to get a base64 encoded version of a File object for uploading to an API. Works with await, or in a promise chain.
function getDataUrl(file) {
return new Promise((resolve, reject) => {
var reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result);
reader.onerror = err => reject(err);
});
};
@bmorrisondev
bmorrisondev / docker-compose.yaml
Created April 2, 2020 13:31
Here is a docker-compose file that can be used to spin up an instance of #mongodb along with the mongo-express gui
# Source: https://hub.docker.com/_/mongo
# Use root/example as user/password credentials
version: '3.1'
services:
mongo:
image: mongo
restart: always
# You can uncomment this to set a password, but I use it locally with no auth for testing.
@bmorrisondev
bmorrisondev / azure-pipelines.yml
Created March 26, 2020 21:54
An #Azure DevOps build pipeline for #GatsbyJS (or other #nodejs) projects
# Whenever a new commit is added to 'master', this build will trigger.
trigger:
- master
# Use an Azure VM with Ubuntu to build this poroject.
pool:
vmImage: 'ubuntu-latest'
# Our first step preps the VM to build our project.
steps:
@bmorrisondev
bmorrisondev / profile.ps1
Created March 26, 2020 14:15
My profile.ps1 - I use this to customize my #PowerShell session
# Stored in "~/Documents/Windows PowerShell". Any commands in this file will be executed when a session is launched.
function prompt {
"PS ($(Split-Path -leaf -path (Get-Location)))> "
}
@bmorrisondev
bmorrisondev / Check-IISSiteExists.ps1
Created March 20, 2020 21:54
Check if an IIS Site exists using PowerShell
if((Get-IISSite -Name "IisSiteName") -eq $true) {
# The site exists, do something
} else {
# The site doesnt exist.
}
@bmorrisondev
bmorrisondev / docker-rebuild.sh
Created March 19, 2020 15:48
My docker-compose script I use in my devops pipelines
#!/bin/bash
docker-compose down -v # Takes down the docker containers including named volumes
docker-compose build # Build the image
docker-compose up -d # Start the container
@bmorrisondev
bmorrisondev / simpleDiscordBot.js
Created March 6, 2020 16:34
A simple Discord bot shell, built using the discord.js library
const Discord = require('discord.js');
const client = new Discord.Client();
// When the bot is ready, log out a message.
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
// When a message is received that starts with 'hello', respond with 'world!'
// This is where you would handle various commands that your bot responds to.
@bmorrisondev
bmorrisondev / HttpContextFaker.cs
Created March 6, 2020 14:52
A simple method to mock out an HttpContext using NSubstitute for unit testing API Controllers in C#
using System;
using NSubstitute;
using Stage.Data;
using System.IO;
using System.Linq;
using System.Security.Principal;
using System.Web;
namespace FakerTools
{