An AWS Cloud Architecture For Web Hosting
https://docs.aws.amazon.com/whitepapers/latest/web-application-hosting-best-practices/an-aws-cloud-architecture-for-web-hosting.html

Web Architecture 101
https://medium.com/storyblocks-engineering/web-architecture-101-a3224e126947

How Amazon Route 53 Routes Traffic For Your Domain
https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/welcome-dns-service.html

    bash
  1. .bashrc = Bash login script.
  2. .bash_logout = Bash logout script.
  3. .bash_history = Bash history file.
  4. $ history
    Show bash history.
  5. $ history -c
    Clear bash history.
  6. $ !commandnumber
    Execute command number commandnumber from bash history.
    browser support
  1. General rule: If a browser has less than 1% usage, do not support it.
  2. IE 7 and above will handle multiple classes for an element.
    Example: <div class="red border box"></div>
  3. CSS Grid functionality will eventually make all CSS grid frameworks obsolete.
  4. Preventing CSS & JavaScript Caching
    I have seen a few different ways after googling. Here is a comment I like,
    If you're going to make the browser download the CSS/JS every time then you may as well just include it in the page itself so only one request needs to be made per page.
  5. 66 characters per line counting both letters and spaces
  6. 10 words per line
    css links
  1. https://zellwk.com/blog/9-important-css-properties-you-must-know/
  2. https://code.tutsplus.com/tutorials/the-30-css-selectors-you-must-memorize--net-16048
    directory navigation
  1. $ cd
    Navigate to your home directory.
  2. $ cd -
    Navigate to previous directory.
  3. $ cd /
    Navigate to root directory.
    disk usage
  1. $ df -HT
    Human readable in Gigabytes along with file system type.
  2. $ df --help
    Help information.
  3. $ du -ahx . | sort -rh | less
    Calc file/directory sizes in the current directory.
    find files
  1. $ find / -name 'name'
    / is the directory
    name is the name of the file
  2. $ locate name
    name is the name of the file
    locate is faster than find BUT locate uses an index that may not be up to date.
    ls -la
  1. $ ls -la | grep '<searchpattern>'
  2. $ ls -la <searchpattern> -d
    List files/directories matching search pattern without going into subdirectories.
    Operating System Stuff
  1. $ hostnamectl
  2. $ lsb_release -a
  3. In recent years, Linux distributions have increasingly transitioned from other init systems to systemd
    gzip
  1. gzip -d file.gz
    Restore the compressed file to its original state and remove the .gz file.
  2. gzip -dk file.gz
    Restore the compressed file but leave the compressed .gz file as is.
    display special character
  1. cat -A filename
  2. https://en.wikipedia.org/wiki/Control_character#In_ASCII
  3. backspace: BS, \b, ^H
  4. carriage return: CR, \r, ^M
  5. horizontal tab: HT, \t, ^I
  6. line feed: LF, \n, ^J, $
    git
    $ git status
    $ git commit -a -m "Commit mm/dd/yy hh:mm"
    $ git push -u origin master
    $ git status
    On branch master Your branch is up to date with 'origin/master'.

    nothing to commit, working tree clean
git

You're working on your project and have a couple of commits already on the master branch. This is your Production version of code.

You decide to add new funtionality to Production.

Create a new branch off master: $ git branch newfunctionality

Switch to the new branch: $ git checkout newfunctionality

You are working and doing commits on branch newfunctionality

Production code blows up and you need to fix it.

Commit your changes on branch newfunctionality.

Switch back to master: $ git checkout master

Create a new branch off master: $ git branch emergencyfix

Switch to the new branch: $ git checkout emergencyfix

fix the code and then commit it to emergencyfix

Switch to master: $ git checkout master

Merge emergencyfix into master: $ git merge emergencyfix

Delete emergencyfix: $ git branch -d emergencyfix

