├── toys.sqlite ├── ColorListAPI_rails ├── log │ └── .keep ├── tmp │ ├── .keep │ ├── pids │ │ └── .keep │ └── storage │ │ └── .keep ├── storage │ └── .keep ├── vendor │ └── .keep ├── lib │ └── tasks │ │ └── .keep ├── test │ ├── mailers │ │ └── .keep │ ├── models │ │ ├── .keep │ │ └── color_test.rb │ ├── controllers │ │ ├── .keep │ │ └── colors_controller_test.rb │ ├── integration │ │ └── .keep │ ├── fixtures │ │ ├── files │ │ │ └── .keep │ │ └── colors.yml │ ├── channels │ │ └── application_cable │ │ │ └── connection_test.rb │ └── test_helper.rb ├── .ruby-version ├── app │ ├── models │ │ ├── concerns │ │ │ └── .keep │ │ ├── color.rb │ │ └── application_record.rb │ ├── controllers │ │ ├── concerns │ │ │ └── .keep │ │ └── application_controller.rb │ ├── views │ │ └── layouts │ │ │ ├── mailer.text.erb │ │ │ └── mailer.html.erb │ ├── channels │ │ └── application_cable │ │ │ ├── channel.rb │ │ │ └── connection.rb │ ├── mailers │ │ └── application_mailer.rb │ └── jobs │ │ └── application_job.rb ├── bin │ ├── rake │ ├── rails │ └── setup ├── public │ └── robots.txt ├── config │ ├── environment.rb │ ├── boot.rb │ ├── cable.yml │ ├── routes.rb │ ├── initializers │ │ ├── filter_parameter_logging.rb │ │ ├── cors.rb │ │ └── inflections.rb │ ├── credentials.yml.enc │ ├── database.yml │ ├── locales │ │ └── en.yml │ ├── application.rb │ └── storage.yml ├── config.ru ├── Rakefile ├── .gitattributes ├── db │ ├── migrate │ │ └── 20240310230244_create_colors.rb │ ├── seeds.rb │ └── schema.rb ├── README.md ├── .gitignore └── Gemfile ├── FlaskDemo ├── .gitignore ├── fetch_temp_data.py ├── .dockerignore ├── form_with_get.html ├── form_with_post.html ├── fly.toml ├── templates │ ├── temperature.j2 │ └── temperature_and_query.j2 └── all_routes.html ├── FlaskImpl ├── http_socket.py ├── fetch_temp_data.py ├── README.md └── test.py ├── SimpleHTTPServer ├── http_socket.py ├── Java │ └── cgi-bin │ │ ├── colorDemo.php │ │ ├── hello.pl │ │ ├── hello_html.pl │ │ └── mean.rb ├── form_with_get.html ├── form_with_post.html ├── all_routes.html └── fetch_temp_data.py ├── ReactJSXIntro ├── runBabel ├── clientSideDomCreation.html ├── README.md ├── jsx1.jsx ├── reactDomCreation.html ├── package.json ├── jsx2.html ├── jsx2.jsx ├── clientSideDomCreation.js ├── reactDomCreation.js └── complexDOMcreateElement.js ├── ColorListAPI ├── dbInit.js ├── colors.sqlite ├── colors.test.sqlite └── package.json ├── ExpressIntro ├── .gitignore ├── .dockerignore ├── views │ ├── firstView.ejs │ └── multTable.ejs ├── images │ ├── buzz2.jpeg │ ├── bicycle.png │ └── catTyping.gif ├── hello.html ├── README.md ├── __pycache__ │ └── mini_express.cpython-312.pyc ├── package.json ├── fly.toml ├── .eslintrc.js ├── simple_sendHTML.js ├── multForm.html ├── use_mini_express.py ├── first_sendHTML.js └── Dockerfile ├── ExpressMVC ├── README.md ├── .gitignore ├── public │ ├── AndrewAndSpots.jpg │ ├── LifeconnectTeam.jpg │ └── ajax1.html ├── dbTest.js ├── views │ ├── toyNew.ejs │ ├── toyEdit.ejs │ ├── showSomePictures.ejs │ ├── showUser.ejs │ ├── selectUser.ejs │ ├── toyShow.ejs │ └── toyIndex.ejs ├── controllers │ └── UserController.js ├── package.json ├── .eslintrc.js ├── models │ ├── User.js │ └── Toy.js ├── test │ └── MemoryToyDB.test.js └── db │ └── MemoryToyDB.js ├── ExpressSession ├── db │ ├── initDB.js │ └── dbTest.js ├── README.md ├── .gitignore ├── views │ ├── toyNew.ejs │ ├── toyEdit.ejs │ ├── login.ejs │ ├── toyShow.ejs │ └── toyIndex.ejs ├── package.json ├── .eslintrc.js ├── models │ ├── User.js │ └── Toy.js └── controllers │ └── LoginController.js ├── ExpressMVCSimple ├── README.md ├── db │ ├── initDB.js │ └── dbTest.js ├── .dockerignore ├── .gitignore ├── views │ ├── toyEdit.ejs │ ├── toyNew.ejs │ ├── toyShow.ejs │ └── toyIndex.ejs ├── package.json ├── fly.toml ├── .eslintrc.js ├── Dockerfile ├── models │ ├── User.js │ └── Toy.js └── index.js ├── ReactRecipe ├── package.json ├── README.md ├── recipe1.html ├── recipe2.html ├── recipe3.html ├── stateUsingClosures.js └── exampleComponent1.jsx ├── SimpleWebClient ├── .gitignore ├── hard_coded_http_request.py ├── README.md └── Java │ ├── BasicHTTPTransaction.java │ └── DebugHTTPTransaction.java ├── ExpressMVCSqlitePromises ├── db │ ├── initDB.js │ └── dbTest.js ├── README.md ├── .gitignore ├── views │ ├── toyNew.ejs │ ├── toyEdit.ejs │ ├── toyShow.ejs │ └── toyIndex.ejs ├── package.json ├── .eslintrc.js ├── models │ ├── User.js │ └── Toy.js ├── test │ └── MemoryToyDB.test.js └── index.js ├── ColorList1_fetch ├── public │ ├── robots.txt │ ├── favicon.ico │ ├── logo192.png │ ├── logo512.png │ ├── colorData.json │ └── manifest.json ├── src │ ├── Star.jsx │ ├── setupTests.js │ ├── index.css │ ├── reportWebVitals.js │ ├── Color.jsx │ ├── StarRating.jsx │ ├── index.js │ ├── ColorList.jsx │ └── NewColorForm.jsx ├── README.md ├── .gitignore └── package.json ├── ColorList2_edit ├── README.md ├── public │ ├── robots.txt │ ├── favicon.ico │ ├── logo192.png │ ├── logo512.png │ ├── colorData.json │ └── manifest.json ├── src │ ├── Star.jsx │ ├── setupTests.js │ ├── reportWebVitals.js │ ├── Color.jsx │ ├── StarRating.jsx │ ├── index.js │ ├── index.css │ ├── ColorList.jsx │ └── NewColorForm.jsx ├── .gitignore └── package.json ├── ColorList3_routing ├── README.md ├── public │ ├── robots.txt │ ├── favicon.ico │ ├── logo192.png │ ├── logo512.png │ ├── colorData.json │ └── manifest.json ├── src │ ├── Star.jsx │ ├── setupTests.js │ ├── reportWebVitals.js │ ├── ColorDetails.jsx │ ├── Color.jsx │ ├── StarRating.jsx │ ├── index.js │ ├── ColorList.jsx │ ├── index.css │ ├── Color.test.js │ ├── NewColorForm.jsx │ └── Tabs.js ├── .gitignore ├── .eslintrc.json └── package.json ├── ExpressMVCSqliteCallbacks ├── README.md ├── db │ ├── initDB.js │ ├── dbTest.js │ └── callbacksRequired.js ├── .gitignore ├── views │ ├── toyNew.ejs │ ├── toyEdit.ejs │ ├── toyShow.ejs │ └── toyIndex.ejs ├── package.json ├── .eslintrc.js ├── models │ ├── User.js │ └── Toy.js ├── test │ └── MemoryToyDB.test.js └── index.js ├── Fly └── StaticOnly │ ├── Dockerfile │ ├── fly.toml │ └── public │ ├── goodbye.html │ └── index.html ├── .gitignore ├── Templating ├── runJinja.py ├── countToTen.php ├── colorDemo_jinja.html ├── colorDemo.pug ├── colorDemo.haml ├── colorDemo.html.erb └── colorDemo.php ├── Cookies ├── PHP │ ├── startSession.php │ ├── readme.txt │ └── lookForCookie.php ├── views │ ├── repeatVisit.ejs │ ├── firstVisit.ejs │ └── cookieList.ejs ├── package.json └── .eslintrc.js ├── PretendJest ├── MyController.js ├── package.json ├── MyController.test.js └── PretendJest.js ├── JavaScriptDOM ├── package.json ├── .eslintrc.js ├── rawDomNavigation.html ├── hideableList.html └── placementOfScript.html ├── ExpressRouting ├── package.json ├── openForBusiness.js └── .eslintrc.js ├── JavaScriptAsADT ├── PrintHelper.js ├── dog.html └── Dog.js ├── JavaScriptBasics ├── dynamicTypingAndFunctions.js ├── sortingStudents.js ├── Dog.js └── dynamicTyping.js ├── Bootstrap ├── example.scss └── widthTest.erb ├── JavaScriptAsynchronous ├── timerPromise.js ├── hiLo.mjs ├── timerPromiseAwait.mjs ├── callbackHell.js ├── asynchronous1.js └── timerPromiseWithFeedback.mjs └── HTMLForms └── Flask └── app.py /toys.sqlite: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ColorListAPI_rails/log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ColorListAPI_rails/tmp/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /FlaskDemo/.gitignore: -------------------------------------------------------------------------------- 1 | **/venv -------------------------------------------------------------------------------- /ColorListAPI_rails/storage/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ColorListAPI_rails/tmp/pids/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ColorListAPI_rails/vendor/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ColorListAPI_rails/lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ColorListAPI_rails/test/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ColorListAPI_rails/test/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ColorListAPI_rails/tmp/storage/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ColorListAPI_rails/test/controllers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ColorListAPI_rails/test/integration/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ColorListAPI_rails/.ruby-version: -------------------------------------------------------------------------------- 1 | ruby-3.1.2 2 | -------------------------------------------------------------------------------- /ColorListAPI_rails/app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ColorListAPI_rails/test/fixtures/files/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ColorListAPI_rails/app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /FlaskImpl/http_socket.py: -------------------------------------------------------------------------------- 1 | ../SimpleHTTPServer/http_socket.py -------------------------------------------------------------------------------- /FlaskDemo/fetch_temp_data.py: -------------------------------------------------------------------------------- 1 | ../SimpleHTTPServer/fetch_temp_data.py -------------------------------------------------------------------------------- /FlaskImpl/fetch_temp_data.py: -------------------------------------------------------------------------------- 1 | ../SimpleHTTPServer/fetch_temp_data.py -------------------------------------------------------------------------------- /SimpleHTTPServer/http_socket.py: -------------------------------------------------------------------------------- 1 | ../SimpleWebClient/http_socket.py -------------------------------------------------------------------------------- /ColorListAPI_rails/app/views/layouts/mailer.text.erb: -------------------------------------------------------------------------------- 1 | <%= yield %> 2 | -------------------------------------------------------------------------------- /SimpleHTTPServer/Java/cgi-bin/colorDemo.php: -------------------------------------------------------------------------------- 1 | ../../Templating/colorDemo.php -------------------------------------------------------------------------------- /ReactJSXIntro/runBabel: -------------------------------------------------------------------------------- 1 | npx babel --presets=@babel/preset-react jsx1.jsx 2 | -------------------------------------------------------------------------------- /SimpleHTTPServer/Java/cgi-bin/hello.pl: -------------------------------------------------------------------------------- 1 | print "Hello, World! (from perl)\n" 2 | -------------------------------------------------------------------------------- /ColorListAPI/dbInit.js: -------------------------------------------------------------------------------- 1 | let ColorDB = require('./ColorDB'); 2 | ColorDB.initialize(); -------------------------------------------------------------------------------- /ColorListAPI_rails/app/models/color.rb: -------------------------------------------------------------------------------- 1 | class Color < ApplicationRecord 2 | end 3 | -------------------------------------------------------------------------------- /FlaskDemo/.dockerignore: -------------------------------------------------------------------------------- 1 | # flyctl launch added from .gitignore 2 | **/**/venv 3 | fly.toml 4 | -------------------------------------------------------------------------------- /ExpressIntro/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | node_modules 3 | build 4 | npm-debug.log 5 | .env 6 | .DS_Store 7 | -------------------------------------------------------------------------------- /ExpressMVC/README.md: -------------------------------------------------------------------------------- 1 | A simple `Express` app that show the basic CRUD operations for a Toy model. -------------------------------------------------------------------------------- /ExpressSession/db/initDB.js: -------------------------------------------------------------------------------- 1 | let SqliteToyDB = require('./SqliteToyDB') 2 | SqliteToyDB.initialize() -------------------------------------------------------------------------------- /ExpressIntro/.dockerignore: -------------------------------------------------------------------------------- 1 | *~ 2 | node_modules 3 | build 4 | npm-debug.log 5 | .env 6 | .DS_Store 7 | -------------------------------------------------------------------------------- /ExpressIntro/views/firstView.ejs: -------------------------------------------------------------------------------- 1 |

Hello, there <%= username %>

2 |

Not a bad first page.

-------------------------------------------------------------------------------- /ExpressMVCSimple/README.md: -------------------------------------------------------------------------------- 1 | A simple `Express` app that show the basic CRUD operations for a Toy model. -------------------------------------------------------------------------------- /ExpressMVCSimple/db/initDB.js: -------------------------------------------------------------------------------- 1 | let SqliteToyDB = require('./SqliteToyDB') 2 | SqliteToyDB.initialize() -------------------------------------------------------------------------------- /ExpressSession/README.md: -------------------------------------------------------------------------------- 1 | A simple `Express` app that show the basic CRUD operations for a Toy model. -------------------------------------------------------------------------------- /ReactRecipe/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "devDependencies": { 3 | "babel-cli": "^6.26.0" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /SimpleWebClient/.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | opt.* 3 | opts.* 4 | out 5 | buzz1.jpg 6 | __pycache__ 7 | 8 | -------------------------------------------------------------------------------- /ExpressMVCSqlitePromises/db/initDB.js: -------------------------------------------------------------------------------- 1 | let SqliteToyDB = require('./SqliteToyDB') 2 | SqliteToyDB.initialize() -------------------------------------------------------------------------------- /ColorList1_fetch/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /ColorList2_edit/README.md: -------------------------------------------------------------------------------- 1 | # ColorList with Edit (version 2) 2 | 3 | This adds edit capabilities to ColorList1 -------------------------------------------------------------------------------- /ColorList2_edit/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /ColorList3_routing/README.md: -------------------------------------------------------------------------------- 1 | # ColorList with Edit (version 2) 2 | 3 | This adds edit capabilities to ColorList1 -------------------------------------------------------------------------------- /ExpressMVC/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | node_modules 3 | build 4 | npm-debug.log 5 | .env 6 | .DS_Store 7 | *.sqlite 8 | -------------------------------------------------------------------------------- /ExpressMVCSqliteCallbacks/README.md: -------------------------------------------------------------------------------- 1 | A simple `Express` app that show the basic CRUD operations for a Toy model. -------------------------------------------------------------------------------- /ExpressMVCSqliteCallbacks/db/initDB.js: -------------------------------------------------------------------------------- 1 | let SqliteToyDB = require('./SqliteToyDB') 2 | SqliteToyDB.initialize() -------------------------------------------------------------------------------- /ExpressMVCSqlitePromises/README.md: -------------------------------------------------------------------------------- 1 | A simple `Express` app that show the basic CRUD operations for a Toy model. -------------------------------------------------------------------------------- /ExpressSession/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | node_modules 3 | build 4 | npm-debug.log 5 | .env 6 | .DS_Store 7 | *.sqlite 8 | -------------------------------------------------------------------------------- /ColorList3_routing/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /ExpressMVCSimple/.dockerignore: -------------------------------------------------------------------------------- 1 | *~ 2 | node_modules 3 | build 4 | npm-debug.log 5 | .env 6 | .DS_Store 7 | *.sqlite 8 | -------------------------------------------------------------------------------- /ExpressMVCSimple/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | node_modules 3 | build 4 | npm-debug.log 5 | .env 6 | .DS_Store 7 | *.sqlite 8 | -------------------------------------------------------------------------------- /ExpressMVCSqlitePromises/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | node_modules 3 | build 4 | npm-debug.log 5 | .env 6 | .DS_Store 7 | *.sqlite 8 | -------------------------------------------------------------------------------- /ColorListAPI/colors.sqlite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kurmasz-SampleCode/CIS371-SampleCode/HEAD/ColorListAPI/colors.sqlite -------------------------------------------------------------------------------- /ColorListAPI_rails/app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::API 2 | end 3 | -------------------------------------------------------------------------------- /ExpressMVCSqliteCallbacks/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | node_modules 3 | build 4 | npm-debug.log 5 | .env 6 | .DS_Store 7 | *.sqlite 8 | -------------------------------------------------------------------------------- /ColorListAPI_rails/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative "../config/boot" 3 | require "rake" 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /ExpressIntro/images/buzz2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kurmasz-SampleCode/CIS371-SampleCode/HEAD/ExpressIntro/images/buzz2.jpeg -------------------------------------------------------------------------------- /ColorListAPI/colors.test.sqlite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kurmasz-SampleCode/CIS371-SampleCode/HEAD/ColorListAPI/colors.test.sqlite -------------------------------------------------------------------------------- /ColorListAPI_rails/app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | primary_abstract_class 3 | end 4 | -------------------------------------------------------------------------------- /ExpressIntro/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

Hello

5 | 6 | This is a static HTML file. 7 | 8 | 9 | -------------------------------------------------------------------------------- /ExpressIntro/images/bicycle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kurmasz-SampleCode/CIS371-SampleCode/HEAD/ExpressIntro/images/bicycle.png -------------------------------------------------------------------------------- /ExpressIntro/images/catTyping.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kurmasz-SampleCode/CIS371-SampleCode/HEAD/ExpressIntro/images/catTyping.gif -------------------------------------------------------------------------------- /Fly/StaticOnly/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3 2 | 3 | WORKDIR public 4 | 5 | COPY public . 6 | 7 | CMD ["python", "-m", "http.server", "8080"] -------------------------------------------------------------------------------- /ColorList1_fetch/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kurmasz-SampleCode/CIS371-SampleCode/HEAD/ColorList1_fetch/public/favicon.ico -------------------------------------------------------------------------------- /ColorList1_fetch/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kurmasz-SampleCode/CIS371-SampleCode/HEAD/ColorList1_fetch/public/logo192.png -------------------------------------------------------------------------------- /ColorList1_fetch/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kurmasz-SampleCode/CIS371-SampleCode/HEAD/ColorList1_fetch/public/logo512.png -------------------------------------------------------------------------------- /ColorList2_edit/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kurmasz-SampleCode/CIS371-SampleCode/HEAD/ColorList2_edit/public/favicon.ico -------------------------------------------------------------------------------- /ColorList2_edit/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kurmasz-SampleCode/CIS371-SampleCode/HEAD/ColorList2_edit/public/logo192.png -------------------------------------------------------------------------------- /ColorList2_edit/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kurmasz-SampleCode/CIS371-SampleCode/HEAD/ColorList2_edit/public/logo512.png -------------------------------------------------------------------------------- /ColorListAPI_rails/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | -------------------------------------------------------------------------------- /ColorList3_routing/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kurmasz-SampleCode/CIS371-SampleCode/HEAD/ColorList3_routing/public/favicon.ico -------------------------------------------------------------------------------- /ColorList3_routing/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kurmasz-SampleCode/CIS371-SampleCode/HEAD/ColorList3_routing/public/logo192.png -------------------------------------------------------------------------------- /ColorList3_routing/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kurmasz-SampleCode/CIS371-SampleCode/HEAD/ColorList3_routing/public/logo512.png -------------------------------------------------------------------------------- /ExpressMVC/public/AndrewAndSpots.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kurmasz-SampleCode/CIS371-SampleCode/HEAD/ExpressMVC/public/AndrewAndSpots.jpg -------------------------------------------------------------------------------- /ExpressMVC/public/LifeconnectTeam.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kurmasz-SampleCode/CIS371-SampleCode/HEAD/ExpressMVC/public/LifeconnectTeam.jpg -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | *~ 3 | **/.DS_Store 4 | **/node_modules 5 | build 6 | npm-debug.log 7 | .env 8 | **/__pycache__ 9 | **/venv 10 | 11 | -------------------------------------------------------------------------------- /ColorListAPI_rails/app/channels/application_cable/channel.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Channel < ActionCable::Channel::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /Templating/runJinja.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from jinja2 import Template 3 | 4 | input = sys.stdin.read() 5 | template = Template(input) 6 | print(template.render()) 7 | -------------------------------------------------------------------------------- /ColorListAPI_rails/app/channels/application_cable/connection.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Connection < ActionCable::Connection::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /Cookies/PHP/startSession.php: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | I just started a session. Check your cookies. 8 | 9 | { 3 | let rows = await SqliteToyDB.all() 4 | console.log(rows) 5 | } 6 | main() -------------------------------------------------------------------------------- /ColorListAPI_rails/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path("../config/application", __dir__) 3 | require_relative "../config/boot" 4 | require "rails/commands" 5 | -------------------------------------------------------------------------------- /ColorListAPI_rails/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require_relative "application" 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /ColorListAPI_rails/test/models/color_test.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | 3 | class ColorTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /ColorListAPI_rails/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require_relative "config/environment" 4 | 5 | run Rails.application 6 | Rails.application.load_server 7 | -------------------------------------------------------------------------------- /Cookies/views/repeatVisit.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Welcome Back

4 | 5 |

Welcome back, <%= name %>.

6 | 7 |

This is visit number <%= visitNum %> for you.

8 | 9 | 10 | -------------------------------------------------------------------------------- /ExpressSession/db/dbTest.js: -------------------------------------------------------------------------------- 1 | let SqliteToyDB = require('./SqliteToyDB') 2 | console.log('sqliteToyDB') 3 | console.log(SqliteToyDB) 4 | let main = async() => { 5 | let rows = await SqliteToyDB.allToys() 6 | console.log(rows) 7 | } 8 | main() -------------------------------------------------------------------------------- /ReactJSXIntro/clientSideDomCreation.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
Web page to go here
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /ExpressMVCSimple/db/dbTest.js: -------------------------------------------------------------------------------- 1 | let SqliteToyDB = require('./SqliteToyDB') 2 | console.log('sqliteToyDB') 3 | console.log(SqliteToyDB) 4 | let main = async() => { 5 | let rows = await SqliteToyDB.allToys() 6 | console.log(rows) 7 | } 8 | main() -------------------------------------------------------------------------------- /ColorListAPI_rails/config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) 2 | 3 | require "bundler/setup" # Set up gems listed in the Gemfile. 4 | require "bootsnap/setup" # Speed up boot time by caching expensive operations. 5 | -------------------------------------------------------------------------------- /Cookies/views/firstVisit.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Hello

