Skip to content

Instantly share code, notes, and snippets.

@jdretz
jdretz / Capstone3.ipynb
Last active July 5, 2019 22:12
Created on Cognitive Class Labs
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jdretz
jdretz / ubuntu-commands.md
Last active October 22, 2019 22:13
Initial Set Up of Remote Server Running Ubuntu 18.04

Setting Up Remote Server

  1. Include SSH key when created ("Add Key", if using Linode) # I have a couple on my desktop that I use
  2. $ ssh root@[ipaddress] # Sign in to remote server
  3. $ apt-get update && apt-get upgrade # Get server up-to-date
  4. $ yes # when prompted
  5. $ hostnamectl set-hostname [new hostname] # Set hostname for server
  6. $ nano /etc/hosts ---> insert new line [ipaddress] [hostname] # In hosts file add IP address for remote server (host name from step 4), format the same as the 127.0.0.1 etc. line
  7. Save (Ctl+X), Accept (y) and exit (Enter)
  8. $ adduser [new username] # Make the user that you will sign in with normalling
  9. Enter new password and personal information
@jdretz
jdretz / mongodb-quicksetup-ubuntu.md
Last active October 22, 2019 22:09
Ubuntu 18.04 Commands for Setting Up MongoDB

MongoDB Set Up on Linode (Ubuntu 18.04)

  1. $ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 68818C72E52529D4 # Get Key
  2. $ sudo echo "deb http://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list # Create needed files
  3. $ sudo apt-get update # Reload packages
  4. $ sudo apt-get install -y mongodb-org # install MongoDB
  5. $ sudo mkdir -p /data/db # Create the db files
  6. $ sudo chown -R `id -un` /data/db # Give appropriate permissions to directories
  7. $ sudo systemctl start mongod # Start mongod process
  8. $ sudo systemctl enable mongod # Enable the process
  9. $ sudo netstat -plntu # Have mongod start on boot
@jdretz
jdretz / related-articles
Created March 3, 2021 01:33
YAML OpenAPI Specification Related Articles API
@jdretz
jdretz / subscribe.ts
Created June 15, 2022 04:25
Add a new contact to a SendGrid contact list using the SendGrid API via a Netlify Typescript Function.
import { Handler } from "@netlify/functions"
import client from "@sendgrid/client"
import { ClientRequest } from "@sendgrid/client/src/request"
const blogListId = `0350949f-5c47-4bb3-b8fb-83e848f9d8ae`
const handler: Handler = async (event, context) => {
if (event.httpMethod !== `POST`) {
return {
statusCode: 405,
@jdretz
jdretz / .eslintrc
Last active June 17, 2022 16:06
Gatsby, Typescript, MUI, ESLint, Prettier, Husky, and Lint-Staged project in VSCode development environment. Most of the scaffolding is done using the CLIs of the individual technologies when available.
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"plugins": ["@typescript-eslint"],
@jdretz
jdretz / ContactForm.tsx
Last active July 26, 2022 16:39
Gatsby Function, Sendgrid, ReactJS, Typescript, Formik, Material-UI, and useReducer. These files are from a ReactJS form built with Formik that sends data to Gatsby Function that triggers email via Sendgrid API. The workflow is built with Typescript and uses a custom useReducer hook to bundle state updates.
import { EmailOutlined } from '@mui/icons-material'
import { Box, Button, Typography } from '@mui/material'
import axios from 'axios'
import { Field, FieldProps, Form, Formik } from 'formik'
import React from 'react'
import * as Yup from 'yup'
import useHttpReducer from '../../hooks/useHttpReducer'
import useMediaQueries from '../../hooks/useMediaQueries'
import RDTextField from '../RDTextField/RDTextField'
@jdretz
jdretz / active_user.py
Last active October 17, 2023 12:49
User token authentication with FastAPI, Auth0, and Neo4j
from typing import Annotated
from neo4j.exceptions import Neo4jError
from exceptions.custom_exceptions import DatabaseError
from fastapi import Depends
from db import driver
from user.work import get_user
from user.model import User, UserInDB
from .validate_token import validate_token
from util.models.types import JWTPayload
@jdretz
jdretz / data1.ts
Created November 6, 2023 14:18
Demonstrating imperative vs. functional programming styles with the help of fp-ts library in Typescript
const data1 = [
{
id: 1,
name: 'Mug',
},
{
id: 2,
name: 'Table'
},
{