Skip to content

Instantly share code, notes, and snippets.

View smcelhinney's full-sized avatar

Stephen McElhinney smcelhinney

View GitHub Profile

Hey, so this is the problem, I've two models Collection & Track. As you can tell, a collection can contain many tracks, but a track belongs to one collection

ModelCollection.ts

import mongoose, { Schema, model, SchemaType, SchemaTypes } from "mongoose";

// 1. Create an interface representing a document in MongoDB.
interface ICollection {
  userId: string;
  name: string;
This file has been truncated, but you can view the full file.
aws s3 cp s3://hubkit-file-preview/c5c05d8b74c73afaeb1328e1706f513a2755d46b18ac1e82f7b32a5753738504/9c73d39f-ff64-49d7-9aa3-147a932cf62e_original_1.png ./tmp/c5c05d8b74c73afaeb1328e1706f513a2755d46b18ac1e82f7b32a5753738504/9c73d39f-ff64-49d7-9aa3-147a932cf62e_original_1.png
aws s3 cp s3://hubkit-file-preview/c5c05d8b74c73afaeb1328e1706f513a2755d46b18ac1e82f7b32a5753738504/9c73d39f-ff64-49d7-9aa3-147a932cf62e_original_2.png ./tmp/c5c05d8b74c73afaeb1328e1706f513a2755d46b18ac1e82f7b32a5753738504/9c73d39f-ff64-49d7-9aa3-147a932cf62e_original_2.png
aws s3 cp s3://hubkit-file-preview/c5c05d8b74c73afaeb1328e1706f513a2755d46b18ac1e82f7b32a5753738504/9c73d39f-ff64-49d7-9aa3-147a932cf62e_original_3.png ./tmp/c5c05d8b74c73afaeb1328e1706f513a2755d46b18ac1e82f7b32a5753738504/9c73d39f-ff64-49d7-9aa3-147a932cf62e_original_3.png
aws s3 cp s3://hubkit-file-preview/c5c05d8b74c73afaeb1328e1706f513a2755d46b18ac1e82f7b32a5753738504/9c73d39f-ff64-49d7-9aa3-147a932cf62e_original_4.png ./tmp/c5c05d8b74c73afaeb1328e1706f513a2755d46b
@smcelhinney
smcelhinney / .bashrc
Last active March 15, 2021 15:23
AWS Credentials autocomplete setup.
# Append this to your ~/.bashrc or ~/.bash_profile
# Switch to a specified AWS profile globally
function aws_switch_profile() {
local profile=${1:-"default"}
export AWS_PROFILE="$profile"
}
# Setup autocomplete for the above command
setup_aws_profile_complete (){
@smcelhinney
smcelhinney / create-subnet.sh
Created December 4, 2020 12:05
Creating new subnets AWS
VPC_ID=<your-vpc-id>
SUBNET_CIDR_BLOCK=10.0.96.0/24
AVAILABILITY_ZONE=us-east-1f
SUBNET_NAME="private-lambda-$AVAILABILITY_ZONE"
SUBNET_CREATE_RESPONSE=$(aws ec2 create-subnet \
--cidr-block "$SUBNET_CIDR_BLOCK" \
--availability-zone "$AVAILABILITY_ZONE" \
--vpc-id "$VPC_ID" \
--output json)
@smcelhinney
smcelhinney / next-js-static-to-s3-gh-actions.yml
Last active December 10, 2022 20:14
Github workflow to build static Next.js site and deploy to an S3 bucket
name: Deploy to S3
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
@smcelhinney
smcelhinney / k8s-env-generator.js
Last active March 22, 2019 18:31
A Node.js script for creating Base64 encoded configMaps (secrets) from existing .env file (for Kubernetes)
const fs = require('fs');
const path = require('path');
const yaml = require('yaml');
const envFilePath = path.resolve(__dirname, '.env');
const destYamlPath = path.resolve(__dirname, 'my-secrets.yml');
const data = fs
.readFileSync(envFilePath, 'utf-8')
.split('\n')
.filter(i => !i.startsWith('#'))
export prefix="localhost"
echo "Creating Certificate '$prefix'"
echo "Creating SSL Config File"
cat <<EOF >$prefix.cnf
[ req ]
default_bits = 2048
default_keyfile = privkey.pem
distinguished_name = subject
# Credit to https://stackoverflow.com/a/41407246
Reset = "\x1b[0m"
Bright = "\x1b[1m"
Dim = "\x1b[2m"
Underscore = "\x1b[4m"
Blink = "\x1b[5m"
Reverse = "\x1b[7m"
Hidden = "\x1b[8m"
// Ordinarily, you would import this from another module...
class ObservableService {
constructor() {
this.callbacks = [];
}
subscribe(cb) {
this.callbacks.push(cb)
}
notify() {
this.callbacks.forEach(cb => {
var
gulp = require('gulp'),
$$ = require('gulp-load-plugins')(),
del = require('del'),
fs = require('fs'),
runSequence = require('run-sequence'),
server = require('./server/index'),
merge = require('event-stream').merge,
stylish = require('jshint-stylish'),
LessPluginCleanCSS = require('less-plugin-clean-css'),