4 | 5 |

It looks like you are new around here. Welcome.

6 | 7 |

I think I'll call you <%= nickname %>.

8 | 9 | 10 | -------------------------------------------------------------------------------- /ExpressMVCSqliteCallbacks/db/dbTest.js: -------------------------------------------------------------------------------- 1 | let SqliteToyDB = require('./SqliteToyDB') 2 | console.log('sqliteToyDB') 3 | console.log(SqliteToyDB) 4 | let main = async() => { 5 | let rows = await SqliteToyDB.allToys() 6 | console.log(rows) 7 | } 8 | main() -------------------------------------------------------------------------------- /ExpressMVCSqlitePromises/db/dbTest.js: -------------------------------------------------------------------------------- 1 | let SqliteToyDB = require('./SqliteToyDB') 2 | console.log('sqliteToyDB') 3 | console.log(SqliteToyDB) 4 | let main = async() => { 5 | let rows = await SqliteToyDB.allToys() 6 | console.log(rows) 7 | } 8 | main() -------------------------------------------------------------------------------- /ColorListAPI_rails/Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require_relative "config/application" 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /ColorList1_fetch/src/Star.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { FaStar } from "react-icons/fa"; 3 | 4 | export default function Star({ selected = false, onStarClicked = f => f }) { 5 | return ; 6 | } 7 | -------------------------------------------------------------------------------- /ColorList2_edit/src/Star.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { FaStar } from "react-icons/fa"; 3 | 4 | export default function Star({ selected = false, onStarClicked = f => f }) { 5 | return ; 6 | } 7 | -------------------------------------------------------------------------------- /ColorList3_routing/src/Star.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { FaStar } from 'react-icons/fa' 3 | 4 | export default function Star({ selected = false, onStarClicked = f => f }) { 5 | return 6 | } 7 | -------------------------------------------------------------------------------- /ColorListAPI_rails/config/cable.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: async 3 | 4 | test: 5 | adapter: test 6 | 7 | production: 8 | adapter: redis 9 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> 10 | channel_prefix: color_list_api_rails_production 11 | -------------------------------------------------------------------------------- /PretendJest/MyController.js: -------------------------------------------------------------------------------- 1 | class MyController { 2 | 3 | constructor(db_in) { 4 | this.db = db_in 5 | } 6 | 7 | index(res) { 8 | const data = this.db.getData() 9 | res.render(data) 10 | } 11 | } 12 | 13 | module.exports = MyController -------------------------------------------------------------------------------- /ColorList1_fetch/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /ColorList2_edit/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /ColorList3_routing/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom' 6 | -------------------------------------------------------------------------------- /ColorListAPI_rails/.gitattributes: -------------------------------------------------------------------------------- 1 | # See https://git-scm.com/docs/gitattributes for more about git attribute files. 2 | 3 | # Mark the database schema as having been generated. 4 | db/schema.rb linguist-generated 5 | 6 | # Mark any vendored files as having been vendored. 7 | vendor/* linguist-vendored 8 | -------------------------------------------------------------------------------- /FlaskDemo/form_with_get.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Get the Temperature

4 | 5 |
6 | 7 | 8 |
9 | 10 | -------------------------------------------------------------------------------- /SimpleHTTPServer/form_with_get.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Get the Temperature

4 | 5 |
6 | 7 | 8 |
9 | 10 | -------------------------------------------------------------------------------- /ExpressMVC/views/toyNew.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 |

New Toy

13 | 14 | <%- include('toyForm') %> 15 | 16 | Back 17 | 18 | -------------------------------------------------------------------------------- /FlaskDemo/form_with_post.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Get the Temperature

4 | 5 |
6 | 7 | 8 |
9 | 10 | -------------------------------------------------------------------------------- /ExpressMVC/views/toyEdit.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 |

Edit Toy

13 | 14 | <%- include('toyForm') %> 15 | 16 | List 17 | 18 | -------------------------------------------------------------------------------- /ExpressSession/views/toyNew.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 |

New Toy

13 | 14 | <%- include('toyForm') %> 15 | 16 | Back 17 | 18 | -------------------------------------------------------------------------------- /SimpleHTTPServer/Java/cgi-bin/hello_html.pl: -------------------------------------------------------------------------------- 1 | use POSIX; 2 | 3 | my $time = strftime "%H:%M", localtime time; 4 | 5 | print < 7 | 8 |

Hello, World!

9 | 10 |

At the tone time time (at the server) will be $time.

11 | 12 | (from perl) 13 | 14 | 15 | HERE 16 | -------------------------------------------------------------------------------- /ColorListAPI_rails/test/fixtures/colors.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 2 | 3 | one: 4 | title: MyString 5 | uuid: MyString 6 | color: 1 7 | rating: 1 8 | 9 | two: 10 | title: MyString 11 | uuid: MyString 12 | color: 1 13 | rating: 1 14 | -------------------------------------------------------------------------------- /ExpressMVCSimple/views/toyEdit.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 |

Edit Toy

13 | 14 | <%- include('toyForm') %> 15 | 16 | List 17 | 18 | -------------------------------------------------------------------------------- /ExpressMVCSimple/views/toyNew.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 |

New Toy

13 | 14 | <%- include('toyForm') %> 15 | 16 | Back 17 | 18 | -------------------------------------------------------------------------------- /ExpressSession/views/toyEdit.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 |

Edit Toy

13 | 14 | <%- include('toyForm') %> 15 | 16 | List 17 | 18 | -------------------------------------------------------------------------------- /SimpleHTTPServer/form_with_post.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Get the Temperature

4 | 5 |
6 | 7 | 8 |
9 | 10 | -------------------------------------------------------------------------------- /ExpressMVCSqliteCallbacks/views/toyNew.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 |

New Toy

13 | 14 | <%- include('toyForm') %> 15 | 16 | Back 17 | 18 | -------------------------------------------------------------------------------- /ExpressMVCSqlitePromises/views/toyNew.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 |

New Toy

13 | 14 | <%- include('toyForm') %> 15 | 16 | Back 17 | 18 | -------------------------------------------------------------------------------- /ExpressMVCSqliteCallbacks/views/toyEdit.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 |

Edit Toy

13 | 14 | <%- include('toyForm') %> 15 | 16 | List 17 | 18 | -------------------------------------------------------------------------------- /ExpressMVCSqlitePromises/views/toyEdit.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 |

Edit Toy

13 | 14 | <%- include('toyForm') %> 15 | 16 | List 17 | 18 | -------------------------------------------------------------------------------- /ReactJSXIntro/README.md: -------------------------------------------------------------------------------- 1 | Order for viewing source code 2 | 3 | 1. `clientSideDomCreation.{html.js}` --- How to create web page using raw JavaScript. 4 | 2. `reactDomCreation.{html.js}` -- How to create web pages using "raw" React (without JSX) 5 | 3. `jsx1.js` -- basic use of JSX 6 | 4. `jsx2.js` -- include code inside JSX 7 | 5. 8 | -------------------------------------------------------------------------------- /ColorListAPI_rails/app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | class ApplicationJob < ActiveJob::Base 2 | # Automatically retry jobs that encountered a deadlock 3 | # retry_on ActiveRecord::Deadlocked 4 | 5 | # Most jobs are safe to ignore if the underlying records are no longer available 6 | # discard_on ActiveJob::DeserializationError 7 | end 8 | -------------------------------------------------------------------------------- /ColorListAPI_rails/app/views/layouts/mailer.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | -------------------------------------------------------------------------------- /ColorListAPI_rails/db/migrate/20240310230244_create_colors.rb: -------------------------------------------------------------------------------- 1 | class CreateColors < ActiveRecord::Migration[7.0] 2 | def change 3 | create_table :colors do |t| 4 | t.string :title 5 | t.string :uuid 6 | t.integer :color 7 | t.integer :rating 8 | 9 | t.timestamps 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /PretendJest/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pretendjest", 3 | "version": "1.0.0", 4 | "description": "", 5 | "license": "ISC", 6 | "author": "", 7 | "type": "commonjs", 8 | "main": "PretendJest.js", 9 | "scripts": { 10 | "test": "jest" 11 | }, 12 | "devDependencies": { 13 | "jest": "^29.7.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /ReactJSXIntro/jsx1.jsx: -------------------------------------------------------------------------------- 1 | const helloWorld =

Hello, World

; 2 | 3 | 4 | const myStates =
5 |

Here are some states

6 |
    7 |
  • Alabama
  • 8 |
  • Alaska
  • 9 |
  • Michigan
  • 10 |
  • New York
  • 11 |
  • Tennessee
  • 12 |
13 |
-------------------------------------------------------------------------------- /JavaScriptDOM/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "javascriptdom", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": ".eslintrc.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "devDependencies": { 12 | "eslint": "^8.36.0" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SimpleHTTPServer/Java/cgi-bin/mean.rb: -------------------------------------------------------------------------------- 1 | 2 | 3 | names = ['Prof. Engelsma', 'Prof. Leidig', 'Prof. Wolffe', 'Prof. Moore', 'Prof. Scripps', 'Prof. Carrier'] 4 | 5 | puts < 7 | 8 |

Hello, World!

9 | 10 |

Today, I'm randomly being mean to #{names.sample}.

11 | 12 | (from, Ruby) 13 | 14 | 15 | HERE -------------------------------------------------------------------------------- /ColorListAPI_rails/test/channels/application_cable/connection_test.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | 3 | class ApplicationCable::ConnectionTest < ActionCable::Connection::TestCase 4 | # test "connects with cookies" do 5 | # cookies.signed[:user_id] = 42 6 | # 7 | # connect 8 | # 9 | # assert_equal connection.user_id, "42" 10 | # end 11 | end 12 | -------------------------------------------------------------------------------- /ColorListAPI/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "colorlistapi", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "express": "^4.21.2", 13 | "sqlite3": "^5.1.5" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Cookies/PHP/readme.txt: -------------------------------------------------------------------------------- 1 | Demonstrates how to use cookies 2 | 3 | simpleCookie.php: 4 | Demonstrates how to read and set a cookie. 5 | Also demonstrates all the parameters to the 6 | setcookie method. 7 | 8 | lookForCookie.php: 9 | A second page that looks for the same cookies 10 | used by simpleCookie.php. Used to demonstrate 11 | when pages can and can't share cookies. -------------------------------------------------------------------------------- /ColorList1_fetch/README.md: -------------------------------------------------------------------------------- 1 | # "Plain" ColorList (version 1) 2 | 3 | This is an implementation of the ColorList example from the Porcello and Banks book using the 4 | "plain"/"straightforward" techniques discussed in Chapters 4-6. 5 | 6 | In other words, this is the version of ColorList that includes a fetch call to the API, but 7 | before the authors add refactoring, short-cuts, and network access. -------------------------------------------------------------------------------- /ExpressRouting/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "expressrouting", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "express": "^4.21.2" 13 | }, 14 | "devDependencies": { 15 | "eslint": "^8.28.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Templating/countToTen.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | Count to Ten 4 | 5 | 6 | 7 |

Count to Ten

8 | 9 | Let's count! 10 | 11 |
    12 | " . $i . ""; 15 | } 16 | ?> 17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /ExpressSession/views/login.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

Welcome!

5 | 6 | <%= message %> 7 |
8 | Username:
9 | Password:
10 | 11 |
12 | 13 | -------------------------------------------------------------------------------- /ExpressMVC/views/showSomePictures.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Just a few pictures

8 |
9 | 10 |
LifeConnect team at Atomic Object 2010-2011: One of the few times I've felt short.
11 |
12 | 13 | -------------------------------------------------------------------------------- /ReactJSXIntro/reactDomCreation.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
Web page to go here
9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /ColorList1_fetch/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /ColorList2_edit/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /ColorList3_routing/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /Cookies/views/cookieList.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

Cookie List

5 | 6 | <% if (Object.keys(cookieList).length == 0) { %> 7 | No cookies detected 8 | <% } else { %> 9 |
    10 | <% for (const [key, value] of Object.entries(cookieList)) { %> 11 |
  • <%= key %>: <%= value %>
  • 12 | <% } %> 13 |
14 | <% } %> 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /ColorList1_fetch/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /ColorList3_routing/src/reportWebVitals.js: -------------------------------------------------------------------------------- 1 | const reportWebVitals = onPerfEntry => { 2 | if (onPerfEntry && onPerfEntry instanceof Function) { 3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 4 | getCLS(onPerfEntry) 5 | getFID(onPerfEntry) 6 | getFCP(onPerfEntry) 7 | getLCP(onPerfEntry) 8 | getTTFB(onPerfEntry) 9 | }) 10 | } 11 | } 12 | 13 | export default reportWebVitals 14 | -------------------------------------------------------------------------------- /ColorList1_fetch/src/reportWebVitals.js: -------------------------------------------------------------------------------- 1 | const reportWebVitals = onPerfEntry => { 2 | if (onPerfEntry && onPerfEntry instanceof Function) { 3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 4 | getCLS(onPerfEntry); 5 | getFID(onPerfEntry); 6 | getFCP(onPerfEntry); 7 | getLCP(onPerfEntry); 8 | getTTFB(onPerfEntry); 9 | }); 10 | } 11 | }; 12 | 13 | export default reportWebVitals; 14 | -------------------------------------------------------------------------------- /ColorList2_edit/src/reportWebVitals.js: -------------------------------------------------------------------------------- 1 | const reportWebVitals = onPerfEntry => { 2 | if (onPerfEntry && onPerfEntry instanceof Function) { 3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 4 | getCLS(onPerfEntry); 5 | getFID(onPerfEntry); 6 | getFCP(onPerfEntry); 7 | getLCP(onPerfEntry); 8 | getTTFB(onPerfEntry); 9 | }); 10 | } 11 | }; 12 | 13 | export default reportWebVitals; 14 | -------------------------------------------------------------------------------- /ReactJSXIntro/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-intro", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "clientSideDomCreation.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Zachary Kurmas", 10 | "license": "ISC", 11 | "devDependencies": { 12 | "@babel/cli": "^7.19.3", 13 | "@babel/core": "^7.19.6", 14 | "@babel/preset-react": "^7.18.6" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Cookies/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cookies", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "cookie-parser": "^1.4.6", 13 | "ejs": "^3.1.8", 14 | "express": "^4.18.2" 15 | }, 16 | "devDependencies": { 17 | "eslint": "^8.34.0" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ColorList1_fetch/src/Color.jsx: -------------------------------------------------------------------------------- 1 | import StarRating from './StarRating' 2 | 3 | export default function Color({ title, color, rating, onColorRatingUpdated = f => f}) { 4 | return ( 5 |
6 |

{title}

7 |
8 | onColorRatingUpdated(newValue)} /> 9 |
10 | ); 11 | } -------------------------------------------------------------------------------- /ColorListAPI_rails/config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | resources :colors 3 | 4 | # add an OPTIONS route for "DIY" CORS 5 | # The better answer is to use the rack-cors ruby gem 6 | match '/colors(/:id)' => 'colors#options', via: [:options] 7 | 8 | 9 | # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html 10 | 11 | # Defines the root path route ("/") 12 | # root "articles#index" 13 | end 14 | -------------------------------------------------------------------------------- /ReactRecipe/README.md: -------------------------------------------------------------------------------- 1 | Demonstrates how to use components and state 2 | 3 | Order for viewing source code 4 | 5 | 1. `exampleComponent1.js` -- Demonstrates creating a React component without JSX. 6 | 2. `recipe1.jsx` -- Recipe example using props only (Shows all recipes at once) 7 | 3. `recipe2.jsx` -- Recipe example using state to keep track of current recipe (only shows current recipe) 8 | 4. `recipe3.jsx` -- Recipe example using shortcuts like deconstructing objects. 9 | -------------------------------------------------------------------------------- /ColorListAPI_rails/test/test_helper.rb: -------------------------------------------------------------------------------- 1 | ENV["RAILS_ENV"] ||= "test" 2 | require_relative "../config/environment" 3 | require "rails/test_help" 4 | 5 | class ActiveSupport::TestCase 6 | # Run tests in parallel with specified workers 7 | parallelize(workers: :number_of_processors) 8 | 9 | # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. 10 | fixtures :all 11 | 12 | # Add more helper methods to be used by all tests here... 13 | end 14 | -------------------------------------------------------------------------------- /FlaskImpl/README.md: -------------------------------------------------------------------------------- 1 | # "Pretend" Flask 2 | 3 | This directory contains a "pretend" implementation of Flask. The idea is to show one 4 | way Flask _might_ be implemented so that the framework doesn't feel like "magic". 5 | Flask is open source, so you can just go to GitHub and 6 | [look at the actual source yourself](https://github.com/pallets/flask); however, 7 | because Flask has so many features, it can be difficult to see at a glance what is 8 | actually going on. 9 | 10 | -------------------------------------------------------------------------------- /PretendJest/MyController.test.js: -------------------------------------------------------------------------------- 1 | pretendJest = require('./PretendJest') 2 | 3 | MyController = require('./MyController') 4 | 5 | describe('#index', () => { 6 | 7 | let c 8 | let res 9 | 10 | 11 | beforeEach(() => { 12 | c = new MyController({getData:() => [1, 2, 3, 4]}) 13 | res = { 14 | render: pretendJest.fn() 15 | } 16 | }) 17 | 18 | it('works', () => { 19 | c.index(res) 20 | }) 21 | }) -------------------------------------------------------------------------------- /ColorListAPI_rails/config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure parameters to be filtered from the log file. Use this to limit dissemination of 4 | # sensitive information. See the ActiveSupport::ParameterFilter documentation for supported 5 | # notations and behaviors. 6 | Rails.application.config.filter_parameters += [ 7 | :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn 8 | ] 9 | -------------------------------------------------------------------------------- /ColorListAPI_rails/config/credentials.yml.enc: -------------------------------------------------------------------------------- 1 | 5TNdli5TEB1WrqF0EA5CMvP4ZkbUi4w3025OyNFlqIzrCjpfRluSsY6Pb5+vvPshtF43qlyQCNjBuq4GoMS/J/3XQllIS0IurVfZtbbJ4XO5BMr+Yi2AjTPQQr7buWVC/9oJNxH4yn5FMYCO9ppg3F4TW/LFQ8HKQTFHw07hZYkBuN64kXPaVQ5afIU2QJeO4cmBR4iOhgXGLucE53obFc2TESNn42KXhyQz1YsEDk9K21NG01FkqLRdaNWhH6ytLs3rHec1aCR0T+Atd1qZNSxF+4kpC5ipJ+Xj3x19Wk7vT6ISRqngOpNU7XUXPrXmqIcVqWAJwGQM+TLNKMLTITjo73NK4uvKiKThRRZH/nem86nBf5uxBC/9OSnDbK9X5/dJ3+gm7uS8awDCS4YQ0b53EZgZrVL/gCA6--y1b/abiiUrORVNf6--8hsXGAYOsIrbJdx0kMoriA== -------------------------------------------------------------------------------- /ColorListAPI_rails/README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | This README would normally document whatever steps are necessary to get the 4 | application up and running. 5 | 6 | Things you may want to cover: 7 | 8 | * Ruby version 9 | 10 | * System dependencies 11 | 12 | * Configuration 13 | 14 | * Database creation 15 | 16 | * Database initialization 17 | 18 | * How to run the test suite 19 | 20 | * Services (job queues, cache servers, search engines, etc.) 21 | 22 | * Deployment instructions 23 | 24 | * ... 25 | -------------------------------------------------------------------------------- /ExpressRouting/openForBusiness.js: -------------------------------------------------------------------------------- 1 | const weekday = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] 2 | 3 | 4 | // eslint-disable-next-line no-undef 5 | module.exports = (dayOpen, whenClosed) => { 6 | const dayOpenNum = weekday.indexOf(dayOpen) 7 | return (req, res, next) => { 8 | const date = new Date() 9 | if (dayOpenNum !== date.getDay()) { 10 | whenClosed(req, res) 11 | } else { 12 | next() 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /JavaScriptAsADT/PrintHelper.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * Created by kurmasz on 2/10/15. 4 | */ 5 | 6 | var PrintHelper = (function () { 7 | 8 | var print = function (p) { 9 | document.getElementById("output").innerHTML += p; 10 | } 11 | 12 | var println = function (p) { 13 | print(p); 14 | print("
"); 15 | } 16 | 17 | return { 18 | print: print, 19 | println: println, 20 | tab: " " 21 | } 22 | })(); -------------------------------------------------------------------------------- /ColorList2_edit/public/colorData.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "0175d1f0-a8c6-41bf-8d02-df5734d829a4", 4 | "title": "ocean at dusk", 5 | "color": "#00c4e2", 6 | "rating": 5 7 | }, 8 | { 9 | "id": "83c7ba2f-7392-4d7d-9e23-35adbe186046", 10 | "title": "lawn", 11 | "color": "#26ac56", 12 | "rating": 3 13 | }, 14 | { 15 | "id": "a11e3995-b0bd-4d58-8c48-5e49ae7f7f23", 16 | "title": "bright red", 17 | "color": "#ff0000", 18 | "rating": 0 19 | } 20 | ] -------------------------------------------------------------------------------- /ColorList1_fetch/public/colorData.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "0175d1f0-a8c6-41bf-8d02-df5734d829a4", 4 | "title": "ocean at dusk", 5 | "color": "#00c4e2", 6 | "rating": 5 7 | }, 8 | { 9 | "id": "83c7ba2f-7392-4d7d-9e23-35adbe186046", 10 | "title": "lawn", 11 | "color": "#26ac56", 12 | "rating": 3 13 | }, 14 | { 15 | "id": "a11e3995-b0bd-4d58-8c48-5e49ae7f7f23", 16 | "title": "bright red", 17 | "color": "#ff0000", 18 | "rating": 0 19 | } 20 | ] -------------------------------------------------------------------------------- /ColorList3_routing/public/colorData.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "0175d1f0-a8c6-41bf-8d02-df5734d829a4", 4 | "title": "ocean at dusk", 5 | "color": "#00c4e2", 6 | "rating": 5 7 | }, 8 | { 9 | "id": "83c7ba2f-7392-4d7d-9e23-35adbe186046", 10 | "title": "lawn", 11 | "color": "#26ac56", 12 | "rating": 3 13 | }, 14 | { 15 | "id": "a11e3995-b0bd-4d58-8c48-5e49ae7f7f23", 16 | "title": "bright red", 17 | "color": "#ff0000", 18 | "rating": 0 19 | } 20 | ] -------------------------------------------------------------------------------- /ExpressIntro/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "expressintro", 3 | "version": "1.0.0", 4 | "description": "Introductory demo for Express.js", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "ejs": "^3.1.10", 13 | "express": "^4.21.2" 14 | }, 15 | "devDependencies": { 16 | "@flydotio/dockerfile": "^0.7.10", 17 | "ejs-cli": "^2.2.3", 18 | "eslint": "^8.33.0" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Fly/StaticOnly/fly.toml: -------------------------------------------------------------------------------- 1 | # fly.toml app configuration file generated for zkstatic1 on 2025-04-08T11:01:58-04:00 2 | # 3 | # See https://fly.io/docs/reference/configuration/ for information about how to use this file. 4 | # 5 | 6 | app = 'zkstatic1' 7 | primary_region = 'ord' 8 | 9 | [build] 10 | 11 | [http_service] 12 | internal_port = 8080 13 | force_https = true 14 | auto_stop_machines = 'stop' 15 | auto_start_machines = true 16 | min_machines_running = 0 17 | processes = ['app'] 18 | 19 | [[vm]] 20 | size = 'shared-cpu-1x' 21 | -------------------------------------------------------------------------------- /ReactRecipe/recipe1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | React Demo Recipe v1 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /FlaskDemo/fly.toml: -------------------------------------------------------------------------------- 1 | # fly.toml app configuration file generated for flaskdemo on 2025-02-06T15:07:59-05:00 2 | # 3 | # See https://fly.io/docs/reference/configuration/ for information about how to use this file. 4 | # 5 | 6 | app = 'flaskdemo' 7 | primary_region = 'ord' 8 | 9 | [http_service] 10 | internal_port = 5000 11 | force_https = true 12 | auto_stop_machines = 'stop' 13 | auto_start_machines = true 14 | min_machines_running = 0 15 | processes = ['app'] 16 | 17 | [[vm]] 18 | memory = '1gb' 19 | cpu_kind = 'shared' 20 | cpus = 1 21 | -------------------------------------------------------------------------------- /FlaskDemo/templates/temperature.j2: -------------------------------------------------------------------------------- 1 | 2 | 3 | Current Temperature 4 | 5 | 6 |