Got back to newfunctionalitybranch: $ git checkout newfunctionality

    go coding techniques
  1. https://arslan.io/2015/10/08/ten-useful-techniques-in-go/
  2. Convert Int to string:strconv.FormatInt(int64(tickOffsetInt),10))
  3. fmt.Fprintf(os.Stdout, "\nFprintf xAxisValue:%+#v\n", xAxisValue) // TODDDEBUGTEMP
    go code formatting
  1. gofmt -w Make sure you are not editing the file you are formatting.
    grep - recursively through subdirectories
  1. grep -r searchstring ./
    media queries
  1. @media only screen and (max-width: 600px) {...}
    if [device width] is less than or equal to 600px, then do {...}
  2. @media only screen and (min-width: 600px) {...}
    if [device width] is greater than or equal to 600px, then do {...}
    nginx
  1. $ apt update
  2. $ apt install nginx
  3. $ systemctl status nginx
    package management
  1. https://www.debian.org/doc/debian-policy/
    Detailed documentation describing the policy requirements for the Debian distribution and the creation of Debian packages.
  2. $ apt help Gives less complex help information about apt than $ man apt
  3. To list all packages installed on the system:
  4. $ apt list --installed
  5. $ dpkg -l
  6. To list certain packages installed on the system:
  7. $ apt list --installed nginx*
  8. $ dpkg -l nginx*
  9. To list the files installed by a package:
  10. $ dpkg -L nginx
  11. If you are not sure which package installed a file, dpkg -S MAY BE ABLE to tell you. For example:
  12. $ dpkg -S /etc/host.conf
  13. base-files: /etc/host.conf
  14. The output shows that the /etc/host.conf belongs to the base-files package.
  15. To show the details of a package:
  16. $ apt show nginx
  17. https://manpages.debian.org/jessie/dpkg-dev/deb-control.5.en.html
    The syntax of Depends, Pre-Depends, Recommends and Suggests fields is a list of groups of alternative packages. Each group is a list of packages separated by vertical bar (or 'pipe') symbols, '|'. The groups are seperated by commas. Commas are to be read as 'AND', and pipes as 'OR', with pipes binding more tightly. Each package name is optionally followed by a version number specification in parentheses.

    A version number may start with a '>>', in which case any later version will match, and may specify or omit the Debian packaging revision (seperated by a hyphen). Accepted version relationships are '>>' for greater than, '<<' for less than, '>=' for greater than or equal to, '<=' for less than or equal to, and '=' for equal to.
    postgres
  1. sudo su postgres
  2. printenv
  3. export PAGER="less -S -X"
  4. psql -d kenworth
  5. \pset null (null)
  6. Execute commands from a file:
  7. \i /home/toddad538/postgresql/function/uc_get_all_nothing_done_support
  8. Execute postgres function from psql:
  9. select * from uc_get_all_nothing_done_support();
  10. As postgres, did the following in directory /var/lib/postgresql:
  11. $ pg_dump kenworth > kenworthdb.mmddyy
  12. $ pg_dumpall -g > kenworthglobals.mmddyy
  13. DECLARE TODDDEBUGRECORD;
  14. FOR TODDDEBUGRECORD IN SELECT * FROM tablename LOOP
  15. RAISE NOTICE '%', to_json(TODDDEBUGRECORD);
  16. END LOOP;
  17. RAISE NOTICE 'v_aggregate_row_count(%)', v_aggregate_row_count;
  18. As postgres in directory: /var/lib/postgresql run the following:
  19. $ pg_lsclusters
  20. It will show you the clusters AKA database servers running on that server.
  21. It displays: Version,Cluster,Port,Status,Owner,Data directory,Log file

select json_each(CAST(session_data AS JSON)) from user_data;
select session_data::json->>'graphthrower' from user_data;

    Regex tutorial - A quick cheatsheet by examples
  1. https://medium.com/factory-mind/regex-tutorial-a-simple-cheatsheet-by-examples-649dc1c3f285
    sed - show what would change in file
  1. sed 's/old-text/new-text/g' input.txt
    sed - actully change the file
  1. sed -i 's/old-text/new-text/g' input.txt
    sed - show all lines between <style> and </style>
  1. sed -n '/<style>/,/</style>/p' <filename>
    screen resolutions
  1. Android browser version 2.3.4 portrait 320x473 landscape 533x260
  2. Opera Mini browser versions 20.0 portrait 300x387 landscape 500x193
    Get a list of running services as root run
  1. $ systemctl | grep running
    How to check if installing a package will require a reboot?
  1. Short answer: you can't
  2. Long answer: you can but it'll be a real nightmare to implement and maintain a way to detect all possible reboot notifications
  3. https://askubuntu.com/questions/674967/how-to-check-if-installing-a-package-will-require-a-rebootp

vi
0 Number zero, move to beginning of line.
$ Move to end of line.

