Skip to content

Instantly share code, notes, and snippets.

View AlexMercedCoder's full-sized avatar
🎯
Focusing

Alex Merced AlexMercedCoder

🎯
Focusing
View GitHub Profile
@AlexMercedCoder
AlexMercedCoder / memo.js
Created April 17, 2021 03:53
example of memoization in javascript
////////////////////////////////////
// Example of Memoization by Alex Merced of AlexMercedCoder.com
///////////////////////////////////
const addNums = (x,y) => x + y
const createMemo = (thefunc) => {
const cache = {}
@AlexMercedCoder
AlexMercedCoder / nestedjs.js
Created April 17, 2021 13:52
Nest Data Structures in Javascript
///////////////////////////////
// Array of Objects
//////////////////////////////
console.log("------------------------------------")
const dogs = [
{name: "Spot", age: 6},
{name: "Fluffy", age: 6},
{name: "Clifford", age: 6},
{name: "Lassi", age: 6},
]
@AlexMercedCoder
AlexMercedCoder / pattern.js
Created April 18, 2021 14:03
Pattern Matching Javascript
// Example String
const stringy = "| ohtml | odiv | Hello World | cdiv | chtml |";
// Function that matches a string against a pattern
const matcher = (str) => {
// declare some variables
let tag;
let split;

webpack.config

const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");

module.exports = (env) => {
  const { production } = env ? env : { production: false };
@AlexMercedCoder
AlexMercedCoder / reactwebpack.md
Created April 19, 2021 14:06
Intro to Webpack for React Settings

webpack.config.json

const path = require("path")
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");

const config = {
    mode: process.env.NODE_ENV ? process.env.NODE_ENV : "development",
    module: {
@AlexMercedCoder
AlexMercedCoder / python_curr.md
Last active May 22, 2021 14:09
Self-Guided: From 0 to Flask Curriculum

Goal

This is a 6 day self-paced curriculum to learn the python language and the basics of the Flask Web Framework.

Day 1 - Starting Python

@AlexMercedCoder
AlexMercedCoder / ExpressEJS.js
Last active June 14, 2023 14:39
Reference For ExpressJS and Mongo
/////////////////////////////////
// ./models/connection.js
/////////////////////////////////
// PURPOSE OF THIS FILE TO CONNECT TO MONGO AND EXPORT CONNECTED MONGO OBJECT
require("dotenv").config(); // Loads variables from .env into the process.env object
const mongoose = require('mongoose'); // import a fresh mongoose object
//connect to our db
mongoose.connect(
@AlexMercedCoder
AlexMercedCoder / dom.js
Created August 10, 2021 23:23
jQuery and Plain Vanilla DOM side by side
///////////////////////////////////////
// Selecting an element by element, class, id
///////////////////////////////////////
// PLAIN VANILLA JS
const h1 = document.querySelector("h1");
const byClass = document.querySelector(".class");
const byId = document.querySelector("#id");
// jQuery
const $h1 = $("h1");
const $byClass = $(".class");
@AlexMercedCoder
AlexMercedCoder / expressmongo.js
Created August 13, 2021 15:25
Ways of Writing Express/MongoDB routes (Callback, Async/Await, .then)
///////////////////////////////////////
// Writing the Index Route all three ways
// (Callback,.then, async/await)
///////////////////////////////////////
// callback
app.get("/dogs", (req, res) => {
Dog.find({}, (err, data) =>
err ? res.status(400).json(err) : res.json(data)
);