Current Temperature

7 | 8 |

Currently, it is {{temperature}}°F in {{place_name}}, {{place_state}}.

9 | 10 | {% if temperature > 65 and temperature < 80 %} 11 | That seems like a nice temperature. 12 | {% endif %} 13 | 14 | {% if temperature < 40 %} 15 | That's a bit cold for me. 16 | {% endif %} 17 | 18 | 19 | -------------------------------------------------------------------------------- /ReactRecipe/recipe2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | React Demo Recipe v2 5 | 6 | 7 | 8 |
React results will go here
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /ReactRecipe/recipe3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | React Demo Recipe v3 5 | 6 | 7 | 8 |
React results will go here
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /PretendJest/PretendJest.js: -------------------------------------------------------------------------------- 1 | 2 | let mock_data = {} 3 | function fn(fake_in) { 4 | 5 | const fake = fake_in ? fake_in : x => x 6 | 7 | let stub = (...args) => { 8 | mock_data[stub].timesCalled += 1 9 | mock_data[stub].args = args 10 | return fake(...args) 11 | } 12 | mock_data[stub] = { 13 | timesCalled: 0, 14 | } 15 | return stub 16 | } 17 | 18 | function expect(mock_fn) { 19 | return 20 | } 21 | 22 | 23 | function toHaveBeenCalledWith(...expectedParams) { 24 | 25 | } 26 | 27 | 28 | module.exports = {fn:fn} -------------------------------------------------------------------------------- /ColorList2_edit/src/Color.jsx: -------------------------------------------------------------------------------- 1 | import StarRating from './StarRating' 2 | 3 | export default function Color({ title, color, rating, onEditClicked = f => f, onColorRatingUpdated = f => f}) { 4 | return ( 5 |
6 |

{title}

7 |
8 |
9 | 10 |
11 | onColorRatingUpdated(newValue)} /> 12 |
13 | ); 14 | } -------------------------------------------------------------------------------- /ExpressMVC/views/showUser.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

Selected User

5 | 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 18 | 19 |
Name: 10 | <%= `${user.fname} ${user.lname}`%> 11 |
Name: 16 | <%= user.email %> 17 |
20 | 21 | Select another 22 | 23 | 24 | -------------------------------------------------------------------------------- /ExpressIntro/fly.toml: -------------------------------------------------------------------------------- 1 | # fly.toml app configuration file generated for zk-express-intro1 on 2025-04-08T15:09:34-04:00 2 | # 3 | # See https://fly.io/docs/reference/configuration/ for information about how to use this file. 4 | # 5 | 6 | app = 'zk-express-intro1' 7 | primary_region = 'ord' 8 | 9 | [build] 10 | 11 | [http_service] 12 | internal_port = 3000 13 | force_https = true 14 | auto_stop_machines = 'stop' 15 | auto_start_machines = true 16 | min_machines_running = 0 17 | processes = ['app'] 18 | 19 | [[vm]] 20 | memory = '512mb' 21 | cpu_kind = 'shared' 22 | cpus = 1 23 | -------------------------------------------------------------------------------- /ColorList3_routing/src/ColorDetails.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { useParams } from 'react-router-dom' 3 | import Color from './Color' 4 | 5 | export default function ColorDetails({ colors }) { 6 | 7 | let params = useParams() 8 | console.log(params) 9 | let id = params.id 10 | console.log(colors) 11 | let color = colors.find((item) => item.id === id || item.pk == id) 12 | 13 | const body = color ? : Color {id} not found. 14 | return ( 15 |
16 |

Color Details

17 | {body} 18 |
19 | 20 | ) 21 | } -------------------------------------------------------------------------------- /ExpressMVC/controllers/UserController.js: -------------------------------------------------------------------------------- 1 | let User = require('../models/User') 2 | 3 | // The purpose of this "mini-controller" is to show how to use a dropdown select 4 | // There is 5 | class UserController { 6 | 7 | select(req, res) { 8 | res.render('selectUser', { users: User.all() }) 9 | } 10 | 11 | showSelected(req, res) { 12 | console.log('Input: ') 13 | console.log(req.body) 14 | 15 | let user = User.find(req.body.chosenUser) 16 | 17 | res.render('showUser', { user: user }) 18 | 19 | } 20 | } 21 | 22 | module.exports = UserController -------------------------------------------------------------------------------- /ExpressMVC/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "express-mvc", 3 | "version": "1.0.0", 4 | "description": "Demonstrating use of MVC with Express", 5 | "main": "index.js", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "scripts": { 10 | "test": "jest" 11 | }, 12 | "author": "Zachary Kurmas", 13 | "license": "ISC", 14 | "dependencies": { 15 | "ejs": "^3.1.10", 16 | "express": "^4.21.2", 17 | "express-validator": "^6.14.2", 18 | "jest": "^29.0.3", 19 | "sqlite3": "^5.1.5" 20 | }, 21 | "devDependencies": { 22 | "eslint": "^8.34.0" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ColorList3_routing/src/Color.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import StarRating from './StarRating' 3 | 4 | export default function Color({ title, color, rating, onEditClicked = f => f, onColorRatingUpdated = f => f }) { 5 | return ( 6 |
7 |

{title}

8 |
9 |
10 | 11 |
12 | onColorRatingUpdated(newValue)} /> 13 |
14 | ) 15 | } -------------------------------------------------------------------------------- /ReactJSXIntro/jsx2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | React Demo #2 5 | 6 | 7 | 8 |

Rendered using JSX

9 |
React results will go here
10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /ExpressMVCSqlitePromises/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "express-mvc", 3 | "version": "1.0.0", 4 | "description": "Demonstrating use of MVC with Express", 5 | "main": "index.js", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "scripts": { 10 | "test": "jest" 11 | }, 12 | "author": "Zachary Kurmas", 13 | "license": "ISC", 14 | "dependencies": { 15 | "ejs": "^3.1.10", 16 | "express": "^4.21.2", 17 | "express-validator": "^6.14.2", 18 | "jest": "^29.0.3", 19 | "sqlite3": "^5.1.5" 20 | }, 21 | "devDependencies": { 22 | "eslint": "^8.34.0" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ColorListAPI_rails/config/initializers/cors.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Avoid CORS issues when API is called from the frontend app. 4 | # Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests. 5 | 6 | # Read more: https://github.com/cyu/rack-cors 7 | 8 | # Rails.application.config.middleware.insert_before 0, Rack::Cors do 9 | # allow do 10 | # origins "example.com" 11 | # 12 | # resource "*", 13 | # headers: :any, 14 | # methods: [:get, :post, :put, :patch, :delete, :options, :head] 15 | # end 16 | # end 17 | -------------------------------------------------------------------------------- /ExpressMVCSqliteCallbacks/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "express-mvc", 3 | "version": "1.0.0", 4 | "description": "Demonstrating use of MVC with Express", 5 | "main": "index.js", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "scripts": { 10 | "test": "jest" 11 | }, 12 | "author": "Zachary Kurmas", 13 | "license": "ISC", 14 | "dependencies": { 15 | "ejs": "^3.1.10", 16 | "express": "^4.21.2", 17 | "express-validator": "^6.14.2", 18 | "jest": "^29.0.3", 19 | "sqlite3": "^5.1.5" 20 | }, 21 | "devDependencies": { 22 | "eslint": "^8.34.0" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ReactJSXIntro/jsx2.jsx: -------------------------------------------------------------------------------- 1 | 2 | let states = ['Alabama', 'Alaska', 'Arizona', 'California', 'Colorado', 'Georgia', 3 | 'Florida', 'Michigan', 'Minnesota', '...', '(you get the point :)' 4 | ]; 5 | 6 | const moreStates =
7 |

Here are some more states:

8 |
    9 | {states.map((state) =>
  • {state}
  • )} 10 |
11 |
; 12 | 13 | // This is the new React18 way of rendering the content 14 | const root = ReactDOM.createRoot(document.getElementById('main')); 15 | root.render(moreStates); 16 | 17 | // This is the old way. 18 | // ReactDOM.render(moreStates, document.getElementById('main')); -------------------------------------------------------------------------------- /ColorList1_fetch/src/StarRating.jsx: -------------------------------------------------------------------------------- 1 | import Star from './Star' 2 | 3 | const createArray = length => [...Array(length)]; 4 | 5 | export default function StarRating({ totalStars = 5, selectedStars = 0, onRatingUpdated = f => f }) { 6 | return ( 7 | <> 8 | {createArray(totalStars).map((n, i) => ( 9 | i} 12 | onStarClicked={() => onRatingUpdated(i + 1) } 13 | /> 14 | ))} 15 |

16 | {selectedStars} of {totalStars} stars 17 |

18 | 19 | ); 20 | } -------------------------------------------------------------------------------- /ColorList2_edit/src/StarRating.jsx: -------------------------------------------------------------------------------- 1 | import Star from './Star' 2 | 3 | const createArray = length => [...Array(length)]; 4 | 5 | export default function StarRating({ totalStars = 5, selectedStars = 0, onRatingUpdated = f => f }) { 6 | return ( 7 | <> 8 | {createArray(totalStars).map((n, i) => ( 9 | i} 12 | onStarClicked={() => onRatingUpdated(i + 1) } 13 | /> 14 | ))} 15 |

16 | {selectedStars} of {totalStars} stars 17 |

18 | 19 | ); 20 | } -------------------------------------------------------------------------------- /ColorList3_routing/src/StarRating.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Star from './Star' 3 | 4 | const createArray = length => [...Array(length)] 5 | 6 | export default function StarRating({ totalStars = 5, selectedStars = 0, onRatingUpdated = f => f }) { 7 | return ( 8 | <> 9 | {createArray(totalStars).map((n, i) => ( 10 | i} 13 | onStarClicked={() => onRatingUpdated(i + 1) } 14 | /> 15 | ))} 16 |

17 | {selectedStars} of {totalStars} stars 18 |

19 | 20 | ) 21 | } -------------------------------------------------------------------------------- /FlaskDemo/templates/temperature_and_query.j2: -------------------------------------------------------------------------------- 1 | 2 | 3 | Current Temperature 4 | 5 | 6 |

Current Temperature

7 | 8 | 9 |

10 | {% if name %} 11 | Hello, {{name}}. 12 | {% endif %} 13 | Currently, it is {{temperature}}°F in {{place_name}}, {{place_state}}.

14 | 15 |
16 |

Query Parameters

17 |
    18 | {% for key, value in query_dict.items() %} 19 |
  • {{key}}: {{value}}
  • 20 | {% endfor %} 21 |
22 | 23 | -------------------------------------------------------------------------------- /ColorList1_fetch/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom/client'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | const root = ReactDOM.createRoot(document.getElementById('root')); 8 | root.render( 9 | 10 | 11 | 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /ColorList2_edit/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom/client'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | const root = ReactDOM.createRoot(document.getElementById('root')); 8 | root.render( 9 | 10 | 11 | 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /ColorList1_fetch/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /ColorList2_edit/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /ColorList3_routing/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /ExpressSession/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "express-mvc", 3 | "version": "1.0.0", 4 | "description": "Demonstrating use of MVC with Express", 5 | "main": "index.js", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "scripts": { 10 | "test": "jest" 11 | }, 12 | "author": "Zachary Kurmas", 13 | "license": "ISC", 14 | "dependencies": { 15 | "ejs": "^3.1.10", 16 | "express": "^4.21.2", 17 | "express-session": "^1.18.1", 18 | "express-validator": "^6.14.2", 19 | "jest": "^29.0.3", 20 | "sqlite3": "^5.1.5" 21 | }, 22 | "devDependencies": { 23 | "eslint": "^8.34.0" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /JavaScriptBasics/dynamicTypingAndFunctions.js: -------------------------------------------------------------------------------- 1 | function myForEach(array, callback) { 2 | for (var i = 0; i < array.length; ++i) { 3 | callback(array[i]); 4 | } 5 | } 6 | 7 | var names = ["John", "Paul", "George", "Ringo"]; 8 | 9 | console.log("Method with functional parameter working as expected: "); 10 | myForEach(names, (name) => console.log("Hello, " + name + ".")); 11 | 12 | console.log(""); 13 | console.log("Runtime error resulting from bad lambda: We don't know until runtime that lastName will always be undefined."); 14 | myForEach(names, (firstName, lastName) => console.log("Hello, " + firstName + " " + lastName + ".")); -------------------------------------------------------------------------------- /ColorList1_fetch/src/ColorList.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import Color from "./Color"; 3 | 4 | export default function ColorList({ colors = [], loading = false, message, update = f => f }) { 5 | if (message) { 6 | return
{message}
7 | } 8 | else if (loading) { 9 | return
Loading ......
; 10 | } else if(!colors.length) { 11 | return
No Colors Listed.
; 12 | } 13 | 14 | return ( 15 |
16 | { 17 | colors.map(color => update(color.id, newValue)} />) 18 | } 19 |
20 | ); 21 | } -------------------------------------------------------------------------------- /ExpressMVCSimple/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "express-mvc", 3 | "version": "1.0.0", 4 | "description": "Demonstrating use of MVC with Express", 5 | "main": "index.js", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "scripts": { 10 | "test": "jest" 11 | }, 12 | "author": "Zachary Kurmas", 13 | "license": "ISC", 14 | "dependencies": { 15 | "ejs": "^3.1.10", 16 | "express": "^4.21.2", 17 | "express-validator": "^6.14.2", 18 | "jest": "^29.0.3", 19 | "sqlite3": "^5.1.5" 20 | }, 21 | "devDependencies": { 22 | "@flydotio/dockerfile": "^0.7.10", 23 | "eslint": "^8.34.0" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ExpressMVC/views/selectUser.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Select a User

6 | 7 |
8 | Select a user: 9 | 12 | 13 |
14 | 15 |
16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /ColorList3_routing/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import ReactDOM from 'react-dom/client' 3 | import './index.css' 4 | import App from './App' 5 | import reportWebVitals from './reportWebVitals' 6 | 7 | import {BrowserRouter as Router} from 'react-router-dom' 8 | 9 | 10 | const root = ReactDOM.createRoot(document.getElementById('root')) 11 | root.render( 12 | 13 | 14 | 15 | ) 16 | 17 | // If you want to start measuring performance in your app, pass a function 18 | // to log results (for example: reportWebVitals(console.log)) 19 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 20 | reportWebVitals() 21 | -------------------------------------------------------------------------------- /ColorList2_edit/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | 15 | #updateForm { 16 | border: 1px solid black; 17 | padding: 7px; 18 | display: inline-block; 19 | } 20 | 21 | .colorBox { 22 | height: 50px; 23 | width: 100px; 24 | margin-right: 15px; 25 | display: inline-block; 26 | } -------------------------------------------------------------------------------- /ColorList2_edit/src/ColorList.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import Color from "./Color"; 3 | 4 | export default function ColorList({ colors = [], loading = false, message, onEditColor = f => f, update = f => f }) { 5 | if (message) { 6 | return
{message}
7 | } else if (loading) { 8 | return
Loading ......
; 9 | } else if(!colors.length) { 10 | return
No Colors Listed.
; 11 | } 12 | return ( 13 |
14 | { 15 | colors.map(color => onEditColor(color)} onColorRatingUpdated={(newValue) => update(color.id, newValue)} />) 16 | } 17 |
18 | ); 19 | } -------------------------------------------------------------------------------- /ColorListAPI_rails/config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, "\\1en" 8 | # inflect.singular /^(ox)en/i, "\\1" 9 | # inflect.irregular "person", "people" 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym "RESTful" 16 | # end 17 | -------------------------------------------------------------------------------- /ColorListAPI_rails/config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite. Versions 3.8.0 and up are supported. 2 | # gem install sqlite3 3 | # 4 | # Ensure the SQLite 3 gem is defined in your Gemfile 5 | # gem "sqlite3" 6 | # 7 | default: &default 8 | adapter: sqlite3 9 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 10 | timeout: 5000 11 | 12 | development: 13 | <<: *default 14 | database: db/development.sqlite3 15 | 16 | # Warning: The database defined as "test" will be erased and 17 | # re-generated from your development database when you run "rake". 18 | # Do not set this db to the same as development or production. 19 | test: 20 | <<: *default 21 | database: db/test.sqlite3 22 | 23 | production: 24 | <<: *default 25 | database: db/production.sqlite3 26 | -------------------------------------------------------------------------------- /Cookies/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "env": { 3 | "browser": true, 4 | "es2021": true, 5 | "jest": true 6 | }, 7 | "extends": "eslint:recommended", 8 | "overrides": [ 9 | ], 10 | "parserOptions": { 11 | "ecmaVersion": "latest", 12 | "sourceType": "module" 13 | }, 14 | "rules": { 15 | "indent": [ 16 | "error", 17 | 4 18 | ], 19 | "linebreak-style": [ 20 | "error", 21 | "unix" 22 | ], 23 | "quotes": [ 24 | "error", 25 | "single" 26 | ], 27 | "semi": [ 28 | "error", 29 | "never" 30 | ], 31 | "react/prop-types": 0 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ExpressIntro/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "env": { 3 | "browser": true, 4 | "es2021": true, 5 | "jest": true 6 | }, 7 | "extends": "eslint:recommended", 8 | "overrides": [ 9 | ], 10 | "parserOptions": { 11 | "ecmaVersion": "latest", 12 | "sourceType": "module" 13 | }, 14 | "rules": { 15 | "indent": [ 16 | "error", 17 | 4 18 | ], 19 | "linebreak-style": [ 20 | "error", 21 | "unix" 22 | ], 23 | "quotes": [ 24 | "error", 25 | "single" 26 | ], 27 | "semi": [ 28 | "error", 29 | "never" 30 | ], 31 | "react/prop-types": 0 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ExpressRouting/.eslintrc.js: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line no-undef 2 | module.exports = { 3 | 'env': { 4 | 'browser': true, 5 | 'es2021': true, 6 | 'amd': true 7 | }, 8 | 'extends': 'eslint:recommended', 9 | 'overrides': [ 10 | ], 11 | 'parserOptions': { 12 | 'ecmaVersion': 'latest', 13 | 'sourceType': 'script' 14 | }, 15 | 'rules': { 16 | 'indent': [ 17 | 'error', 18 | 4 19 | ], 20 | 'linebreak-style': [ 21 | 'error', 22 | 'unix' 23 | ], 24 | 'quotes': [ 25 | 'error', 26 | 'single' 27 | ], 28 | 'semi': [ 29 | 'error', 30 | 'never' 31 | ] 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ExpressMVCSimple/fly.toml: -------------------------------------------------------------------------------- 1 | # fly.toml app configuration file generated for zk-express-mvc-simple on 2025-04-08T15:43:23-04:00 2 | # 3 | # See https://fly.io/docs/reference/configuration/ for information about how to use this file. 4 | # 5 | 6 | app = 'zk-express-mvc-simple' 7 | primary_region = 'ord' 8 | 9 | [build] 10 | 11 | [[mounts]] 12 | source = 'data' 13 | destination = '/data' 14 | auto_extend_size_threshold = 80 15 | auto_extend_size_increment = '1GB' 16 | auto_extend_size_limit = '10GB' 17 | 18 | [http_service] 19 | internal_port = 3000 20 | force_https = true 21 | auto_stop_machines = 'stop' 22 | auto_start_machines = true 23 | min_machines_running = 0 24 | processes = ['app'] 25 | 26 | [[vm]] 27 | memory = '512mb' 28 | cpu_kind = 'shared' 29 | cpus = 1 30 | -------------------------------------------------------------------------------- /FlaskDemo/all_routes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