vi & less
G Move to end of file.
1G Move to top of file.
ctrl+f Page down.
ctrl+b Page up.
/<searchtext> in command mode search forward.
?<searchtext> in command mode search backward.
n goes to the next instance of <searchtext> in the direction of the last search.
N goes to the next instance of <searchtext> in the opposite direction of the last search.

    vi search and replace in a visual selection
  1. Select the text.
  2. Hit the enter key.
  3. Hit the escape key.
  4. Enter the following: :%s/\%Vtexttoreplace/newtext/g
    Web pages for future reference
  1. http://paulgraham.com/startupideas.html
    How to come up with start up ideas.
  2. https://medium.com/@mattholt/its-2019-and-i-still-make-websites-with-my-bare-hands-73d4eec6b7
    It is ok to be old school.
  3. https://blog.codinghorror.com/your-session-has-timed-out/
    Pros/Cons of web app session timeouts.
    Techniques to do timeouts without pissing off users.
  4. https://blog.nugget.one/upstart/how-to-multiply-the-potential-of-every-startup-idea/

    One of Elon Musks super powers is he thinks optimistically about any idea that comes into his head. He forces himself to think it through and try to solve all the problems it might present.

    For example, if someone told you they had a great idea to ease traffic congestion by building hundreds of tunnels under cities, you would probably think, Thats stupid, dont waste any time thinking about that!

    Not so for Elon. He lets his mind go there. He optimistically tries to solve even the most outrageous sounding problems. Next time you hear an idea that sounds stupid, try to think about it optimistically and see if that presents you with anything interesting.

  5. https://blog.nugget.one/upstart/competition-does-not-matter/
    6 Reasons Competition Does Not Matter
    Alexa max session length
  1. No .mp3 file: 90 seconds
  2. Using .mp3 file: 240 seconds

JSON object
It is derived from Javascript objects.
It is a text only string.
The keys must be a string written with double quotes:
{"name":"harrry","price":120,"inStock":true,"features":["WiFi","LTE"],"xyz":null}
The values can be any of the following:
strings, numbers, objects, arrays, Boolean, null
Convert JSON object to a Javascript object: JSON.parse()

Javascript object
It is a type in the Javascript language.
The keys and values can be strings, numbers or identifier names. The strings can be single or double quotes.
{name:"harrry",price:120,inStock:true,features:["WiFi","LTE"],xyz:null}
Convert Javascript object to JSON object: JSON.stringify()

Check Versions
Ubuntu Operating System & Kernel
As root: $ hostnamectl

Nginx
As root: $ nginx -v

Postgres Client
As postgres: $ psql -V

Postgres Server
As postgres: $ psql -d kenworth
psql prompt: # select version();

ThrowsLog.com shut down:
Logged in as root
$ ps -ef | egrep "kenworth|UID"
$ kill ??? (whatever the PID is for /home/toddad538/go/bin/kenworthserver)
$ kill ??? (whatever the PID is for /home/toddad538/go/bin/kenworthexception)
$ systemctl stop nginx
$ systemctl stop postgresql
Log out of SSH sessions and select the Stop command from the GCP control panel for the VM you want to shut down.
Once the instance has stopped select the Start/Resume command from the GCP control panel for the VM you want to start up.

ThrowsLog.com start up:
As root do the following:
If $ systemctl status nginx does not show it running
$ systemctl start nginx
If $ systemctl status postgresql does not show it running
$ systemctl start postgresql
Run the following commands as root in /home/toddad538/go/bin:
$ /home/toddad538/go/bin/kenworthserver &
$ /home/toddad538/go/bin/kenworthexception &

ThrowsLog.com & NotesRightHere.com monitoring:
$ ps -ef | egrep "kenworth|UID"
$ systemctl status nginx 'postgresql*'

grep results should be similar to the following processes:

root 00000 00000 0 00:00 pts/2 00:00:00 /home/toddad538/go/bin/kenworthserver
postgres 00000 00000 0 00:00 ? 00:00:00 postgres: 11/main: postgres kenworth 127.0.0.1(00000) idle

NotesRightHere.com shut down:
Logged in as root
$ ps -ef | egrep "kenworth|UID"
$ kill ??? (whatever the PID is for /home/toddad538/go/bin/kenworthserver)
$ systemctl stop nginx
$ systemctl stop postgresql
Log out of SSH sessions and select the Stop command from the GCP control panel for the VM you want to shut down.
Once the instance has stopped select the Start/Resume command from the GCP control panel for the VM you want to start up.

NotesRightHere.com start up:
As root do the following:
If $ systemctl status nginx does not show it running
$ systemctl start nginx
If $ systemctl status postgresql does not show it running
$ systemctl start postgresql
Run the following commands as root in /home/toddad538/go/bin:
$ /home/toddad538/go/bin/kenworthserver &

Ubuntu System Maintenance
If needed do: Throwslog.com shut down: Leave VM running
If needed do: NotesRightHere.com shut down: Leave VM running

