Skip to content

Instantly share code, notes, and snippets.

View kezzico's full-sized avatar

Lee Irvine kezzico

View GitHub Profile

Node.js: Express MVC

Link to sample code

Designing a Node.js/Express API following the Model-View-Controller (MVC) architectural pattern utilizing middleware is a common and effective approach.

Express.js is a popular Node.js web application framework known for its flexibility and simplicity.

A core concept that underlies much of its power and versatility is middleware.

module.exports = {
meta: {
type: 'layout', // Specify the rule type ('problem', 'suggestion', or 'layout')
fixable: 'whitespace', // Allow ESLint to fix the issues automatically
},
create: function (context) {
return {
FunctionDeclaration(node) {
const params = node.params;
for (let i = 1; i < params.length; i++) {

UEFI Windows Installer

I found it difficult to get ahold of an accurate up to date guide on how to setup Windows 10 installation media for Linux users. Everything is either geared towards people currently on Windows, or is out dated information that relys on Bootcamp and old MBR/BIOS standards no longer relevant to modern machines.

After spending days trying to set a boot flag on an MBR partition, I went back to the drawing board and did some research. I found UEFI.

🥾 UEFI is a new boot standard.

Unified Extensible Firmware Interface (UEFI) is a specification for a software program that connects a computer's firmware to its operating system (OS). UEFI is expected to eventually replace basic input/output system (BIOS) but is compatible with it.

@kezzico
kezzico / mysql-commands.md
Created August 24, 2023 21:35
Common MySQL commands

SELECT Command with WHERE Clause

SELECT * FROM customers WHERE age > 25;

This command selects all columns from the "customers" table where the age is greater than 25.

INSERT Command

@app.route('/events')
def sse():
def generate():
lipsum = '''
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed molestie sodales eros, sed vehicula tortor volutpat non. Vestibulum imperdiet porta lorem eu accumsan. Proin magna purus, vulputate nec ante vulputate, blandit sollicitudin dui. Donec cursus venenatis orci, quis placerat turpis consectetur et. Donec at ante hendrerit, consequat nibh sit amet, luctus neque. Maecenas id massa ut purus pretium fermentum sit amet nec risus. Morbi varius mi a sem lacinia, eget ornare libero aliquam. Donec sit amet nisl id neque auctor dignissim. Duis cursus condimentum enim et scelerisque. Fusce finibus malesuada lectus, sed vehicula lorem molestie nec. In hac habitasse platea dictumst. Nunc ipsum dolor, viverra et pharetra eu, egestas volutpat tellus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aliquam erat volutpat. Phasellus tincidunt viverra lorem, id aliquet quam aliquam sit amet.
Pellentesque h
@kezzico
kezzico / make-a-mermaid-from-paste.sh
Created August 11, 2023 17:28
MacOS users can use pbpaste to make diagrams
#!/bin/zsh
out=$1
if [[ -z $out ]]; then
echo "usage [outputfile]"
fi
pbpaste | mmdc - -o $out --width 1600 --theme dark -b black;
@kezzico
kezzico / python-virtual-environment.md
Last active October 30, 2023 20:07
Python: Setup a Virtual Environment

Python: Virtual Environments

A virtual environment is a sandbox for packages. Pip's default behavior is system level. However, packages installed in different virtual environment do not co-mingle. The ideal is for each project to have its own distinct virtual environment.

This is especially important on team projects. The virtual environment provides a means to a standard for packages. Identifying project dependencies and which package versions have already been tested against the code.

HOWTO:

It is common to see virtual environments named after the project it represents. The virtual enviromment in this sample will be called venv.

@kezzico
kezzico / file.c
Created August 4, 2023 23:27
client / server UDP communication in C
//Program by Lee Irvine
// client.c
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <string.h>
#include <stdlib.h>
#include <arpa/inet.h>
@kezzico
kezzico / MYSQL.py
Last active August 24, 2023 21:31
Python MySQL Wrapper
# MYSQL.py
import mysql.connector
from dotenv import dotenv_values
config = dotenv_values(".env") # config = {"USER": "foo", "EMAIL": "foo@example.org"}
db_config = {
'user': config.get("DATABASE_USER"),
# flaskapp.py
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route("/")
def index():
return "Hello World"
@app.route("/user/data")