All Routes

4 | 5 |

These are all the routes supported by this server:

6 | 14 | 15 | -------------------------------------------------------------------------------- /Cookies/PHP/lookForCookie.php: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | Look for Cookie 8 | 9 | 10 | 11 | 12 |

Looking for cookie

13 | 14 | Hello, $nn. I see you've been to one of my other web pages.

\n"; 18 | } else { 19 | echo "

Howdy. It looks like you're new around here.

"; 20 | } 21 | ?> 22 | 23 | 24 | 25 | 2 | 3 |

All Routes

4 | 5 |

These are all the routes supported by this server:

6 | 14 | 15 | -------------------------------------------------------------------------------- /ColorList3_routing/src/ColorList.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Color from './Color' 3 | 4 | export default function ColorList({ colors = [], loading = false, message, onEditColor = f => f, update = f => f }) { 5 | 6 | function editClicked(color) { 7 | console.log(color) 8 | return onEditColor(color) 9 | } 10 | 11 | 12 | if (message) { 13 | return
{message}
14 | } else if (loading) { 15 | return
Loading ......
16 | } else if(!colors.length) { 17 | return
No Colors Listed.
18 | } 19 | return ( 20 |
21 | { 22 | colors.map(color => editClicked(color)} onColorRatingUpdated={(newValue) => update(color.id, newValue)} />) 23 | } 24 |
25 | ) 26 | } -------------------------------------------------------------------------------- /ColorList3_routing/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | 15 | #updateForm { 16 | border: 1px solid black; 17 | padding: 7px; 18 | display: inline-block; 19 | } 20 | 21 | .colorBox { 22 | height: 50px; 23 | width: 100px; 24 | margin-right: 15px; 25 | display: inline-block; 26 | } 27 | 28 | #navBar a { 29 | margin: 15px; 30 | } 31 | 32 | #navBar { 33 | margin-bottom: 25px; 34 | padding: 5px; 35 | background-color:rgb(235, 235, 235) 36 | } -------------------------------------------------------------------------------- /ColorListAPI_rails/db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }]) 7 | # Character.create(name: "Luke", movie: movies.first) 8 | 9 | Color.create(title: 'Ocean at noon', color: 0x029eb6, rating: 5, uuid: '0175d1f0-a8c6-41bf-8d02-df5734d829a4') 10 | Color.create(uuid: "83c7ba2f-7392-4d7d-9e23-35adbe186046",title: "Lawn",color:0x2534486, rating:3) 11 | Color.create(uuid: "a11e3995-b0bd-4d58-8c48-5e49ae7f7f23",title: "Bright red",color: 0x16711680,rating:2) 12 | Color.create(uuid: "49fef18c-475c-4ff7-b2de-7adfdbcbaa24",title: "Orange",color:0xca8102,rating: 0) -------------------------------------------------------------------------------- /ColorList3_routing/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es2021": true, 5 | "jest": true 6 | }, 7 | "extends": [ 8 | "eslint:recommended", 9 | "plugin:react/recommended" 10 | ], 11 | "overrides": [ 12 | ], 13 | "parserOptions": { 14 | "ecmaVersion": "latest", 15 | "sourceType": "module" 16 | }, 17 | "plugins": [ 18 | "react" 19 | ], 20 | "rules": { 21 | "indent": [ 22 | "error", 23 | 2 24 | ], 25 | "linebreak-style": [ 26 | "error", 27 | "unix" 28 | ], 29 | "quotes": [ 30 | "error", 31 | "single" 32 | ], 33 | "semi": [ 34 | "error", 35 | "never" 36 | ], 37 | "react/prop-types": 0 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Bootstrap/example.scss: -------------------------------------------------------------------------------- 1 | /* These are just the examples from https://www.w3schools.com/sass 2 | * 3 | * There are many ways to install/run sass. Here is one: 4 | * npm install sass -g 5 | * sass example.scss 6 | */ 7 | 8 | nav { 9 | ul { 10 | margin: 0; 11 | padding: 0; 12 | list-style: none; 13 | } 14 | li { 15 | display: inline-block; 16 | } 17 | a { 18 | display: block; 19 | padding: 6px 12px; 20 | text-decoration: none; 21 | } 22 | } 23 | 24 | .button-basic { 25 | border: none; 26 | padding: 15px 30px; 27 | text-align: center; 28 | font-size: 16px; 29 | cursor: pointer; 30 | } 31 | 32 | .button-report { 33 | @extend .button-basic; 34 | background-color: red; 35 | } 36 | 37 | .button-submit { 38 | @extend .button-basic; 39 | background-color: green; 40 | color: white; 41 | } -------------------------------------------------------------------------------- /ReactRecipe/stateUsingClosures.js: -------------------------------------------------------------------------------- 1 | // Gives a rough idea of how the React useState hook might work. 2 | // (In reality, it is much more complex.) 3 | // Other articles: 4 | // https://dev.to/lizraeli/implementing-the-usestate-hook-3nd7 5 | // https://medium.com/the-guild/under-the-hood-of-reacts-hooks-system-eb59638c9dba 6 | 7 | let makeState = function(initialValue) { 8 | 9 | let current = initialValue; 10 | 11 | let get = () => current; 12 | 13 | let update = (newValue) => { 14 | current = newValue; 15 | } 16 | 17 | return [get, update]; 18 | }; 19 | 20 | console.log("Welcome!"); 21 | 22 | let [getTemp, setTemp] = makeState(55); 23 | let [getHumidity, setHumidity] = makeState(44.5); 24 | 25 | console.log(`Current conditions: ${getTemp()}, ${getHumidity()}`) 26 | 27 | setTemp(72); 28 | setHumidity(12); 29 | 30 | console.log(`New conditions: ${getTemp()}, ${getHumidity()}`) -------------------------------------------------------------------------------- /ExpressIntro/simple_sendHTML.js: -------------------------------------------------------------------------------- 1 | // Demonstrates a couple of routes using send only 2 | 3 | // Express documentation: https://expressjs.com/en/api.html 4 | 5 | /* Import the express npm module */ 6 | const express = require('express') 7 | 8 | /* Instantiate a server object*/ 9 | const app = express() 10 | const port = 3000 11 | 12 | /* Sample route returning a simple, static message. 13 | #send() simply sends the string to the client. 14 | (Yes, I "cheated" by not sending a complete HTML file.) 15 | */ 16 | app.get('/', (req, res) => res.send('

Root

Hello World!
(This is the root route)')) 17 | 18 | /* Another sample route returning a simple, static message. */ 19 | app.get('/about', (req, res) => res.send('

About

This is an absurdly simple express server with two routes.')) 20 | 21 | /* Launch the server */ 22 | app.listen(port, () => console.log(`Example app listening on port ${port}!`)) -------------------------------------------------------------------------------- /ExpressIntro/multForm.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 20 | 21 | 22 | 23 | 24 |

Multiplication Table

25 | 26 |
27 | Table Parameters 28 |
29 | Num rows:
30 | Num columns:
31 | 32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /Fly/StaticOnly/public/goodbye.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Still Hello from Fly 6 | 7 | 35 | 36 | 37 | 38 |

You say goodbye

39 |

But I say hello.