Logged in as root.

$ apt update
This command uses the repository entries in the following:
1. File: /etc/apt/sources.list
2. Files in directory: /etc/apt/sources.list.d/

Example entry:
deb http://us-central1.gce.archive.ubuntu.com/ubuntu/ bionic main restricted

to download/update the files in
/var/lib/apt/lists/partial
and then
/var/lib/apt/lists

The files in /var/lib/apt/lists contain the information
about all the packages in the repositories pointed to
by the repository entries in 1. & 2. above.

I believe the files in /var/lib/apt/lists can be deleted temporarily
because the files are created by the apt update command.
If the files in /var/lib/apt/lists are temporarily deleted
other commands may fail because those commands use the
information in the files in /var/lib/apt/lists.

Once the apt update command is finished I don't belive
there should be any files in /var/lib/apt/lists/partial

$ apt list --upgradable
Look over the packages that will be updated.

$ apt upgrade
If you see there are packages that are no longer needed,
Answer the: Do you want to continue? [Y/n] with n
and run the following:

$ apt autoremove
The autoremove option is used to remove packages that were automatically
installed to satisfy dependencies for other packages and are now no longer
needed as dependencies changed or the package(s) needing them were removed
in the meantime. For example, when you upgrade Linux kernel to 4.1.5,
you may not need Linux kernel version 3.8.5.

$ apt list | grep '\[residual-config'
This command will list config files related to the packages that were removed
by the: apt autoremove command above.

$ apt purge [package_name]
This command will delete the config files for package(s) that were returned
from the: apt list | grep '\[residual-config' command above

$ apt upgrade
This is the command that will apply any changes needed to installed packages
and/or those packages dependency packages.

$ apt clean
This removes all retrieved package files (.deb) from the local repository except
for the lock file.
(.deb) files in transit go into directory
/var/cache/apt/archives/partial
(.deb) files that have finished downloading go into directory
/var/cache/apt/archives

$ apt autoclean
This does the same as apt clean BUT it only removes (.deb) files that can no
longer be downloaded, and are largely useless. This allows the cache to be
maintained over a long period without it going out of control.

$ snap list --all
For any that have: disabled in the Notes column do the following:
$ snap remove Namecolumn --revision=Revcolumn
Remove the files in /var/lib/snapd/cache without issue.
Also there is no need to stop the snapd service.

Once the: apt upgrade command has finished use Google Cloud Console to stop and
then restart the VM instance.

dpkg is the low level package management tool that is called by command:
apt upgrade
/var/lib/dpkg/info contains files that relate to packages - including the list of
files (as full path names) provided by each package, the MD5sums of each of these
files, and the executable scripts that would be run before and after installation
or removal (preinst, postinst, prerm, postrm). Of course the system contains many,
many packages and each one has multiple files here.

The more packages you install, the bigger this directory will get.

THIS DIRECTORY IS REALLY IMPORTANT TO THE SYSTEM.
YOU SHOULD NEVER DELETE ANYTHING FROM IT MANUALLY.
IF YOU DO, YOU CAN EXPECT BAD BAD BAD THINGS TO OCCUR.
Use the following to manipulate this directory:
apt commands, apt-get commands or dpkg commands

/var/lib/dpkg/info/[package_name].list
$ apt remove [package_name]
The command above deletes the files/directories listed in
file: /var/lib/dpkg/info/[package_name].list
Directories are only deleted if they are empty.

/var/lib/dpkg/info/[package_name].conffiles
$ apt purge [package_name]
The command above deletes the files listed in file:
/var/lib/dpkg/info/[package_name].conffiles
It can be used to delete config files even if package related files have already
been deleted.
Not sure if .conffiles contains directories or not.
If there are, I assume the same rules apply to them as for directories listed in
the .list file.

Any files or directories not in .list or .conffiles need to be deleted by the
system administrator. These would be files that are created by something or
someone other than dpkg.

Directory /var/cache/apt/archives/partial
Storage area for package files (.deb) in transit.
Directory /var/cache/apt/archives
Storage area for retrieved package files (.deb).

https://fred.stlouisfed.org/series/T10Y3M
https://fred.stlouisfed.org/series/T10Y2Y
You want 0 or higher.

https://tradingeconomics.com/united-states/business-confidence
The ISM (Institute of Supply Management) surveys 50,000+ executives from 400 US manufacturing companies monthly to gauage their sentiment on various factors, such as employment, new orders, production, and more.
A score below 50 indicates contraction and may signal an impending recession.
Above 50 signals growth.
Over 60 signals a booming economy.