Skip to content

Instantly share code, notes, and snippets.

View jmcdo29's full-sized avatar
📝
Ogma for the win

Jay McDoniel jmcdo29

📝
Ogma for the win
View GitHub Profile
@jmcdo29
jmcdo29 / gist:3b1c0577071cbcb139b8f2babbe3d723
Created September 18, 2020 04:39
Webpacked Orgnaised JavaScript
This file has been truncated, but you can view the full file.
// ┌───────────────────────┬───────────────┬────────────┬───────────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬────────────────────┬───────────────────────────────────────┐
// │ Operators │ Brackets │ Keywords │ Numbers │ Strings │ Other primitives │ Variables │
@jmcdo29
jmcdo29 / resume.json
Last active July 28, 2019 03:01
Resume of Jay McDoniel working with JSON Resume Schema
{
"basics": {
"name": "Jay McDoniel",
"label": "Software Developer",
"email": "jmcdo29@gmail.com",
"phone": "(432) 269-9800",
"website": "http://jaymcdoniel.dev",
"summary": "Jay comes from Lynnwood Washington. He has earned his degree from Texas A&M University. He has worked at Revature and Infosys as a Salesforce practitioner and at Texas A&M as a student IT worker. His focuses are on NodeJS, especially using NestJS, and Angular, but he also enjoys work with Apex and Salesforce.",
"location": {
"address": "18123 36th Ave W Apt N205",
@jmcdo29
jmcdo29 / Explaination.md
Created July 17, 2019 01:02
tsconfig-paths bootstrap file to make registering paths work without problem

I've always had trouble using the given node -r tsconfig-paths/register path/to/main function from the command line, my paths never import correctly and I always seem to have an error when running after a build. After doing a bunch of digging around through packages and StackOverflow Q&A's I finally found a way to use tsconfig-paths programatically.

The tsconfig-bootstrap.js file makes use of tsconfig-pathsto register the paths from the compiler, and more than likely does exactly what tsconfig-paths/register is supposed to do. After requiring your tsconfig file you can access your baseUrl and paths via the JSON scheme of the config file to 100% programatically set your path imports to be correct, so that is anything changes in your config file this function doesn't need any chagning!

After you have the function set up, jsut add the following segment to your npm start command (whatever you have it called) and watch as your server fires up seamlessly:

# normal start without bootstrap
node
@jmcdo29
jmcdo29 / gist:f9d4d3effc2d55996341ce18fe0cb6d3
Last active September 20, 2024 09:28
Testing Observables with Jest

I've run into trouble in the past with testing observables, so I figured I would make myself a gist to help myself remember, and to help others who find it.

Observables are rather tricky to test in general as they are made to be asynchronous and act like a stream, and up until recently it was acceptable to pass a next, error, and complete callback function, but now that method is bieng deprecated in favor of Observers. Fear not! An Observer is just like the three callbacks rolled into a signle object, plus other fields you would like to add :).

Say that we have the following Observable

const numbersArray = from([1,2,3,4,5]);
$ nest g mo test
TypeError: Cannot read property 'length' of undefined
at MetadataManager.insertSymbolToMetadata (C:\Users\jay.mcdoniel\AppData\Roaming\npm\node_modules\@nestjs\cli\node_modules\@nestjs\schematics\utils\metadata.manager.js:104:33)
at MetadataManager.insert (C:\Users\jay.mcdoniel\AppData\Roaming\npm\node_modules\@nestjs\cli\node_modules\@nestjs\schematics\utils\metadata.manager.js:41:25)
at ModuleMetadataDeclarator.declare (C:\Users\jay.mcdoniel\AppData\Roaming\npm\node_modules\@nestjs\cli\node_modules\@nestjs\schematics\utils\module-metadata.declarator.js:7:34)
at ModuleDeclarator.declare (C:\Users\jay.mcdoniel\AppData\Roaming\npm\node_modules\@nestjs\cli\node_modules\@nestjs\schematics\utils\module.declarator.js:14:33)
at C:\Users\jay.mcdoniel\AppData\Roaming\npm\node_modules\@nestjs\cli\node_modules\@nestjs\schematics\lib\module\module.factory.js:50:51
at MergeMapSubscriber.input.pipe.operators_1.mergeMap.inputTree [as project] (C:\Users\jay.mcdoniel\AppData\Roaming\n