40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /ColorListAPI_rails/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore the default SQLite database. 11 | /db/*.sqlite3 12 | /db/*.sqlite3-* 13 | 14 | # Ignore all logfiles and tempfiles. 15 | /log/* 16 | /tmp/* 17 | !/log/.keep 18 | !/tmp/.keep 19 | 20 | # Ignore pidfiles, but keep the directory. 21 | /tmp/pids/* 22 | !/tmp/pids/ 23 | !/tmp/pids/.keep 24 | 25 | # Ignore uploaded files in development. 26 | /storage/* 27 | !/storage/.keep 28 | /tmp/storage/* 29 | !/tmp/storage/ 30 | !/tmp/storage/.keep 31 | 32 | # Ignore master key for decrypting credentials and more. 33 | /config/master.key 34 | -------------------------------------------------------------------------------- /JavaScriptAsynchronous/timerPromise.js: -------------------------------------------------------------------------------- 1 | /************************************************************************************ 2 | * 3 | * timerPromise.js 4 | * 5 | * Using promises lets us clean up code. 6 | * 7 | ************************************************************************************/ 8 | 9 | 10 | let setTimer = (delay) => { 11 | return new Promise( (resolve, reject) => { 12 | setTimeout(resolve, delay) 13 | }) 14 | } 15 | 16 | console.log("(c1) Begin.") 17 | setTimer(1000).then( () => { 18 | console.log("(c2) It's time to wake up.") 19 | return setTimer(1500) 20 | }).then( () => { 21 | console.log("(c3) You should be out of bed by now.") 22 | return setTimer(2000) 23 | }).then( () => { 24 | console.log("(c4) Breakfast time is over. Go brush your teeth.") 25 | return setTimer(500) 26 | }).then( () => { 27 | console.log("(c5) That's long enough. Now get to the bus!") 28 | }) -------------------------------------------------------------------------------- /ExpressMVC/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'env': { 3 | 'node': true, 4 | 'es2021': true, 5 | 'jest': true 6 | }, 7 | 'extends': 'eslint:recommended', 8 | 'overrides': [ 9 | ], 10 | 'parserOptions': { 11 | 'ecmaVersion': 'latest', 12 | 'sourceType': 'script' 13 | }, 14 | 'rules': { 15 | 'indent': [ 16 | 'error', 17 | 4 18 | ], 19 | 'linebreak-style': [ 20 | 'error', 21 | 'unix' 22 | ], 23 | 'quotes': [ 24 | 'error', 25 | 'single' 26 | ], 27 | 'semi': [ 28 | 'error', 29 | 'never' 30 | ], 31 | 'no-unused-vars': [ 32 | 'error', { 33 | 'argsIgnorePattern': '^_', 34 | 'varsIgnorePattern': '^_' 35 | } 36 | ], 37 | 'react/prop-types': 0 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ExpressMVCSimple/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'env': { 3 | 'node': true, 4 | 'es2021': true, 5 | 'jest': true 6 | }, 7 | 'extends': 'eslint:recommended', 8 | 'overrides': [ 9 | ], 10 | 'parserOptions': { 11 | 'ecmaVersion': 'latest', 12 | 'sourceType': 'script' 13 | }, 14 | 'rules': { 15 | 'indent': [ 16 | 'error', 17 | 4 18 | ], 19 | 'linebreak-style': [ 20 | 'error', 21 | 'unix' 22 | ], 23 | 'quotes': [ 24 | 'error', 25 | 'single' 26 | ], 27 | 'semi': [ 28 | 'error', 29 | 'never' 30 | ], 31 | 'no-unused-vars': [ 32 | 'error', { 33 | 'argsIgnorePattern': '^_', 34 | 'varsIgnorePattern': '^_' 35 | } 36 | ], 37 | 'react/prop-types': 0 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ExpressSession/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'env': { 3 | 'node': true, 4 | 'es2021': true, 5 | 'jest': true 6 | }, 7 | 'extends': 'eslint:recommended', 8 | 'overrides': [ 9 | ], 10 | 'parserOptions': { 11 | 'ecmaVersion': 'latest', 12 | 'sourceType': 'script' 13 | }, 14 | 'rules': { 15 | 'indent': [ 16 | 'error', 17 | 4 18 | ], 19 | 'linebreak-style': [ 20 | 'error', 21 | 'unix' 22 | ], 23 | 'quotes': [ 24 | 'error', 25 | 'single' 26 | ], 27 | 'semi': [ 28 | 'error', 29 | 'never' 30 | ], 31 | 'no-unused-vars': [ 32 | 'error', { 33 | 'argsIgnorePattern': '^_', 34 | 'varsIgnorePattern': '^_' 35 | } 36 | ], 37 | 'react/prop-types': 0 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /JavaScriptDOM/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'env': { 3 | 'browser': true, 4 | 'es2021': true, 5 | 'jest': true 6 | }, 7 | 'extends': 'eslint:recommended', 8 | 'overrides': [ 9 | ], 10 | 'parserOptions': { 11 | 'ecmaVersion': 'latest', 12 | 'sourceType': 'module' 13 | }, 14 | 'rules': { 15 | 'indent': [ 16 | 'error', 17 | 4 18 | ], 19 | 'linebreak-style': [ 20 | 'error', 21 | 'unix' 22 | ], 23 | 'quotes': [ 24 | 'error', 25 | 'single' 26 | ], 27 | 'semi': [ 28 | 'error', 29 | 'never' 30 | ], 31 | 'no-unused-vars': [ 32 | 'error', { 33 | 'argsIgnorePattern': '^_', 34 | 'varsIgnorePattern': '^_' 35 | } 36 | ], 37 | 'react/prop-types': 0 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ExpressMVC/views/toyShow.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | 13 | 14 |

Toy Details

15 | 16 | Name: 17 | <%= toy.name %> 18 |
19 | 20 | Description: 21 | <%= toy.description %> 22 |
23 | Manufacturer: 24 | <%= toy.manufacturer %> 25 |
26 | Price: $ 27 | <%= toy.price %> 28 |
29 | 30 |

31 | Back 32 | Edit 33 |

34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /ExpressMVCSqliteCallbacks/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'env': { 3 | 'node': true, 4 | 'es2021': true, 5 | 'jest': true 6 | }, 7 | 'extends': 'eslint:recommended', 8 | 'overrides': [ 9 | ], 10 | 'parserOptions': { 11 | 'ecmaVersion': 'latest', 12 | 'sourceType': 'script' 13 | }, 14 | 'rules': { 15 | 'indent': [ 16 | 'error', 17 | 4 18 | ], 19 | 'linebreak-style': [ 20 | 'error', 21 | 'unix' 22 | ], 23 | 'quotes': [ 24 | 'error', 25 | 'single' 26 | ], 27 | 'semi': [ 28 | 'error', 29 | 'never' 30 | ], 31 | 'no-unused-vars': [ 32 | 'error', { 33 | 'argsIgnorePattern': '^_', 34 | 'varsIgnorePattern': '^_' 35 | } 36 | ], 37 | 'react/prop-types': 0 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ExpressMVCSqlitePromises/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'env': { 3 | 'node': true, 4 | 'es2021': true, 5 | 'jest': true 6 | }, 7 | 'extends': 'eslint:recommended', 8 | 'overrides': [ 9 | ], 10 | 'parserOptions': { 11 | 'ecmaVersion': 'latest', 12 | 'sourceType': 'script' 13 | }, 14 | 'rules': { 15 | 'indent': [ 16 | 'error', 17 | 4 18 | ], 19 | 'linebreak-style': [ 20 | 'error', 21 | 'unix' 22 | ], 23 | 'quotes': [ 24 | 'error', 25 | 'single' 26 | ], 27 | 'semi': [ 28 | 'error', 29 | 'never' 30 | ], 31 | 'no-unused-vars': [ 32 | 'error', { 33 | 'argsIgnorePattern': '^_', 34 | 'varsIgnorePattern': '^_' 35 | } 36 | ], 37 | 'react/prop-types': 0 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ExpressMVCSimple/views/toyShow.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | 13 | 14 |

Toy Details

15 | 16 | Name: 17 | <%= toy.name %> 18 |
19 | 20 | Description: 21 | <%- toy.description %> 22 |
23 | Manufacturer: 24 | <%= toy.manufacturer %> 25 |
26 | Price: $ 27 | <%= toy.price %> 28 |
29 | 30 |

31 | Back 32 | Edit 33 |

34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /ExpressSession/views/toyShow.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | 13 | 14 |

Toy Details

15 | 16 | Name: 17 | <%= toy.name %> 18 |
19 | 20 | Description: 21 | <%- toy.description %> 22 |
23 | Manufacturer: 24 | <%= toy.manufacturer %> 25 |
26 | Price: $ 27 | <%= toy.price %> 28 |
29 | 30 |

31 | Back 32 | Edit 33 |

34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /ExpressIntro/use_mini_express.py: -------------------------------------------------------------------------------- 1 | # An example usage of the "mini_express" module 2 | 3 | import mini_express 4 | 5 | # 6 | # Define action when route is requested 7 | # 8 | 9 | def root_route(params): 10 | return "Hello, Everybody. Welcome to my web site." 11 | 12 | def about_route(params): 13 | return "I am eight years old and like fishing." 14 | 15 | def help_route(params): 16 | return "There isn't anything to help with. This site doesn't do anything :)" 17 | 18 | def calculator_route(params): 19 | sum = float(params['a']) + float(params['b']) 20 | return f"Thanks for using the calculator.\n{params['a']} + {params['b']} = {sum}" 21 | 22 | 23 | # 24 | # Configure and launch server 25 | # 26 | 27 | me = mini_express.MiniExpress() 28 | 29 | # me.add_route('/', root_route) 30 | # me.add_route('/about', about_route) 31 | # me.add_route('/help', help_route) 32 | # me.add_route('/calculator', calculator_route) 33 | 34 | me.make_routes() 35 | 36 | me.serve(8084) -------------------------------------------------------------------------------- /ExpressMVCSqliteCallbacks/views/toyShow.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | 13 | 14 |

Toy Details

15 | 16 | Name: 17 | <%= toy.name %> 18 |
19 | 20 | Description: 21 | <%- toy.description %> 22 |
23 | Manufacturer: 24 | <%= toy.manufacturer %> 25 |
26 | Price: $ 27 | <%= toy.price %> 28 |
29 | 30 |

31 | Back 32 | Edit 33 |

34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /ExpressMVCSqlitePromises/views/toyShow.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | 13 | 14 |

Toy Details

15 | 16 | Name: 17 | <%= toy.name %> 18 |
19 | 20 | Description: 21 | <%- toy.description %> 22 |
23 | Manufacturer: 24 | <%= toy.manufacturer %> 25 |
26 | Price: $ 27 | <%= toy.price %> 28 |
29 | 30 |

31 | Back 32 | Edit 33 |

34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Fly/StaticOnly/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello from Fly 6 | 7 | 35 | 36 | 37 | 38 |

Hello from Fly.io with a static web site

39 |

Or goodbye.

40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Templating/colorDemo_jinja.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {% set colors = [ 'red', 'green', 'blue', 'orange', 'yellow', 'purple'] %} 4 | 5 | 6 | 7 | Color Samples using Jinja 8 | 9 | 18 | 19 | 20 | 21 |

List Colors (Jinja)

22 | 23 | This section simply lists the color names because the code is simpler. 24 | 25 |
    26 | {% for color in colors %} 27 |
  • {{ color }}
  • 28 | {% endfor %} 29 |
30 | 31 |

Show Colors

32 | This section shows the colors. Same ideas as above, but the code is a little harder to read. 33 | 34 |
    35 | {% for color in colors %} 36 |
  • {{color}}
  • 37 | {% endfor %} 38 |
39 | 40 | 41 | -------------------------------------------------------------------------------- /ColorListAPI_rails/config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t "hello" 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t("hello") %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # The following keys must be escaped otherwise they will not be retrieved by 20 | # the default I18n backend: 21 | # 22 | # true, false, on, off, yes, no 23 | # 24 | # Instead, surround them with single quotes. 25 | # 26 | # en: 27 | # "true": "foo" 28 | # 29 | # To learn more, please read the Rails Internationalization guide 30 | # available at https://guides.rubyonrails.org/i18n.html. 31 | 32 | en: 33 | hello: "Hello world" 34 | -------------------------------------------------------------------------------- /ColorList1_fetch/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "colorList", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.16.5", 7 | "@testing-library/react": "^13.4.0", 8 | "@testing-library/user-event": "^13.5.0", 9 | "react": "^18.2.0", 10 | "react-dom": "^18.2.0", 11 | "react-icons": "^4.6.0", 12 | "web-vitals": "^2.1.4" 13 | }, 14 | "scripts": { 15 | "start": "react-scripts start", 16 | "build": "react-scripts build", 17 | "test": "react-scripts test", 18 | "eject": "react-scripts eject" 19 | }, 20 | "eslintConfig": { 21 | "extends": [ 22 | "react-app", 23 | "react-app/jest" 24 | ] 25 | }, 26 | "browserslist": { 27 | "production": [ 28 | ">0.2%", 29 | "not dead", 30 | "not op_mini all" 31 | ], 32 | "development": [ 33 | "last 1 chrome version", 34 | "last 1 firefox version", 35 | "last 1 safari version" 36 | ] 37 | }, 38 | "devDependencies": { 39 | "react-scripts": "^5.0.1" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /JavaScriptAsADT/dog.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Dog Example 6 | 7 | 8 | 9 | 10 | 11 |

OO JavaScript --- Complete Example

12 | 13 |
14 |
15 | 16 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /ColorList2_edit/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "colorList2_edit", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.16.5", 7 | "@testing-library/react": "^13.4.0", 8 | "@testing-library/user-event": "^13.5.0", 9 | "react": "^18.2.0", 10 | "react-dom": "^18.2.0", 11 | "react-icons": "^4.6.0", 12 | "web-vitals": "^2.1.4" 13 | }, 14 | "scripts": { 15 | "start": "react-scripts start", 16 | "build": "react-scripts build", 17 | "test": "react-scripts test", 18 | "eject": "react-scripts eject" 19 | }, 20 | "eslintConfig": { 21 | "extends": [ 22 | "react-app", 23 | "react-app/jest" 24 | ] 25 | }, 26 | "browserslist": { 27 | "production": [ 28 | ">0.2%", 29 | "not dead", 30 | "not op_mini all" 31 | ], 32 | "development": [ 33 | "last 1 chrome version", 34 | "last 1 firefox version", 35 | "last 1 safari version" 36 | ] 37 | }, 38 | "devDependencies": { 39 | "react-scripts": "^5.0.1" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ExpressMVC/views/toyIndex.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

Toys, Toys, Toys!

5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | <% toys.forEach( (toy) => { %> 16 | 17 | 20 | 23 | 26 | 29 | 33 | <% }) %> 34 | 35 |
NameDescriptionManufacturerPrice
18 | <%= toy.name %> 19 | 21 | <%= toy.description %> 22 | 24 | <%= toy.manufacturer %> 25 | 27 | <%= toy.price %> 28 | 30 | Show 31 | Edit 32 |
36 | 37 | 38 | New 39 | 40 | -------------------------------------------------------------------------------- /ExpressIntro/first_sendHTML.js: -------------------------------------------------------------------------------- 1 | // Demonstrates a couple of routes using send only 2 | 3 | // Express documentation: https://expressjs.com/en/api.html 4 | 5 | /* Import the express npm module */ 6 | const express = require('express') 7 | 8 | /* Instantiate a server object*/ 9 | const app = express() 10 | const port = 3000 11 | 12 | 13 | /* Notice that these next few lines of code don't have any immediate effect. 14 | They are telling the server what function to call _when_ something "interesting" 15 | happens. 16 | 17 | The calls to app.get just set up a map of paths to the code that should be run for that path. 18 | */ 19 | 20 | function root_callback(_req, res) { 21 | res.send('

Root

Hello World!
(This is the root route)') 22 | } 23 | app.get('/', root_callback) 24 | 25 | function about_callback(_req, res) { 26 | res.send('

About

This is an absurdly simple express server with two routes.') 27 | } 28 | app.get('/about', about_callback) 29 | 30 | /* Launch the server */ 31 | app.listen(port, () => console.log(`Example app listening on port ${port}!`)) -------------------------------------------------------------------------------- /ExpressMVCSimple/views/toyIndex.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

Toys, Toys, Toys!

5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | <% toys.forEach( (toy) => { %> 16 | 17 | 20 | 23 | 26 | 29 | 33 | <% }) %> 34 | 35 |
NameDescriptionManufacturerPrice
18 | <%= toy.name %> 19 | 21 | <%= toy.description %> 22 | 24 | <%= toy.manufacturer %> 25 | 27 | <%= toy.price %> 28 | 30 | Show 31 | Edit 32 |
36 | 37 | 38 | New 39 | 40 | -------------------------------------------------------------------------------- /ExpressMVCSqlitePromises/views/toyIndex.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

Toys, Toys, Toys!

5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | <% toys.forEach( (toy) => { %> 16 | 17 | 20 | 23 | 26 | 29 | 33 | <% }) %> 34 | 35 |
NameDescriptionManufacturerPrice
18 | <%= toy.name %> 19 | 21 | <%= toy.description %> 22 | 24 | <%= toy.manufacturer %> 25 | 27 | <%= toy.price %> 28 | 30 | Show 31 | Edit 32 |
36 | 37 | 38 | New 39 | 40 | -------------------------------------------------------------------------------- /ExpressMVCSqliteCallbacks/views/toyIndex.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

Toys, Toys, Toys!

5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | <% toys.forEach( (toy) => { %> 16 | 17 | 20 | 23 | 26 | 29 | 33 | <% }) %> 34 | 35 |
NameDescriptionManufacturerPrice
18 | <%= toy.name %> 19 | 21 | <%= toy.description %> 22 | 24 | <%= toy.manufacturer %> 25 | 27 | <%= toy.price %> 28 | 30 | Show 31 | Edit 32 |
36 | 37 | 38 | New 39 | 40 | -------------------------------------------------------------------------------- /ReactRecipe/exampleComponent1.jsx: -------------------------------------------------------------------------------- 1 | // Sample code available on GitHub: https://github.com/kurmasz-SampleCode/CIS371-SampleCode 2 | // Based on an example from Learning React, 2nd Edition by Porcello and Banks. 3 | // This example is in React/exampleComponent1.jsx 4 | 5 | /* Functional React component *without* JSX */ 6 | function IngredientsList1() { 7 | return React.createElement( 8 | "ul", 9 | { className: "ingredients" }, 10 | React.createElement("li", null, "1 cup rolled oats"), 11 | React.createElement("li", null, "2 Tablespoons peanut butter"), 12 | React.createElement("li", null, "1/4 cup walnuts"), 13 | React.createElement("li", null, "1/4 cup dried cranberries"), 14 | React.createElement("li", null, "1 banana"), 15 | ); 16 | } 17 | 18 | /* Functional React component *with* JSX */ 19 | function IngredientsList2() { 20 | return
    21 |
  • 1 cup rolled oats
  • 22 |
  • 2 Tablespoons peanut butter
  • 23 |
  • 1/4 cup walnuts
  • 24 |
  • 1/4 cup dried cranberries
  • 25 |
  • 1 banana
  • 26 |
; 27 | } 28 | -------------------------------------------------------------------------------- /ColorList3_routing/src/Color.test.js: -------------------------------------------------------------------------------- 1 | import { render, screen, fireEvent } from '@testing-library/React' 2 | import Color from './Color' 3 | import React from 'react' 4 | 5 | // React recommends structuring tests to _not_ look for structure. 6 | // (But, it can be useful on occasion.) 7 | test('contains a colorbox', () => { 8 | render() 9 | expect(document.querySelector('.colorBox')).toBeTruthy() 10 | }) 11 | 12 | 13 | // React prefers testing for things the user can see. 14 | test('displays the title', () => { 15 | render() 16 | expect(screen.getByText('The title')).toBeInTheDocument() 17 | }) 18 | 19 | test('clicking \'Edit\' passes the color', () => { 20 | 21 | let editCallback = jest.fn() 22 | render() 23 | 24 | const button = document.querySelector('button') 25 | expect(button.innerHTML).toBe('Edit') 26 | fireEvent.click(button) 27 | expect(editCallback).toHaveBeenCalledWith('#00ff00') 28 | }) -------------------------------------------------------------------------------- /ColorListAPI_rails/config/application.rb: -------------------------------------------------------------------------------- 1 | require_relative "boot" 2 | 3 | require "rails/all" 4 | 5 | # Require the gems listed in Gemfile, including any gems 6 | # you've limited to :test, :development, or :production. 7 | Bundler.require(*Rails.groups) 8 | 9 | module ColorListApiRails 10 | class Application < Rails::Application 11 | # Initialize configuration defaults for originally generated Rails version. 12 | config.load_defaults 7.0 13 | 14 | # Configuration for the application, engines, and railties goes here. 15 | # 16 | # These settings can be overridden in specific environments using the files 17 | # in config/environments, which are processed later. 18 | # 19 | # config.time_zone = "Central Time (US & Canada)" 20 | # config.eager_load_paths << Rails.root.join("extras") 21 | 22 | # Only loads a smaller set of middleware suitable for API only apps. 23 | # Middleware like session, flash, cookies can be added back manually. 24 | # Skip views, helpers and assets when generating a new resource. 25 | config.api_only = true 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /ColorListAPI_rails/db/schema.rb: -------------------------------------------------------------------------------- 1 | # This file is auto-generated from the current state of the database. Instead 2 | # of editing this file, please use the migrations feature of Active Record to 3 | # incrementally modify your database, and then regenerate this schema definition. 4 | # 5 | # This file is the source Rails uses to define your schema when running `bin/rails 6 | # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to 7 | # be faster and is potentially less error prone than running all of your 8 | # migrations from scratch. Old migrations may fail to apply correctly if those 9 | # migrations use external dependencies or application code. 10 | # 11 | # It's strongly recommended that you check this file into your version control system. 12 | 13 | ActiveRecord::Schema[7.0].define(version: 2024_03_10_225313) do 14 | create_table "colors", force: :cascade do |t| 15 | t.string "title" 16 | t.string "uuid" 17 | t.integer "color" 18 | t.integer "rating" 19 | t.datetime "created_at", null: false 20 | t.datetime "updated_at", null: false 21 | end 22 | 23 | end 24 | -------------------------------------------------------------------------------- /ReactJSXIntro/clientSideDomCreation.js: -------------------------------------------------------------------------------- 1 | // Create an entire web page in JavaScript. 2 | // (No, you would not want to write code this way. 3 | // I'm just showing you what React does behind the scenes.) 4 | 5 | // Create a container for all the dynamic content. 6 | let div = document.createElement("div"); 7 | 8 | // Create a paragraph and fill it with text. 9 | let p = document.createElement("p") 10 | p.innerText = "Here is a list of some states" 11 | // add the paragraph to the div. 12 | div.appendChild(p); 13 | 14 | // Create a ul and add it to the div. 15 | let ul = document.createElement("ul"); 16 | 17 | let states = ['Alabama', 'Alaska', 'Arizona', 'California', 'Colorado', 'Georgia', 18 | 'Florida', 'Michigan', 'Minnesota', '...', '(you get the point :)' 19 | ]; 20 | 21 | states.forEach((state) => { 22 | let li = document.createElement("li"); 23 | li.innerText = state; 24 | ul.appendChild(li); 25 | }); 26 | 27 | div.appendChild(ul); 28 | 29 | // insert div into the web page. 30 | let main = document.getElementById('main'); 31 | // Remove the placeholder text 32 | main.innerText = ''; 33 | main.appendChild(div); -------------------------------------------------------------------------------- /SimpleHTTPServer/fetch_temp_data.py: -------------------------------------------------------------------------------- 1 | """ 2 | fetch_demo_data.py 3 | 4 | Use various APIs to fetch data for various demos. 5 | 6 | GVSU CIS 371 W25 7 | """ 8 | import json 9 | import urllib.request 10 | 11 | def temp_for_location(latitude, longitude): 12 | """ 13 | Use the open-meteo API to fetch the current temperature at a given location 14 | """ 15 | url = f'https://api.open-meteo.com/v1/forecast?latitude={latitude}&longitude={longitude}¤t=temperature_2m&temperature_unit=fahrenheit' 16 | print(url) 17 | 18 | # Open a URL 19 | with urllib.request.urlopen(url) as response: 20 | content = response.read() 21 | 22 | data = json.loads(content.decode()) 23 | return data['current']['temperature_2m'] 24 | 25 | def info_for_zip(zip_code): 26 | """ 27 | Use the zippopatm API to get the location of a US zip code. 28 | """ 29 | zip_url = f"https://api.zippopotam.us/us/{zip_code}" 30 | print(zip_url) 31 | with urllib.request.urlopen(zip_url) as response: 32 | content = response.read() 33 | zip_data = json.loads(content.decode()) 34 | return zip_data['places'][0] -------------------------------------------------------------------------------- /ExpressMVCSimple/Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = docker/dockerfile:1 2 | 3 | # Adjust NODE_VERSION as desired 4 | ANODE_VERSION=22.13.0RG 5 | FROM node:${NODE_VERSION}-slim AS base 6 | 7 | LABEL fly_launch_runtime="Node.js" 8 | 9 | # Node.js app lives here 10 | WORKDIR /app 11 | 12 | # Set production environment 13 | ENV NODE_ENV="production" 14 | 15 | 16 | # Throw-away build stage to reduce size of final image 17 | FROM base AS build 18 | 19 | # Install packages needed to build node modules 20 | RUN apt-get update -qq && \ 21 | apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3 22 | 23 | # Install node modules 24 | COPY package-lock.json package.json ./ 25 | RUN npm ci 26 | 27 | # Copy application code 28 | COPY . . 29 | 30 | 31 | # Final stage for app image 32 | FROM base 33 | 34 | # Copy built application 35 | COPY --from=build /app /app 36 | 37 | # Setup sqlite3 on a separate volume 38 | RUN mkdir -p /data 39 | VOLUME /data 40 | 41 | # Start the server by default, this can be overwritten at runtime 42 | EXPOSE 3000 43 | ENV DATABASE_URL="file:///data/sqlite.db" 44 | CMD [ "node", "index.js" ] 45 | -------------------------------------------------------------------------------- /ExpressSession/views/toyIndex.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

Toys, Toys, Toys!

5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | <% toys.forEach( (toy) => { %> 16 | 17 | 20 | 23 | 26 | 29 | 33 | <% }) %> 34 | 35 |
NameDescriptionManufacturerPrice
18 | <%= toy.name %> 19 | 21 | <%= toy.description %> 22 | 24 | <%= toy.manufacturer %> 25 | 27 | <%= toy.price %> 28 | 30 | Show 31 | Edit 32 |
36 | 37 | 38 | New 39 | <% if (showLogout) { %> 40 | Logout 41 | <% } %> 42 | -------------------------------------------------------------------------------- /JavaScriptDOM/rawDomNavigation.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Sample page 1 4 | 5 | 6 |

Sample 1

7 | 8 | 9 | 10 |

This is a sample html page with which we can explore the parse tree.

11 | 12 |
    13 |
  • Kent
  • 14 |
  • Ottawa
  • 15 |
  • Genessee 16 |
      17 |
    • Flint
    • 18 |
    • Flushing
    • 19 |
    • Linden
    • 20 |
    • Fenton
    • 21 |
    22 |
  • 23 |
  • Lapeer
  • 24 |
25 | 26 | A link to YouTube. 27 | 28 | 29 | 30 |
31 | 32 | Some more text below the horizontal line. 33 | 34 | 35 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /HTMLForms/Flask/app.py: -------------------------------------------------------------------------------- 1 | """ 2 | Demonstrates the different input choices for an HTML form. 3 | 4 | GVSU CIS 371 W25 5 | """ 6 | 7 | import flask 8 | import argparse 9 | 10 | app = flask.Flask(__name__) 11 | 12 | 13 | # 14 | # Default route. Returns a specific HTML file. 15 | # 16 | @app.route('/', methods=['GET', 'POST']) 17 | def root_route(): 18 | # Note: flask.request.args and flask.request.form are both 19 | # ImmutableMultiDict because there may be more than one input 20 | # in the form with the same name --- especially with checkboxes 21 | print(flask.request.args) 22 | return flask.render_template('form_demo.j2', 23 | query_string = flask.request.args, 24 | form_data = flask.request.form) 25 | 26 | if __name__ == '__main__': 27 | parser = argparse.ArgumentParser(description='Run a Flask server to serve files from the public directory.') 28 | parser.add_argument('--port', '-p', type=int, default=5000, help='Port to run the server on (default: 5000)') 29 | args = parser.parse_args() 30 | 31 | app.run(debug=True, port=args.port) 32 | 33 | 34 | -------------------------------------------------------------------------------- /ExpressIntro/views/multTable.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 19 | 20 | 21 | 22 |

Multiplication Table

23 | 24 | 25 | 26 | 27 | 28 | <% for (let c = 0; c < columns; ++c) { %> 29 | 32 | <% } %> 33 | 34 | 35 | <% for (let r = 0; r < rows; ++r) { %> 36 | 37 | 40 | <% for (let c = 0; c < columns; ++c) { %> 41 | 44 | <% } %> 45 | 46 | <% } %> 47 |
x 30 | <%= c %> 31 |
38 | <%= r %> 39 | 42 | <%= r*c %> 43 |
48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /Templating/colorDemo.pug: -------------------------------------------------------------------------------- 1 | // PUG is a HAML-like template engine for JavaScript 2 | 3 | - var colors = ['red', 'green', 'blue', 'orange', 'pink', 'purple', 'violet', 'lightgreen', 'fuchsia']; 4 | 5 | html 6 | head 7 | title Color Samples using PUG 8 | style !{colors.map( color => `.color-${color} { color: ${color};}`).join("\n")} 9 | 10 | body 11 | h1 List Colors (PUG) 12 | 13 | p This section simply lists the color names because the code is simpler. 14 | 15 | ul 16 | each color in colors 17 | li= color 18 | 19 | h1 Show Colors 20 | 21 | p This section shows the colors. Same ideas as above, but the code is a little harder to read. 22 | 23 | ul 24 | each color in colors 25 | li 26 | span(class=`color-${color}`)= color 27 | 28 | 29 | 30 | h1 Show Colors (v2) 31 | 32 | p This section also shows the colors, but uses the map method. Some may find this code easier to follow. 33 | 34 | // The ~!{} syntax is needed so that the
  • tags don't get escaped into <li> 35 | ul !{colors.map( color => `
  • ${color}
  • `).join("\n")} -------------------------------------------------------------------------------- /ColorListAPI_rails/bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require "fileutils" 3 | 4 | # path to your application root. 5 | APP_ROOT = File.expand_path("..", __dir__) 6 | 7 | def system!(*args) 8 | system(*args) || abort("\n== Command #{args} failed ==") 9 | end 10 | 11 | FileUtils.chdir APP_ROOT do 12 | # This script is a way to set up or update your development environment automatically. 13 | # This script is idempotent, so that you can run it at any time and get an expectable outcome. 14 | # Add necessary setup steps to this file. 15 | 16 | puts "== Installing dependencies ==" 17 | system! "gem install bundler --conservative" 18 | system("bundle check") || system!("bundle install") 19 | 20 | # puts "\n== Copying sample files ==" 21 | # unless File.exist?("config/database.yml") 22 | # FileUtils.cp "config/database.yml.sample", "config/database.yml" 23 | # end 24 | 25 | puts "\n== Preparing database ==" 26 | system! "bin/rails db:prepare" 27 | 28 | puts "\n== Removing old logs and tempfiles ==" 29 | system! "bin/rails log:clear tmp:clear" 30 | 31 | puts "\n== Restarting application server ==" 32 | system! "bin/rails restart" 33 | end 34 | -------------------------------------------------------------------------------- /ExpressMVC/models/User.js: -------------------------------------------------------------------------------- 1 | class User { 2 | constructor(description) { 3 | // if description is null or undefined, we want to create an "empty" Toy object. 4 | if (description) { 5 | this.id = description.id 6 | this.fname = description.fname 7 | this.lname = description.lname 8 | this.email = description.email 9 | } 10 | } 11 | 12 | static all() { 13 | return User.allUsers 14 | } 15 | 16 | static find(id) { 17 | return User.allUsers.find((item) => item.id == id) 18 | } 19 | 20 | // Example of "deconstructing" an object 21 | static find2(theId) { 22 | return User.allUsers.find(({ id }) => theId === id) 23 | } 24 | } 25 | 26 | User.allUsers = [ 27 | new User({ id: 1, fname: 'George', lname: 'Washington', email: 'george@washington.com' }), 28 | new User({ id: 2, fname: 'John', lname: 'Adams', email: 'john@adams.com' }), 29 | new User({ id: 3, fname: 'Thomas', lname: 'Jefferson', email: 'thomas@jefferson.com' }), 30 | new User({ id: 3, fname: 'James', lname: 'Madison', email: 'james@madison.com' }), 31 | ] 32 | 33 | module.exports = User -------------------------------------------------------------------------------- /ExpressMVCSimple/models/User.js: -------------------------------------------------------------------------------- 1 | class User { 2 | constructor(description) { 3 | // if description is null or undefined, we want to create an "empty" Toy object. 4 | if (description) { 5 | this.id = description.id 6 | this.fname = description.fname 7 | this.lname = description.lname 8 | this.email = description.email 9 | } 10 | } 11 | 12 | static all() { 13 | return User.allUsers 14 | } 15 | 16 | static find(id) { 17 | return User.allUsers.find((item) => item.id == id) 18 | } 19 | 20 | // Example of "deconstructing" an object 21 | static find2(theId) { 22 | return User.allUsers.find(({ id }) => theId === id) 23 | } 24 | } 25 | 26 | User.allUsers = [ 27 | new User({ id: 1, fname: 'George', lname: 'Washington', email: 'george@washington.com' }), 28 | new User({ id: 2, fname: 'John', lname: 'Adams', email: 'john@adams.com' }), 29 | new User({ id: 3, fname: 'Thomas', lname: 'Jefferson', email: 'thomas@jefferson.com' }), 30 | new User({ id: 3, fname: 'James', lname: 'Madison', email: 'james@madison.com' }), 31 | ] 32 | 33 | module.exports = User -------------------------------------------------------------------------------- /ExpressSession/models/User.js: -------------------------------------------------------------------------------- 1 | class User { 2 | constructor(description) { 3 | // if description is null or undefined, we want to create an "empty" Toy object. 4 | if (description) { 5 | this.id = description.id 6 | this.fname = description.fname 7 | this.lname = description.lname 8 | this.email = description.email 9 | } 10 | } 11 | 12 | static all() { 13 | return User.allUsers 14 | } 15 | 16 | static find(id) { 17 | return User.allUsers.find((item) => item.id == id) 18 | } 19 | 20 | // Example of "deconstructing" an object 21 | static find2(theId) { 22 | return User.allUsers.find(({ id }) => theId === id) 23 | } 24 | } 25 | 26 | User.allUsers = [ 27 | new User({ id: 1, fname: 'George', lname: 'Washington', email: 'george@washington.com' }), 28 | new User({ id: 2, fname: 'John', lname: 'Adams', email: 'john@adams.com' }), 29 | new User({ id: 3, fname: 'Thomas', lname: 'Jefferson', email: 'thomas@jefferson.com' }), 30 | new User({ id: 3, fname: 'James', lname: 'Madison', email: 'james@madison.com' }), 31 | ] 32 | 33 | module.exports = User -------------------------------------------------------------------------------- /ColorListAPI_rails/test/controllers/colors_controller_test.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | 3 | class ColorsControllerTest < ActionDispatch::IntegrationTest 4 | setup do 5 | @color = colors(:one) 6 | end 7 | 8 | test "should get index" do 9 | get colors_url, as: :json 10 | assert_response :success 11 | end 12 | 13 | test "should create color" do 14 | assert_difference("Color.count") do 15 | post colors_url, params: { color: { color: @color.color, rating: @color.rating, title: @color.title, uuid: @color.uuid } }, as: :json 16 | end 17 | 18 | assert_response :created 19 | end 20 | 21 | test "should show color" do 22 | get color_url(@color), as: :json 23 | assert_response :success 24 | end 25 | 26 | test "should update color" do 27 | patch color_url(@color), params: { color: { color: @color.color, rating: @color.rating, title: @color.title, uuid: @color.uuid } }, as: :json 28 | assert_response :success 29 | end 30 | 31 | test "should destroy color" do 32 | assert_difference("Color.count", -1) do 33 | delete color_url(@color), as: :json 34 | end 35 | 36 | assert_response :no_content 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /ExpressMVCSqliteCallbacks/models/User.js: -------------------------------------------------------------------------------- 1 | class User { 2 | constructor(description) { 3 | // if description is null or undefined, we want to create an "empty" Toy object. 4 | if (description) { 5 | this.id = description.id 6 | this.fname = description.fname 7 | this.lname = description.lname 8 | this.email = description.email 9 | } 10 | } 11 | 12 | static all() { 13 | return User.allUsers 14 | } 15 | 16 | static find(id) { 17 | return User.allUsers.find((item) => item.id == id) 18 | } 19 | 20 | // Example of "deconstructing" an object 21 | static find2(theId) { 22 | return User.allUsers.find(({ id }) => theId === id) 23 | } 24 | } 25 | 26 | User.allUsers = [ 27 | new User({ id: 1, fname: 'George', lname: 'Washington', email: 'george@washington.com' }), 28 | new User({ id: 2, fname: 'John', lname: 'Adams', email: 'john@adams.com' }), 29 | new User({ id: 3, fname: 'Thomas', lname: 'Jefferson', email: 'thomas@jefferson.com' }), 30 | new User({ id: 3, fname: 'James', lname: 'Madison', email: 'james@madison.com' }), 31 | ] 32 | 33 | module.exports = User -------------------------------------------------------------------------------- /ExpressMVCSqlitePromises/models/User.js: -------------------------------------------------------------------------------- 1 | class User { 2 | constructor(description) { 3 | // if description is null or undefined, we want to create an "empty" Toy object. 4 | if (description) { 5 | this.id = description.id 6 | this.fname = description.fname 7 | this.lname = description.lname 8 | this.email = description.email 9 | } 10 | } 11 | 12 | static all() { 13 | return User.allUsers 14 | } 15 | 16 | static find(id) { 17 | return User.allUsers.find((item) => item.id == id) 18 | } 19 | 20 | // Example of "deconstructing" an object 21 | static find2(theId) { 22 | return User.allUsers.find(({ id }) => theId === id) 23 | } 24 | } 25 | 26 | User.allUsers = [ 27 | new User({ id: 1, fname: 'George', lname: 'Washington', email: 'george@washington.com' }), 28 | new User({ id: 2, fname: 'John', lname: 'Adams', email: 'john@adams.com' }), 29 | new User({ id: 3, fname: 'Thomas', lname: 'Jefferson', email: 'thomas@jefferson.com' }), 30 | new User({ id: 3, fname: 'James', lname: 'Madison', email: 'james@madison.com' }), 31 | ] 32 | 33 | module.exports = User -------------------------------------------------------------------------------- /FlaskImpl/test.py: -------------------------------------------------------------------------------- 1 | def decorator(func): 2 | def wrapper(): 3 | print("Something is happening before the function is called.") 4 | func() 5 | print("Something is happening after the function is called.") 6 | return wrapper 7 | 8 | print("Foo1") 9 | 10 | @decorator 11 | def say_whee(): 12 | print("Whee!") 13 | 14 | print("Foo2") 15 | 16 | say_whee() 17 | 18 | 19 | 20 | 21 | def filter_by_gpa(students, threshold): 22 | answer = [] 23 | for s in students: 24 | if s['gpa'] > threshold: 25 | answer.append(s) 26 | return answer 27 | 28 | def filter_by_credit_hours(students, threshold): 29 | answer = [] 30 | for s in students: 31 | if s['credit_hours'] > threshold: 32 | answer.append(s) 33 | return answer 34 | 35 | 36 | def filter(students, filter_fn): 37 | answer = [] 38 | for s in students: 39 | if filter_fn(s): 40 | answer.append(s) 41 | return answer 42 | 43 | def deans_list(student): 44 | return student['gpa'] >= 3.0 45 | 46 | def senior(student): 47 | return student['credit_hours'] >= 90 48 | 49 | filter(students, deans_list) 50 | filter(students, senior) 51 | -------------------------------------------------------------------------------- /ExpressIntro/Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = docker/dockerfile:1 2 | 3 | # Adjust NODE_VERSION as desired 4 | ARG NODE_VERSION=22.13.0 5 | FROM node:${NODE_VERSION}-slim AS base 6 | 7 | LABEL fly_launch_runtime="Node.js" 8 | 9 | # Node.js app lives here 10 | WORKDIR /app 11 | 12 | # Set production environment 13 | ENV NODE_ENV="production" 14 | 15 | 16 | # Throw-away build stage to reduce size of final image 17 | FROM base AS build 18 | 19 | # Install packages needed to build node modules 20 | RUN apt-get update -qq && \ 21 | apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3 22 | 23 | # Install node modules (copy files from host into image) 24 | COPY package-lock.json package.json ./ 25 | 26 | # A special "build install" that does things like 27 | # 1. Remove node_modules when done 28 | # 2. Install dependencies exactly as listed in package-lock.json 29 | RUN npm ci 30 | 31 | # Copy application code 32 | COPY . . 33 | 34 | # Final stage for app image 35 | FROM base 36 | 37 | # Copy built application 38 | COPY --from=build /app /app 39 | 40 | # Start the server by default, this can be overwritten at runtime 41 | EXPOSE 3000 42 | CMD [ "node", "index.js" ] 43 | -------------------------------------------------------------------------------- /ExpressMVC/test/MemoryToyDB.test.js: -------------------------------------------------------------------------------- 1 | const MemoryToyDB = require('../db/MemoryToyDB'); 2 | 3 | // Note: Technically the Toy object instantiated by .create should be mocked. 4 | 5 | describe("MemoryToyDB", () => { 6 | describe(".create", () => { 7 | it('saves the toy if valid', () => { 8 | let toysBefore = MemoryToyDB.allToys().length; 9 | let newToy = MemoryToyDB.create({ name: 'bob', price: 5, description: 'a Toy', manufacturer: 'Hasbro' }); 10 | expect(MemoryToyDB.allToys().length).toBe(toysBefore + 1); 11 | expect(newToy.id).toBeTruthy(); 12 | expect(MemoryToyDB.find(newToy.id)).toEqual(newToy); 13 | }); 14 | 15 | it('does not save toy if not valid', () => { 16 | let toysBefore = MemoryToyDB.allToys().length; 17 | let newToy = MemoryToyDB.create({ name: 'bo', price: 5, description: 'unique', manufacturer: 'Hasbro' }); 18 | expect(MemoryToyDB.allToys().length).toBe(toysBefore); 19 | expect(newToy.id).toBeFalsy(); 20 | expect(MemoryToyDB.allToys().find((item) => item.description === 'unique')).toBeFalsy(); 21 | }); 22 | }); // end create 23 | 24 | }); -------------------------------------------------------------------------------- /ExpressMVCSqliteCallbacks/test/MemoryToyDB.test.js: -------------------------------------------------------------------------------- 1 | const MemoryToyDB = require('../MemoryToyDB'); 2 | 3 | // Note: Technically the Toy object instantiated by .create should be mocked. 4 | 5 | describe("MemoryToyDB", () => { 6 | describe(".create", () => { 7 | it('saves the toy if valid', () => { 8 | let toysBefore = MemoryToyDB.allToys().length; 9 | let newToy = MemoryToyDB.create({ name: 'bob', price: 5, description: 'a Toy', manufacturer: 'Hasbro' }); 10 | expect(MemoryToyDB.allToys().length).toBe(toysBefore + 1); 11 | expect(newToy.id).toBeTruthy(); 12 | expect(MemoryToyDB.find(newToy.id)).toEqual(newToy); 13 | }); 14 | 15 | it('does not save toy if not valid', () => { 16 | let toysBefore = MemoryToyDB.allToys().length; 17 | let newToy = MemoryToyDB.create({ name: 'bo', price: 5, description: 'unique', manufacturer: 'Hasbro' }); 18 | expect(MemoryToyDB.allToys().length).toBe(toysBefore); 19 | expect(newToy.id).toBeFalsy(); 20 | expect(MemoryToyDB.allToys().find((item) => item.description === 'unique')).toBeFalsy(); 21 | }); 22 | }); // end create 23 | 24 | }); -------------------------------------------------------------------------------- /ExpressMVCSqlitePromises/test/MemoryToyDB.test.js: -------------------------------------------------------------------------------- 1 | const MemoryToyDB = require('../MemoryToyDB'); 2 | 3 | // Note: Technically the Toy object instantiated by .create should be mocked. 4 | 5 | describe("MemoryToyDB", () => { 6 | describe(".create", () => { 7 | it('saves the toy if valid', () => { 8 | let toysBefore = MemoryToyDB.allToys().length; 9 | let newToy = MemoryToyDB.create({ name: 'bob', price: 5, description: 'a Toy', manufacturer: 'Hasbro' }); 10 | expect(MemoryToyDB.allToys().length).toBe(toysBefore + 1); 11 | expect(newToy.id).toBeTruthy(); 12 | expect(MemoryToyDB.find(newToy.id)).toEqual(newToy); 13 | }); 14 | 15 | it('does not save toy if not valid', () => { 16 | let toysBefore = MemoryToyDB.allToys().length; 17 | let newToy = MemoryToyDB.create({ name: 'bo', price: 5, description: 'unique', manufacturer: 'Hasbro' }); 18 | expect(MemoryToyDB.allToys().length).toBe(toysBefore); 19 | expect(newToy.id).toBeFalsy(); 20 | expect(MemoryToyDB.allToys().find((item) => item.description === 'unique')).toBeFalsy(); 21 | }); 22 | }); // end create 23 | 24 | }); -------------------------------------------------------------------------------- /JavaScriptAsynchronous/hiLo.mjs: -------------------------------------------------------------------------------- 1 | import * as readline from 'node:readline'; 2 | 3 | const io = readline.createInterface({ 4 | input: process.stdin, 5 | output: process.stdout, 6 | }); 7 | 8 | let turn = (num, answer) => { 9 | io.question(`(${num}) What is your guess? `, line => { 10 | let guess = Number.parseInt(line); 11 | if (!Number.isInteger(guess)) { 12 | console.log(`=>${line}<= is not an integer. Please try again.`); 13 | turn(num, answer); 14 | } else if (guess < 1 || guess > 100) { 15 | console.log(`Guesses must be in the range [1, 100]. Please try again`); 16 | turn(num, answer); 17 | } else if (guess == answer) { 18 | console.log(`Congratulations. You win. It took you ${num} guesses.`); 19 | } else if (guess < answer) { 20 | console.log(`Your guess is too low. Please try again.`); 21 | turn(num + 1, answer); 22 | } else if (guess > answer) { 23 | console.log(`Your guess is too high. Please try again.`); 24 | turn(num + 1, answer); 25 | } else { 26 | console.log("This can't happen! You broke the game!"); 27 | } 28 | }); 29 | } 30 | 31 | turn(1, 73); 32 | -------------------------------------------------------------------------------- /ReactJSXIntro/reactDomCreation.js: -------------------------------------------------------------------------------- 1 | let states = ['Alabama', 'Alaska', 'Arizona', 'California', 'Colorado', 'Georgia', 2 | 'Florida', 'Michigan', 'Minnesota', '...', '(you get the point :)' 3 | ]; 4 | 5 | // When calling createElement, 6 | // * the first parameter is the element type, 7 | // * the second parameter is a hash of properties (also called "props") 8 | // * the remaining parameters are child elements (in this case, text) 9 | let items = states.map((item) => React.createElement("li", null, item)); 10 | 11 | let div = React.createElement("div", 12 | null, 13 | React.createElement("p", null, "Here is a list of some states (created using React)"), 14 | 15 | // Note the use of className instead of class ("class" is a keyword) 16 | // The ...items syntax takes the array of child elements and pulls them 17 | // out into a list of parameters. 18 | React.createElement("ul", { className: 'stateList' }, ...items) 19 | ); 20 | 21 | // 22 | // Insert the document into the html page 23 | // 24 | // This is the new way (under React 18 and after) 25 | const root = ReactDOM.createRoot(document.getElementById('main')); 26 | root.render(div); 27 | 28 | //ReactDOM.render(div, document.getElementById('main')); -------------------------------------------------------------------------------- /Templating/colorDemo.haml: -------------------------------------------------------------------------------- 1 | -# HAML stands for "HTML Abstraction Markup Language" 2 | -# To run: haml colorDemo.haml > output.html 3 | -# To install: gem install haml 4 | 5 | -# Indention is important 6 | -# Notice that loops have no end. They are just "un-indented" 7 | 8 | - colors = [:red, :green, :blue, :orange, :pink, :purple, :violet, :lightgreen, :fuchsia] 9 | 10 | %html 11 | %head 12 | %title Color Samples using HAML 13 | %style 14 | - colors.each do |color| 15 | \.color-#{color} {color: #{color};} 16 | 17 | %body 18 | %h1 List Colors (ERB) 19 | 20 | %p This section simply lists the color names because the code is simpler. 21 | 22 | %ul 23 | - colors.each do |color| 24 | %li= color 25 | 26 | %h1 Show Colors 27 | 28 | %p This section shows the colors. Same ideas as above, but the code is a little harder to read. 29 | 30 | %ul 31 | - colors.each do |color| 32 | %li 33 | %span{class: "color-#{color}"}= color 34 | 35 | 36 | 37 | %h1 Show Colors (v2) 38 | 39 | %p This section also shows the colors, but uses the map method. Some may find this code easier to follow. 40 | 41 | %ul= colors.map { |color| "
  • #{color}
  • " }.join("\n") 42 | 43 | -------------------------------------------------------------------------------- /ColorList1_fetch/src/NewColorForm.jsx: -------------------------------------------------------------------------------- 1 | import React, { useState } from "react"; 2 | // import { useInput } from "./hooks"; 3 | 4 | export default function AddColorForm({ onNewColor = f => f }) { 5 | const [title, setTitle] = useState(""); 6 | const [color, setColor] = useState("#000000"); 7 | 8 | const submit = e => { 9 | e.preventDefault(); 10 | console.log("Submit!") 11 | console.log(title) 12 | console.log(color) 13 | onNewColor(title, color); 14 | setTitle(""); 15 | setColor("#000000"); 16 | }; 17 | 18 | // See the "Creating Custom Hooks" section in Porcello and Banks 19 | // for a short-cut to the cut-and-paste for value and onChange. 20 | return ( 21 |
    22 | setTitle(event.target.value)} 25 | type="text" 26 | placeholder="color title..." 27 | required 28 | /> 29 | { setColor(event.target.value) }} 32 | type="color" 33 | required 34 | /> 35 | 36 |
    37 | ) 38 | } -------------------------------------------------------------------------------- /ColorListAPI_rails/config/storage.yml: -------------------------------------------------------------------------------- 1 | test: 2 | service: Disk 3 | root: <%= Rails.root.join("tmp/storage") %> 4 | 5 | local: 6 | service: Disk 7 | root: <%= Rails.root.join("storage") %> 8 | 9 | # Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) 10 | # amazon: 11 | # service: S3 12 | # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> 13 | # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> 14 | # region: us-east-1 15 | # bucket: your_own_bucket-<%= Rails.env %> 16 | 17 | # Remember not to checkin your GCS keyfile to a repository 18 | # google: 19 | # service: GCS 20 | # project: your_project 21 | # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> 22 | # bucket: your_own_bucket-<%= Rails.env %> 23 | 24 | # Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) 25 | # microsoft: 26 | # service: AzureStorage 27 | # storage_account_name: your_account_name 28 | # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> 29 | # container: your_container_name-<%= Rails.env %> 30 | 31 | # mirror: 32 | # service: Mirror 33 | # primary: local 34 | # mirrors: [ amazon, google, microsoft ] 35 | -------------------------------------------------------------------------------- /ExpressMVC/db/MemoryToyDB.js: -------------------------------------------------------------------------------- 1 | let Toy = require('../models/Toy') 2 | 3 | class MemoryToyDB { 4 | 5 | // In a "real" app, the methods below would be DB accesses, not just a references to a static array. 6 | static allToys() { 7 | return this.toysList 8 | } 9 | 10 | static find(id) { 11 | return this.toysList.find((item) => item.id == id) 12 | } 13 | 14 | static create(toyDescription) { 15 | let newToy = new Toy(toyDescription) 16 | if (newToy.isValid()) { 17 | newToy.id = this.toysList.length + 1 18 | this.toysList.push(newToy) 19 | } 20 | return newToy 21 | } 22 | 23 | static update(_toy) { 24 | // Actually, we already modified the toy object. There isn't anything that needs to be done here. 25 | // This method only exists to be consistent with the "real" DB class. 26 | } 27 | } 28 | 29 | MemoryToyDB.toysList = [] 30 | MemoryToyDB.create({ name: 'Barbie', description: 'The doll', price: 20.0, manufacturer: 'Mattel' }) 31 | MemoryToyDB.create({ name: 'Hot Wheels', description: 'Tiny cars', price: 1.50, manufacturer: 'Mattel' }) 32 | MemoryToyDB.create({ name: 'Playstation 4', description: 'A gaming console', price: 400, manufacturer: 'Sony' }) 33 | console.log(MemoryToyDB.toysList) 34 | 35 | module.exports = MemoryToyDB -------------------------------------------------------------------------------- /ColorList3_routing/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "colorList3_routing", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.16.5", 7 | "@testing-library/react": "^13.4.0", 8 | "@testing-library/user-event": "^13.5.0", 9 | "react": "^18.2.0", 10 | "react-dom": "^18.2.0", 11 | "react-icons": "^4.6.0", 12 | "react-router": "^6.4.3", 13 | "react-router-dom": "^6.4.3", 14 | "web-vitals": "^2.1.4" 15 | }, 16 | "scripts": { 17 | "start": "react-scripts start", 18 | "build": "react-scripts build", 19 | "test": "react-scripts test", 20 | "eject": "react-scripts eject" 21 | }, 22 | "eslintConfig": { 23 | "extends": [ 24 | "react-app", 25 | "react-app/jest" 26 | ] 27 | }, 28 | "browserslist": { 29 | "production": [ 30 | ">0.2%", 31 | "not dead", 32 | "not op_mini all" 33 | ], 34 | "development": [ 35 | "last 1 chrome version", 36 | "last 1 firefox version", 37 | "last 1 safari version" 38 | ] 39 | }, 40 | "devDependencies": { 41 | "@cucumber/cucumber": "^11.2.0", 42 | "chromedriver": "^134.0.5", 43 | "eslint": "^8.28.0", 44 | "eslint-plugin-react": "^7.31.11", 45 | "react-scripts": "^5.0.1", 46 | "selenium-webdriver": "^4.6.1" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /JavaScriptBasics/sortingStudents.js: -------------------------------------------------------------------------------- 1 | let students = [ 2 | { name: "John", gpa: 3.5, major: 'math', standing: 'freshman' }, 3 | { name: "David", gpa: 3.7, major: 'chemistry', standing: 'sophomore' }, 4 | { name: "Nathan", gpa: 2.7, major: 'physics', standing: 'junior' }, 5 | { name: "Jonathan", gpa: 2.1, major: 'engineering', standing: 'senior' } 6 | ]; 7 | 8 | 9 | console.log("Students by name: "); 10 | students.sort((a, b) => a.name.localeCompare(b.name)); 11 | console.log(students); 12 | 13 | console.log("Students by gpa: "); 14 | students.sort((a, b) => a.gpa - b.gpa); 15 | console.log(students); 16 | 17 | // 18 | // The trick is how to write a generic "sortStudent" method where the field is a parameter 19 | // 20 | 21 | let sortStudents = function(students, field) { 22 | 23 | // notice that the anonymous compare function has access to the 24 | // field variable from the enclosing scope. 25 | // IMPORTANT: localCompare is for strings. It only works on GPA because the values are all >0 and < 10 26 | students.sort((a, b) => a[field].localeCompare(b[field])); 27 | return students; 28 | } 29 | 30 | console.log("Students by name (v2):"); 31 | sortStudents(students, "name"); 32 | console.log(students); 33 | 34 | console.log("Students by major:"); 35 | sortStudents(students, "major"); 36 | console.log(students); -------------------------------------------------------------------------------- /Templating/colorDemo.html.erb: -------------------------------------------------------------------------------- 1 | <%# ERB stands for "Embedded Ruby" %> 2 | <%# To run: erb colorDemo.html.erb > output.html %> 3 | <%# To install: gem install erb %> 4 | 5 | <% colors = [:red, :green, :blue, :orange, :pink, :purple, :violet, :lightgreen, :lightred] %> 6 | 7 | 8 | 9 | Color Samples using ERB 10 | 19 | 20 | 21 | 22 |

    List Colors (ERB)

    23 | 24 | This section simply lists the color names because the code is simpler. 25 | 26 |
      27 | <% colors.each do |color| %> 28 |
    • <%= color %>
    • 29 | <% end %> 30 |
    31 | 32 |

    Show Colors

    33 | This section shows the colors. Same ideas as above, but the code is a little harder to read. 34 | 35 |
      36 | 37 | <% colors.each do |color| %> 38 |
    • <%= color %>
    • 39 | <% end %> 40 |
    41 | 42 | 43 |

    Show Colors (v2)

    44 | This section also shows the colors, but uses the map method. Some may find this code easier to follow. 45 | 46 |
      47 | <%= colors.map { |color| "
    • #{color}
    • " }.join("\n") %> 48 |
    49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /ColorList3_routing/src/NewColorForm.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | 4 | export default function AddColorForm({ editMode = false, colorToEdit, onUpdate = f => f, onSubmit = f => f, onCancelEdit = f => f }) { 5 | 6 | // See the "Creating Custom Hooks" section in Porcello and Banks 7 | // for a short-cut to the cut-and-paste for value and onChange. 8 | return ( 9 |
    10 | {editMode ? 'Update' : 'New'} Color 11 |
    12 | onUpdate({ ...colorToEdit, title: event.target.value })} 17 | type="text" 18 | placeholder="color title..." 19 | title='Title' 20 | required 21 | /> 22 | onUpdate({ ...colorToEdit, color: event.target.value })} 25 | type="color" 26 | title='Color' 27 | required 28 | /> 29 | 30 | 31 | {/* 33 |
    34 |
    35 | ) 36 | } -------------------------------------------------------------------------------- /ExpressMVC/public/ajax1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

    AJAX Example 1

    5 | 6 |

    You have toys named:

    7 |
      8 | 9 |
    10 | 11 | 12 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /JavaScriptDOM/hideableList.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hideable List 6 | 7 | 22 | 23 | 24 | 25 |
    26 |

    27 | 28 | Counties in Michigan: 29 |

    30 |
      31 |
    • Wayne
    • 32 |
    • Oakland
    • 33 |
    • Livingston
    • 34 |
    • Macomb
    • 35 |
    • Bay
    • 36 |
    • Kent
    • 37 |
    • Ottawa
    • 38 |
    39 |
    40 | 41 |

    Here is some text below the list, just to demonstrate that it moves.

    42 | 43 |
    44 |

    45 | 46 | Countries in Europe: 47 |

    48 |
      49 |
    • France
    • 50 |
    • Germany
    • 51 |
    • Poland
    • 52 |
    • Austria
    • 53 |
    • Switzerland
    • 54 |
    • Italy
    • 55 |
    56 | 57 |
    58 | 59 | -------------------------------------------------------------------------------- /ColorList2_edit/src/NewColorForm.jsx: -------------------------------------------------------------------------------- 1 | 2 | export default function AddColorForm({ editMode = false, colorToEdit, onUpdate = f => f, onSubmit = f => f, onCancelEdit = f => f }) { 3 | 4 | // See the "Creating Custom Hooks" section in Porcello and Banks 5 | // for a short-cut to the cut-and-paste for value and onChange. 6 | return ( 7 |
    8 | { editMode ? 'Update' : "New" } Color 9 |
    10 | onUpdate({...colorToEdit, title: event.target.value})} 15 | type="text" 16 | placeholder="color title..." 17 | required 18 | /> 19 | onUpdate({...colorToEdit, color: event.target.value})} 22 | type="color" 23 | required 24 | /> 25 | {/* This button should submit the form */} 26 | 27 | 28 | {/* 30 |
    31 |
    32 | ) 33 | } -------------------------------------------------------------------------------- /JavaScriptAsynchronous/timerPromiseAwait.mjs: -------------------------------------------------------------------------------- 1 | /************************************************************************************ 2 | * 3 | * timerPromiseAwait.js 4 | * 5 | * Demonstrates the use of await. 6 | * 7 | ************************************************************************************/ 8 | 9 | import * as readline from 'readline'; 10 | 11 | 12 | // I put this here because, in my opinion, the entire program should use the same io object.\ 13 | const io = readline.createInterface({ 14 | input: process.stdin, 15 | output: process.stdout, 16 | }); 17 | 18 | 19 | let askQuestion = (prompt) => { 20 | return new Promise( (resolve, reject) => { 21 | io.question(prompt, (line) => resolve(line)) 22 | }) 23 | } 24 | 25 | let setTimer = (delay) => { 26 | return new Promise( (resolve, reject) => { 27 | setTimeout(resolve, delay) 28 | }) 29 | } 30 | 31 | console.log("(e1) Begin.") 32 | await setTimer(1000) 33 | console.log("(e2) It's time to wake up.") 34 | await setTimer(1500) 35 | console.log("(e3) You should be out of bed by now.") 36 | let answer = await askQuestion("Are you? ") 37 | if (answer.toLocaleLowerCase().trim().startsWith('y')) { 38 | console.log("(d3b) Good. Go eat breakfast"); 39 | await setTimer(2000) 40 | console.log("(d4) Breakfast time is over. Go brush your teeth.") 41 | await setTimer(500) 42 | console.log("(d5) That's long enough. Now get to the bus!") 43 | } else { 44 | console.log("Not again :( ") 45 | } 46 | io.close() 47 | 48 | -------------------------------------------------------------------------------- /ExpressSession/controllers/LoginController.js: -------------------------------------------------------------------------------- 1 | class LoginController { 2 | 3 | // Simply render the page with the login form. 4 | loginPage(req, res) { 5 | res.render('login', { message: 'Please login' }) 6 | } 7 | 8 | // Respond to the POST from the login page. 9 | requestLogin(req, res, next) { 10 | console.log('Request body') 11 | console.log(req.body) 12 | 13 | let returnTo = req.session.returnTo 14 | 15 | // For simplicity the password is always just the reverse of the 16 | // login name. In a real application, we would make a DB 17 | // access to check the username and password. 18 | const reversedUser = req.body.username.split('').reverse().join('') 19 | if (req.body.passwd !== reversedUser) { 20 | // If the password is incorrect, re-render the login form. 21 | res.render('login', { message: 'Incorrect password' }) 22 | } else { 23 | console.log('Creating new session') 24 | req.session.regenerate((err) => { 25 | if (err) next(err) 26 | req.session.user = req.body.username 27 | console.log('Session created') 28 | console.log(req.session) 29 | res.redirect(returnTo ?? '/toys') 30 | }) 31 | } 32 | } 33 | 34 | logout(req, res) { 35 | req.session.destroy(function(){ 36 | res.redirect('/login') 37 | }) 38 | } 39 | } 40 | 41 | module.exports = LoginController -------------------------------------------------------------------------------- /Bootstrap/widthTest.erb: -------------------------------------------------------------------------------- 1 | 2 | <% num_rows = 20 3 | colors = [:blue, :green, :orange, :purple] 4 | %> 5 | 6 | 7 | 8 | 19 | 20 | 21 | 22 | 23 | Screen: Window: Document: 24 | 25 | 26 | 27 | <% (1..num_rows).each do |i| %> 28 |
    29 | Width <%= i*100 %> 30 |
    31 | <%end%> 32 | 33 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /JavaScriptBasics/Dog.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | /** 4 | * Created by kurmasz on 2/10/15. 5 | */ 6 | let Dog = (function () { 7 | 8 | let dogCount = 0 9 | let incrementDogCount = function () { 10 | dogCount++ 11 | } 12 | let numDogs = function () { 13 | return dogCount 14 | } 15 | 16 | 17 | // constructor 18 | let init = function (name_in, height_in, weight_in) { 19 | 20 | let name = name_in 21 | let height = height_in 22 | let weight = weight_in 23 | 24 | 25 | let speak = function () { 26 | return 'Woof' 27 | } 28 | 29 | 30 | let toString = function () { 31 | // Notice the removal of "this" 32 | return name + ' has height ' + height + ' and weight ' + weight 33 | } 34 | 35 | // Notice calcBMI must be moved inside makeDog to have 36 | // access to private data. 37 | let calcBMI = function () { 38 | return weight / (height * height) 39 | } 40 | 41 | let setHeight = function (newHeight) { 42 | height = newHeight 43 | } 44 | 45 | incrementDogCount() 46 | 47 | // If you don't add a function to the list below, it is effectively private. 48 | return { 49 | speak: speak, 50 | toString: toString, 51 | bmi: calcBMI, 52 | setHeight: setHeight 53 | } 54 | } // end of init 55 | 56 | return { 57 | numDogs: numDogs, 58 | init: init 59 | } 60 | })() 61 | 62 | -------------------------------------------------------------------------------- /JavaScriptBasics/dynamicTyping.js: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * This file demonstrates the benefits (and pitfalls) of dynamic typing. 4 | * 5 | *****************************************************************************/ 6 | 7 | class Dog { 8 | 9 | bark() { 10 | console.log("Woof"); 11 | } 12 | 13 | speak() { 14 | this.bark(); 15 | } 16 | } 17 | 18 | class Duck { 19 | quack() { 20 | console.log("Quack") 21 | } 22 | 23 | speak() { 24 | this.quack(); 25 | } 26 | } 27 | 28 | 29 | 30 | var dog = new Dog(); 31 | var duck = new Duck(); 32 | 33 | console.log("Round 1"); 34 | dog.bark(); 35 | duck.quack(); 36 | 37 | console.log(); 38 | console.log("Round 2"); 39 | 40 | 41 | // Benefit of dynamic typing: We can put objects of different types into 42 | // an array. Everything works as long as all the objects implement the method 43 | // in question. 44 | let animals = [dog, duck]; 45 | 46 | animals.forEach((animal) => { 47 | animal.speak(); 48 | }); 49 | 50 | console.log(); 51 | console.log("Round 3"); 52 | 53 | // Pitfall: The compiler can't tell us when we've tried to call a method that doesn't exist. 54 | // This bug is only discoverable at runtime. 55 | // If the code below were buried in if-statements, we might not even notice it until the code 56 | // had been production for a long time and a user just happened to enter an unfortunate combination of data. 57 | animals.forEach((animal) => { 58 | animal.bark(); 59 | }); -------------------------------------------------------------------------------- /SimpleWebClient/hard_coded_http_request.py: -------------------------------------------------------------------------------- 1 | """ 2 | This script provides a minimum working example of an HTTP request. 3 | For simplicity, 4 | (1) the URL (and it's components) are hard-coded, and 5 | (2) the script is not organized into functions. 6 | 7 | See simple_web_client.py for a more complete example. 8 | 9 | GVSU CIS 371 10 | """ 11 | 12 | import socket 13 | import sys 14 | 15 | hostname = 'example.com' 16 | path = '/' 17 | port = 80 18 | 19 | # Connect to the server 20 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 21 | s.connect((hostname, port)) 22 | stream = s.makefile('rw') 23 | 24 | # Send the request 25 | stream.write(f"GET {path} HTTP/1.1\r\n") 26 | stream.write(f"Host: {hostname}\r\n") 27 | stream.write("User-Agent: GVBrowser/1.0\r\n") 28 | stream.write("Connection: close\r\n") 29 | stream.write("\r\n") 30 | stream.flush() # Flush the buffer so the entire message is sent 31 | 32 | # Read the response 33 | response = next(stream) 34 | 35 | # Collect headers 36 | headers = {} 37 | for line in stream: 38 | stripped_line = line.strip() 39 | if len(stripped_line) == 0: 40 | break 41 | key, value = stripped_line.split(":", 1) 42 | headers[key] = value 43 | 44 | # Read content 45 | content = stream.readlines() 46 | 47 | # Write the response and headers to stderr 48 | sys.stderr.write(f"\nResponse: {response.strip()}\n") 49 | sys.stderr.write("Headers:\n") 50 | for key, value in headers.items(): 51 | key_colon = f"{key}:" 52 | sys.stderr.write(f" {key_colon:15} {value}\n") 53 | 54 | print("".join(content)) -------------------------------------------------------------------------------- /JavaScriptAsADT/Dog.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /** 4 | * Created by kurmasz on 2/10/15. 5 | */ 6 | let Dog = (function () { 7 | 8 | let dogCount = 0; 9 | let incrementDogCount = function () { 10 | dogCount++; 11 | } 12 | let numDogs = function () { 13 | return dogCount; 14 | } 15 | 16 | 17 | // constructor 18 | let init = function (name_in, height_in, weight_in) { 19 | 20 | let name = name_in; 21 | let height = height_in; 22 | let weight = weight_in; 23 | 24 | 25 | let speak = function () { 26 | return "Woof"; 27 | }; 28 | 29 | 30 | let toString = function () { 31 | // Notice the removal of "this" 32 | return name + " has height " + height + " and weight " + weight 33 | }; 34 | 35 | // Notice calcBMI must be moved inside makeDog to have 36 | // access to private data. 37 | let calcBMI = function () { 38 | return weight / (height * height); 39 | }; 40 | 41 | let setHeight = function (newHeight) { 42 | height = newHeight; 43 | }; 44 | 45 | incrementDogCount(); 46 | 47 | // If you don't add a function to the list below, it is effectively private. 48 | return { 49 | speak: speak, 50 | toString: toString, 51 | bmi: calcBMI, 52 | setHeight: setHeight 53 | } 54 | }; // end of init 55 | 56 | return { 57 | numDogs: numDogs, 58 | init: init 59 | } 60 | })(); 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /SimpleWebClient/README.md: -------------------------------------------------------------------------------- 1 | This folder contains several Python implementations of a very simple HTTP client. 2 | 3 | 1. [hard_coded_http_request.py](./hard_coded_http_request.py) makes an unencrypted HTTP 4 | request to an address that is hard-coded into the program. The goal of this code is 5 | to be as simple and straightforward as reasonable. 6 | 7 | 2. [hard_coded_image_request.py](./hard_coded_image_request.py) makes an encrypted HTTPS 8 | request for an image (i.e, binary file) at an address that is hard-coded into the program. 9 | The goal of this code is to be as simple and straightforward as reasonable. 10 | **IMPORTANT**: he code reads raw binary data from the socket after 11 | having also used a text IO wrapper (i.e., makefile()) **In general this doesn't work!** 12 | See [simple_web_client.py](./simple_web_client.py) for the correct way to manage a socket 13 | with both text and binary data. 14 | 15 | 3. [simple_web_client.py](./simple_web_client.py) is a more complete web client. It can retrieve 16 | the content of any simple HTTP/HTTPS GET request (text or binary) accessible using a URL alone. 17 | (It supports neither authentication not query strings.) It mimics the behavior of running 18 | `curl some_url -o output_file` 19 | 20 | 4. [http_socket.py](./http_socket.py) wraps the socket and handles the reading of both text and 21 | binary data. The purpose of this file is to make [simple_web_client.py](./simple_web_client.py) 22 | more readable by abstracting the details of reading binary data from a socket out of the main flow 23 | of the code. 24 | 25 | -------------------------------------------------------------------------------- /JavaScriptAsynchronous/callbackHell.js: -------------------------------------------------------------------------------- 1 | /************************************************************************************ 2 | * 3 | * callbackHell.js 4 | * 5 | * Demonstrates how multiple callbacks can make for code that is hard to follow. 6 | * 7 | ************************************************************************************/ 8 | console.log("(a1) Begin!") 9 | setTimeout(() => { 10 | console.log("(a2) It's time to wake up.") 11 | setTimeout(() => { 12 | console.log("(a3) You should be out of bed by now.") 13 | setTimeout(() => { 14 | console.log("(a4) Breakfast time is over. Go brush your teeth.") 15 | setTimeout(() => { 16 | console.log("(a5) That's long enough. Now get to the bus!") 17 | }, 500) 18 | }, 2000) 19 | }, 1500) 20 | }, 1000) 21 | 22 | // 23 | // Even using functions doesn't help much. 24 | // 25 | 26 | let step5 = () => { 27 | console.log("(b5) That's long enough. Now get to the bus!") 28 | } 29 | 30 | 31 | let step4 = () => { 32 | console.log("(b4) Breakfast time is over. Go brush your teeth.") 33 | setTimeout(step5, 500) 34 | } 35 | 36 | 37 | let step3 = () => { 38 | console.log("(b3) You should be out of bed by now.") 39 | setTimeout(step4, 2000) 40 | } 41 | 42 | let step2 = () => { 43 | console.log("(b2) It's time to wake up."); 44 | setTimeout(step3, 1500); 45 | } 46 | 47 | let step1 = () => { 48 | console.log("*******************************") 49 | console.log("(b1) Begin."); 50 | setTimeout(step2, 1000); 51 | } 52 | 53 | setTimeout(step1, 6000) -------------------------------------------------------------------------------- /ExpressMVCSqliteCallbacks/db/callbacksRequired.js: -------------------------------------------------------------------------------- 1 | let sqlite3 = require('sqlite3').verbose() 2 | let db = new sqlite3.Database('toys.sqlite') 3 | 4 | console.log('About to call all') 5 | let all1 = db.all('SELECT * from Toys') 6 | console.log('Notice that the return value is *not* the list of toys in the DB:') 7 | // (Return value is db itself so calls can be chained.) 8 | console.log(all1) 9 | console.log('The only way to access the data is from a callback.') 10 | 11 | 12 | console.log('******************************************************') 13 | 14 | db.all('SELECT * from Toys', (err, rows) => { 15 | console.log('-----------------------') 16 | console.log('Now, the rows are ready') 17 | console.log(rows.slice(0, 3)) //only print first 3 to keep output manageable 18 | if (err) { 19 | console.log(`There was an error "${err}"`) 20 | } 21 | }) 22 | 23 | // Example error (SELECT misspelled). 24 | db.all('SELEKT * from Toys', (err, rows) => { 25 | console.log('--------------------------------------') 26 | console.log('There should be an error and no rows:') 27 | console.log(rows) 28 | if (err) { 29 | console.log(`There was an error "${err}"`) 30 | } 31 | }) 32 | 33 | // Example error (Toys misspelled). 34 | db.all('SELECT * from Toyz', (err, rows) => { 35 | console.log('--------------------------------------') 36 | console.log('There should be an error and no rows:') 37 | console.log(rows) 38 | if (err) { 39 | console.log(`There was an error "${err}"`) 40 | } 41 | }) 42 | 43 | console.log('Notice that this line runs *before* the rows are ready.') -------------------------------------------------------------------------------- /JavaScriptAsynchronous/asynchronous1.js: -------------------------------------------------------------------------------- 1 | /* jshint esversion: 6 */ 2 | 3 | const { exit } = require("process") 4 | 5 | console.log("Notice that Javascript runs asynchronously:") 6 | setTimeout(() => console.log('Callback after 3 seconds'), 3000) 7 | setTimeout(() => console.log('Callback after 2 seconds'), 2000) 8 | setTimeout(() => console.log('Callback after 1 seconds'), 1000) 9 | console.log("First three timers set.") 10 | 11 | 12 | callback2 = function(delay) { console.log(`Callback v2 after ${delay} seconds`) } 13 | 14 | setTimeout(() => console.log("We can also use helper methods:")) 15 | setTimeout(() => callback2(5), 5000) 16 | setTimeout(() => callback2(5.5), 5500) 17 | setTimeout(() => callback2(6), 6000) 18 | 19 | demonstrateIncorrectClosures = function() { 20 | 21 | console.log("About to demonstrate incorrect use of closures."); 22 | let x = 0; 23 | callback3 = () => { 24 | console.log(`Callback v3 after ${x} seconds`) 25 | }; 26 | 27 | // Notice that both callbacks will print "1.5". 28 | x = 1.5; 29 | setTimeout(callback3, 1500) 30 | x = 2.5; 31 | setTimeout(callback3, 2500) 32 | }; 33 | setTimeout(() => demonstrateIncorrectClosures(), 6000) 34 | 35 | demonstrateCorrectClosures = function() { 36 | 37 | console.log("About to demonstrate the correct use of closures.") 38 | makeCallback = function(value) { 39 | return function() { 40 | console.log(`Callback v3 after ${value} seconds`); 41 | }; 42 | }; 43 | 44 | setTimeout(makeCallback(1.5), 1500) 45 | setTimeout(makeCallback(2.5), 2500) 46 | }; 47 | 48 | setTimeout(demonstrateCorrectClosures, 9000) -------------------------------------------------------------------------------- /Templating/colorDemo.php: -------------------------------------------------------------------------------- 1 | $color"; 5 | } 6 | 7 | ?> 8 | 9 | 10 | 11 | Color Samples using PHP 12 | 22 | 23 | 24 | 25 |

    List Colors (PHP)

    26 | 27 | This section simply lists the color names because the code is simpler. 28 | 29 |
      30 | $color\n"; 34 | } 35 | ?> 36 |
    37 | 38 |

    Show Colors

    39 | This section shows the colors. Same ideas as above, but the code is a little harder to read. 40 | 41 |
      42 | $color\n"; 44 | } 45 | ?> 46 |
    47 | 48 | 49 |

    Show Colors (v2)

    50 | This section also shows the colors, but uses the map method. Some may find this code easier to follow. 51 | 52 |
      53 | 56 | 57 |
    58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /ColorList3_routing/src/Tabs.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { useLocation, Link } from 'react-router-dom' 3 | 4 | 5 | export function Home() { 6 | return ( 7 |
    8 |

    Colors Я Us

    9 | 10 | Let us help you with all your color listing needs. 11 |
    12 | ) 13 | } 14 | 15 | export function About() { 16 | return ( 17 |
    18 |

    About ColorList

    19 | ColorList is a React app used to demonstrate the basics of React. It is based on an example in 20 | Learning React, 2nd Edition by Alex Banks and Eve Porcello. 21 |
    22 | ) 23 | } 24 | 25 | export function Events() { 26 | return ( 27 |
    28 |

    Events

    29 |
      30 |
    • Party
    • 31 |
    • Book signing
    • 32 |
    • Zoo opens
    • 33 |
    34 |
    35 | ) 36 | } 37 | 38 | export function Products() { 39 | return ( 40 |
    41 |

    [Products]

    42 |
    43 | ) 44 | } 45 | 46 | export function Contact() { 47 | return ( 48 |
    49 |

    Colors 'Я' Us

    50 |
    51 | ) 52 | } 53 | 54 | export function NotFound() { 55 | let location = useLocation() 56 | return ( 57 |
    58 |

    Path {location.pathname} is not valid

    59 |
    60 | ) 61 | } 62 | 63 | export function NavBar() { 64 | return ( 65 | 73 | ) 74 | } -------------------------------------------------------------------------------- /ExpressMVCSqliteCallbacks/index.js: -------------------------------------------------------------------------------- 1 | // Express documentation: https://expressjs.com/en/api.html 2 | 3 | /* Import the express npm module and instantiate the server */ 4 | const express = require('express') 5 | const app = express() 6 | const port = 3000 7 | 8 | /* Import and instantiate the controller. */ 9 | const ToyController = require('./controllers/ToyController') 10 | const toyController = new ToyController() 11 | 12 | /* Parse the request body if there is POST data */ 13 | const bodyParser = require('body-parser') 14 | app.use(bodyParser.urlencoded({ extended: true })) 15 | 16 | /* Tell the server to use EJS by default */ 17 | app.set('view engine', 'ejs') 18 | 19 | // 20 | // Standard CRUD routes for Toy resource 21 | // 22 | 23 | /* Display all toys */ 24 | app.get('/toys', (req, res) => { 25 | toyController.index(req, res) 26 | }) 27 | 28 | /* Display a form to create a new toy */ 29 | app.get('/toys/new', (req, res) => { 30 | toyController.newToy(req, res) 31 | }) 32 | 33 | /* Display details for one toy. 34 | :id represents a "route parameter" */ 35 | app.get('/toys/:id', (req, res) => { 36 | toyController.show(req, res) 37 | }) 38 | 39 | /* Create a new toy */ 40 | app.post('/toys', (req, res) => { 41 | toyController.create(req, res) 42 | }) 43 | 44 | /* Display form to edit a toy */ 45 | app.get('/toys/:id/edit', (req, res) => { 46 | toyController.edit(req, res) 47 | }) 48 | 49 | /* Update a toy */ 50 | app.post('/toys/:id', (req, res) => { 51 | console.log('Update: ') 52 | console.log(req.body) 53 | toyController.update(req, res) 54 | }) 55 | 56 | /* Launch the server */ 57 | app.listen(port, () => console.log(`Example app listening on port ${port}!`)) 58 | -------------------------------------------------------------------------------- /JavaScriptDOM/placementOfScript.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 28 | 29 | 30 | 31 | 32 | 35 | 36 | 37 |

    My List

    38 |
      39 |
    • CIS 162
    • 40 |
    • CIS 163
    • 41 |
    • CIS 343
    • 42 |
    • CIS 351
    • 43 |
    • CIS 371
    • 44 |
    • CIS 451
    • 45 |
    • CIS 500
    • 46 |
    • CIS 658
    • 47 |
    48 | 49 | 50 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /SimpleWebClient/Java/BasicHTTPTransaction.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.net.Socket; 3 | 4 | /** 5 | * Simple HTTP Client 6 | * 7 | * This program 1. Creates a socket connected to a web server 2. Makes a GET 8 | * request 3. Prints the response headers to the standard output 4. Saves the 9 | * data to a file named 'document' 10 | * 11 | * 12 | * Created by kurmasz on 4/27/15. 13 | */ 14 | public class BasicHTTPTransaction { 15 | 16 | public static void main(String[] args) throws IOException { 17 | 18 | // Values set up for a web server running locally. 19 | // One option is to run "python -m SimpleHTTPServer" from the data directory 20 | String host = "www.gvsu.edu"; 21 | int port = 80; 22 | String file = "/"; 23 | String outputFile = "opt.index.html"; 24 | 25 | Socket socket = new Socket(host, port); 26 | 27 | InputStream rawInput = socket.getInputStream(); 28 | BufferedReader input = new BufferedReader(new InputStreamReader(rawInput)); 29 | 30 | OutputStream rawOutput = socket.getOutputStream(); 31 | PrintWriter output = new PrintWriter(rawOutput); 32 | 33 | output.printf("GET %s HTTP/1.1\n", file); 34 | output.printf("Host: %s\n", host); 35 | output.println(""); 36 | output.flush(); 37 | 38 | String line = input.readLine(); 39 | while (line.length() > 0) { 40 | System.out.println(line); 41 | line = input.readLine(); 42 | } 43 | 44 | PrintWriter fileOutput = new PrintWriter(new FileOutputStream(outputFile)); 45 | line = input.readLine(); 46 | while (line != null) { 47 | fileOutput.println(line); 48 | line = input.readLine(); 49 | } 50 | fileOutput.close(); 51 | socket.close(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /ExpressMVC/models/Toy.js: -------------------------------------------------------------------------------- 1 | class Toy { 2 | 3 | constructor(description) { 4 | // if description is null or undefined, we want to create an "empty" Toy object. 5 | if (description) { 6 | this.id = description.id 7 | this.name = description.name 8 | this.description = description.description 9 | this.price = description.price 10 | this.manufacturer = description.manufacturer 11 | } 12 | this.errors = [] 13 | } 14 | 15 | isValid() { 16 | this.errors = [] 17 | if (!this.name || this.name.length <= 2) { 18 | this.errors.push('The name must contain at least three characters') 19 | } 20 | if (!this.description || this.description.length <= 0) { 21 | this.errors.push('The toy must have a description.') 22 | } 23 | if (!this.manufacturer || this.manufacturer.length <= 0) { 24 | this.errors.push('The toy must have a manufacturer.') 25 | } 26 | 27 | // parseFloat(this.price) != this.price will detect cases like this" parseFloat("201 Main street") 28 | // where the returned value (201) is not the entire string. Notice the use of == to compare the number 29 | // and the string. 30 | if (!this.price) { 31 | this.errors.push('The toy must have a price.') 32 | } else if (isNaN(parseFloat(this.price)) || parseFloat(this.price) != this.price) { 33 | this.errors.push('The price must be a number.') 34 | } else if (this.price < 0.0) { 35 | this.errors.push('The price must not be negative.') 36 | } 37 | return this.errors.length <= 0 38 | } 39 | } 40 | 41 | module.exports = Toy -------------------------------------------------------------------------------- /ExpressMVCSimple/index.js: -------------------------------------------------------------------------------- 1 | // Express documentation: https://expressjs.com/en/api.html 2 | 3 | /* Import the express npm module and instantiate the server */ 4 | const express = require('express') 5 | const app = express() 6 | const port = 3000 7 | 8 | /* Import and instantiate the controller. */ 9 | const ToyController = require('./controllers/ToyController') 10 | const toyController = new ToyController() 11 | 12 | /* Parse the request body if there is POST data */ 13 | const bodyParser = require('body-parser') 14 | app.use(bodyParser.urlencoded({ extended: true })) 15 | 16 | /* Tell the server to use EJS by default */ 17 | app.set('view engine', 'ejs') 18 | 19 | // 20 | // Standard CRUD routes for Toy resource 21 | // 22 | 23 | /* Display all toys */ 24 | app.get('/toys', (req, res) => { 25 | toyController.index(req, res) 26 | }) 27 | 28 | /* Display a form to create a new toy */ 29 | app.get('/toys/new', (req, res) => { 30 | console.log('Toys new index.js') 31 | toyController.newToy(req, res) 32 | }) 33 | 34 | /* Display details for one toy. 35 | :id represents a "route parameter" */ 36 | app.get('/toys/:id', (req, res) => { 37 | toyController.show(req, res) 38 | }) 39 | 40 | /* Create a new toy */ 41 | app.post('/toys', (req, res) => { 42 | toyController.create(req, res) 43 | }) 44 | 45 | /* Display form to edit a toy */ 46 | app.get('/toys/:id/edit', (req, res) => { 47 | toyController.edit(req, res) 48 | }) 49 | 50 | /* Update a toy */ 51 | app.post('/toys/:id', (req, res) => { 52 | console.log('Update: ') 53 | console.log(req.body) 54 | toyController.update(req, res) 55 | }) 56 | 57 | /* Launch the server */ 58 | app.listen(port, () => console.log(`Example app listening on port ${port}!`)) 59 | -------------------------------------------------------------------------------- /ExpressMVCSimple/models/Toy.js: -------------------------------------------------------------------------------- 1 | class Toy { 2 | 3 | constructor(description) { 4 | // if description is null or undefined, we want to create an "empty" Toy object. 5 | if (description) { 6 | this.id = description.id 7 | this.name = description.name 8 | this.description = description.description 9 | this.price = description.price 10 | this.manufacturer = description.manufacturer 11 | } 12 | this.errors = [] 13 | } 14 | 15 | isValid() { 16 | this.errors = [] 17 | if (!this.name || this.name.length <= 2) { 18 | this.errors.push('The name must contain at least three characters') 19 | } 20 | if (!this.description || this.description.length <= 0) { 21 | this.errors.push('The toy must have a description.') 22 | } 23 | if (!this.manufacturer || this.manufacturer.length <= 0) { 24 | this.errors.push('The toy must have a manufacturer.') 25 | } 26 | 27 | // parseFloat(this.price) != this.price will detect cases like this" parseFloat("201 Main street") 28 | // where the returned value (201) is not the entire string. Notice the use of == to compare the number 29 | // and the string. 30 | if (!this.price) { 31 | this.errors.push('The toy must have a price.') 32 | } else if (isNaN(parseFloat(this.price)) || parseFloat(this.price) != this.price) { 33 | this.errors.push('The price must be a number.') 34 | } else if (this.price < 0.0) { 35 | this.errors.push('The price must not be negative.') 36 | } 37 | return this.errors.length <= 0 38 | } 39 | } 40 | 41 | module.exports = Toy -------------------------------------------------------------------------------- /ExpressMVCSqlitePromises/index.js: -------------------------------------------------------------------------------- 1 | // Express documentation: https://expressjs.com/en/api.html 2 | 3 | /* Import the express npm module and instantiate the server */ 4 | const express = require('express') 5 | const app = express() 6 | const port = 3000 7 | 8 | /* Import and instantiate the controller. */ 9 | const ToyController = require('./controllers/ToyController') 10 | const toyController = new ToyController() 11 | 12 | /* Parse the request body if there is POST data */ 13 | const bodyParser = require('body-parser') 14 | app.use(bodyParser.urlencoded({ extended: true })) 15 | 16 | /* Tell the server to use EJS by default */ 17 | app.set('view engine', 'ejs') 18 | 19 | // 20 | // Standard CRUD routes for Toy resource 21 | // 22 | 23 | /* Display all toys */ 24 | app.get('/toys', (req, res) => { 25 | toyController.index(req, res) 26 | }) 27 | 28 | /* Display a form to create a new toy */ 29 | app.get('/toys/new', (req, res) => { 30 | console.log('Toys new index.js') 31 | toyController.newToy(req, res) 32 | }) 33 | 34 | /* Display details for one toy. 35 | :id represents a "route parameter" */ 36 | app.get('/toys/:id', (req, res) => { 37 | toyController.show(req, res) 38 | }) 39 | 40 | /* Create a new toy */ 41 | app.post('/toys', (req, res) => { 42 | toyController.create(req, res) 43 | }) 44 | 45 | /* Display form to edit a toy */ 46 | app.get('/toys/:id/edit', (req, res) => { 47 | toyController.edit(req, res) 48 | }) 49 | 50 | /* Update a toy */ 51 | app.post('/toys/:id', (req, res) => { 52 | console.log('Update: ') 53 | console.log(req.body) 54 | toyController.update(req, res) 55 | }) 56 | 57 | /* Launch the server */ 58 | app.listen(port, () => console.log(`Example app listening on port ${port}!`)) 59 | -------------------------------------------------------------------------------- /ExpressSession/models/Toy.js: -------------------------------------------------------------------------------- 1 | class Toy { 2 | 3 | constructor(description) { 4 | // if description is null or undefined, we want to create an "empty" Toy object. 5 | if (description) { 6 | this.id = description.id 7 | this.name = description.name 8 | this.description = description.description 9 | this.price = description.price 10 | this.manufacturer = description.manufacturer 11 | } 12 | this.errors = [] 13 | } 14 | 15 | isValid() { 16 | this.errors = [] 17 | if (!this.name || this.name.length <= 2) { 18 | this.errors.push('The name must contain at least three characters') 19 | } 20 | if (!this.description || this.description.length <= 0) { 21 | this.errors.push('The toy must have a description.') 22 | } 23 | if (!this.manufacturer || this.manufacturer.length <= 0) { 24 | this.errors.push('The toy must have a manufacturer.') 25 | } 26 | 27 | // parseFloat(this.price) != this.price will detect cases like this" parseFloat("201 Main street") 28 | // where the returned value (201) is not the entire string. Notice the use of == to compare the number 29 | // and the string. 30 | if (!this.price) { 31 | this.errors.push('The toy must have a price.') 32 | } else if (isNaN(parseFloat(this.price)) || parseFloat(this.price) != this.price) { 33 | this.errors.push('The price must be a number.') 34 | } else if (this.price < 0.0) { 35 | this.errors.push('The price must not be negative.') 36 | } 37 | return this.errors.length <= 0 38 | } 39 | } 40 | 41 | module.exports = Toy -------------------------------------------------------------------------------- /ExpressMVCSqliteCallbacks/models/Toy.js: -------------------------------------------------------------------------------- 1 | class Toy { 2 | 3 | constructor(description) { 4 | // if description is null or undefined, we want to create an "empty" Toy object. 5 | if (description) { 6 | this.id = description.id 7 | this.name = description.name 8 | this.description = description.description 9 | this.price = description.price 10 | this.manufacturer = description.manufacturer 11 | } 12 | this.errors = [] 13 | } 14 | 15 | isValid() { 16 | this.errors = [] 17 | if (!this.name || this.name.length <= 2) { 18 | this.errors.push('The name must contain at least three characters') 19 | } 20 | if (!this.description || this.description.length <= 0) { 21 | this.errors.push('The toy must have a description.') 22 | } 23 | if (!this.manufacturer || this.manufacturer.length <= 0) { 24 | this.errors.push('The toy must have a manufacturer.') 25 | } 26 | 27 | // parseFloat(this.price) != this.price will detect cases like this" parseFloat("201 Main street") 28 | // where the returned value (201) is not the entire string. Notice the use of == to compare the number 29 | // and the string. 30 | if (!this.price) { 31 | this.errors.push('The toy must have a price.') 32 | } else if (isNaN(parseFloat(this.price)) || parseFloat(this.price) != this.price) { 33 | this.errors.push('The price must be a number.') 34 | } else if (this.price < 0.0) { 35 | this.errors.push('The price must not be negative.') 36 | } 37 | return this.errors.length <= 0 38 | } 39 | } 40 | 41 | module.exports = Toy -------------------------------------------------------------------------------- /ExpressMVCSqlitePromises/models/Toy.js: -------------------------------------------------------------------------------- 1 | class Toy { 2 | 3 | constructor(description) { 4 | // if description is null or undefined, we want to create an "empty" Toy object. 5 | if (description) { 6 | this.id = description.id 7 | this.name = description.name 8 | this.description = description.description 9 | this.price = description.price 10 | this.manufacturer = description.manufacturer 11 | } 12 | this.errors = [] 13 | } 14 | 15 | isValid() { 16 | this.errors = [] 17 | if (!this.name || this.name.length <= 2) { 18 | this.errors.push('The name must contain at least three characters') 19 | } 20 | if (!this.description || this.description.length <= 0) { 21 | this.errors.push('The toy must have a description.') 22 | } 23 | if (!this.manufacturer || this.manufacturer.length <= 0) { 24 | this.errors.push('The toy must have a manufacturer.') 25 | } 26 | 27 | // parseFloat(this.price) != this.price will detect cases like this" parseFloat("201 Main street") 28 | // where the returned value (201) is not the entire string. Notice the use of == to compare the number 29 | // and the string. 30 | if (!this.price) { 31 | this.errors.push('The toy must have a price.') 32 | } else if (isNaN(parseFloat(this.price)) || parseFloat(this.price) != this.price) { 33 | this.errors.push('The price must be a number.') 34 | } else if (this.price < 0.0) { 35 | this.errors.push('The price must not be negative.') 36 | } 37 | return this.errors.length <= 0 38 | } 39 | } 40 | 41 | module.exports = Toy -------------------------------------------------------------------------------- /SimpleWebClient/Java/DebugHTTPTransaction.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.net.Socket; 3 | 4 | /** 5 | * Simple HTTP Client 6 | * 7 | * This program 1. Creates a socket connected to a web server 2. Makes a GET 8 | * request 3. Prints the response headers to the standard output 4. Saves the 9 | * data to a file named 'document' 10 | * 11 | * 12 | * Created by kurmasz on 4/27/15. 13 | */ 14 | public class BasicHTTPTransaction { 15 | 16 | public static void main(String[] args) throws IOException { 17 | 18 | // Values set up for a web server running locally. 19 | // One option is to run "python -m SimpleHTTPServer" from the data directory 20 | String host = "localhost"; // www.gvsu.edu"; 21 | int port = 8534; 22 | String file = "/Pictures/"; 23 | String outputFile = "opt.index.html"; 24 | 25 | Socket socket = new Socket(host, port); 26 | 27 | InputStream rawInput = socket.getInputStream(); 28 | BufferedReader input = new BufferedReader(new InputStreamReader(rawInput)); 29 | 30 | OutputStream rawOutput = socket.getOutputStream(); 31 | PrintWriter output = new PrintWriter(rawOutput); 32 | 33 | output.printf("GET %s HTTP/1.1\n", file); 34 | output.printf("Host: %s\n", host); 35 | output.println(""); 36 | output.flush(); 37 | 38 | String line = input.readLine(); 39 | while (line.length() > 0) { 40 | System.out.println(line); 41 | line = input.readLine(); 42 | } 43 | 44 | PrintWriter fileOutput = new PrintWriter(new FileOutputStream(outputFile)); 45 | line = input.readLine(); 46 | while (line != null) { 47 | fileOutput.println(line); 48 | line = input.readLine(); 49 | } 50 | fileOutput.close(); 51 | socket.close(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /ReactJSXIntro/complexDOMcreateElement.js: -------------------------------------------------------------------------------- 1 | // Example of a bigger, more complex DOM created using createElement 2 | // From Porcello and Banks book. 3 | 4 | React.createElement( "section", { id: "baked-salmon" }, 5 | React.createElement("h1", null, "Baked Salmon"), 6 | React.createElement("ul", { className: "ingredients" }, 7 | React.createElement("li", null, "2 lb salmon"), 8 | React.createElement("li", null, "5 sprigs fresh rosemary"), 9 | React.createElement("li", null, "2 tablespoons olive oil"), 10 | React.createElement("li", null, "2 small lemons"), 11 | React.createElement("li", null, "1 teaspoon kosher salt"), 12 | React.createElement("li", null, "4 cloves of chopped garlic") 13 | ), 14 | React.createElement( "section", { className: "instructions" }, 15 | React.createElement("h2", null, "Cooking Instructions"), 16 | React.createElement("p", null, "Preheat the oven to 375 degrees."), 17 | React.createElement("p", null, "Lightly coat aluminum foil with oil."), 18 | React.createElement("p", null, "Place salmon on foil."), 19 | React.createElement("p", null, "Cover with rosemary, sliced lemons, chopped garlic."), 20 | React.createElement("p", null, "Bake for 15-20 minutes until cooked through."), 21 | React.createElement("p", null, "Remove from oven.") 22 | ) 23 | ); 24 | 25 | // Or, we can separate the data from the structure: 26 | const items = [ 27 | "2 lb salmon", 28 | "5 sprigs fresh rosemary", 29 | "2 tablespoons olive oil", 30 | "2 small lemons", 31 | "1 teaspoon kosher salt", 32 | "4 cloves of chopped garlic" 33 | ]; 34 | 35 | React.createElement( "ul", { className: "ingredients" }, 36 | items.map((ingredient, i) => React.createElement("li", { key: i }, ingredient)) 37 | ); -------------------------------------------------------------------------------- /ColorListAPI_rails/Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 | 4 | ruby "3.1.2" 5 | 6 | # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" 7 | gem "rails", "~> 7.0.8", ">= 7.0.8.1" 8 | 9 | # Use sqlite3 as the database for Active Record 10 | gem "sqlite3", "~> 1.4" 11 | 12 | # Use the Puma web server [https://github.com/puma/puma] 13 | gem "puma", "~> 5.6" 14 | 15 | # Build JSON APIs with ease [https://github.com/rails/jbuilder] 16 | # gem "jbuilder" 17 | 18 | # Use Redis adapter to run Action Cable in production 19 | # gem "redis", "~> 4.0" 20 | 21 | # Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis] 22 | # gem "kredis" 23 | 24 | # Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] 25 | # gem "bcrypt", "~> 3.1.7" 26 | 27 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem 28 | gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ] 29 | 30 | # Reduces boot times through caching; required in config/boot.rb 31 | gem "bootsnap", require: false 32 | 33 | # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] 34 | # gem "image_processing", "~> 1.2" 35 | 36 | # Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible 37 | # gem "rack-cors" 38 | 39 | group :development, :test do 40 | # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem 41 | gem "debug", platforms: %i[ mri mingw x64_mingw ] 42 | end 43 | 44 | group :development do 45 | # Speed up commands on slow machines / big apps [https://github.com/rails/spring] 46 | # gem "spring" 47 | end 48 | 49 | -------------------------------------------------------------------------------- /JavaScriptAsynchronous/timerPromiseWithFeedback.mjs: -------------------------------------------------------------------------------- 1 | /************************************************************************************ 2 | * 3 | * timerPromiseWithFeedback.js 4 | * 5 | * Imagine doing this with straight callbacks. 6 | * 7 | ************************************************************************************/ 8 | 9 | import * as readline from 'readline'; 10 | 11 | 12 | // I put this here because, in my opinion, the entire program should use the same io object.\ 13 | const io = readline.createInterface({ 14 | input: process.stdin, 15 | output: process.stdout, 16 | }); 17 | 18 | 19 | let askAreYouUp = () => { 20 | return new Promise( (resolve, reject) => { 21 | io.question("Are you? ", (line) => { 22 | if (line.toLocaleLowerCase().trim().startsWith('y')) { 23 | console.log("(d3b) Good. Go eat breakfast"); 24 | resolve(); 25 | } else { 26 | reject("Not again :( ") 27 | } 28 | }) 29 | }) 30 | } 31 | 32 | let setTimer = (delay) => { 33 | return new Promise( (resolve, reject) => { 34 | setTimeout(resolve, delay) 35 | }) 36 | } 37 | 38 | console.log("(d1) Begin.") 39 | setTimer(1000).then( () => { 40 | console.log("(d2) It's time to wake up.") 41 | return setTimer(1500) 42 | }).then( () => { 43 | console.log("(d3) You should be out of bed by now.") 44 | return askAreYouUp() 45 | }).then( (line) => { 46 | return setTimer(2000) 47 | }).then( () => { 48 | console.log("(d4) Breakfast time is over. Go brush your teeth.") 49 | return setTimer(500) 50 | }).then( () => { 51 | console.log("(d5) That's long enough. Now get to the bus!") 52 | }).catch( (message) => { 53 | console.log(message) 54 | }).finally( () => io.close()) 55 | 56 | --------------------------------------------------------------------------------