Table Features with Bootstrap MDB 5
Responsive tables: https://mdbootstrap.com/snippets/jquery/cam/979615#html-tab-view
Other table features: https://mdbootstrap.com/docs/standard/data/tables/
Database Visualization
Amazing platform to create database visualization: https://dbdiagram.io
How to send POST Request to API in Python with requests module
This article quite frankly saved my life, I hope it helps you too: https://pynative.com/python-post-json-using-requests-library/
How to push from Branch to Master in Git
How to push from a remote branch to master: https://stackoverflow.com/questions/5423517/how-do-i-push-a-local-git-branch-to-master-branch-in-the-remote
What to do if you know what you are doing or are experienced with Git:
$ git push <remote branch>:master
General format:
$ git push <remote> <local branch name>:<remote branch to push into>
git checkout master
git pull # to update the latest master state
git merge develop # to merge branch to master
git push origin master # push current HEAD to master
I did the second version, and was able to successfully push to master!
How to Add Line Numbers to Vim Permanently
Recently I’ve started working with a VM and I realized that debugging was a bit hard because I couldn’t see the line numbers for the code, so I searched up how you can see line numbers in vim, and found that when you are in a file with vim, press ESC, then enter the command:
:set number
The line numbers will show up. Yet, if you quit out of that session, and vi into the file again, you will see that the line numbers are gone. In order to set line numbers permanently in vim, you would need to go into your ~/.vimrc file and set properties for vim, but I noticed that in the VM I was on, there were no other directories or that file, so I created that file in my home directory by doing:
cd ~ vim .vimrc set number :wq
1st command: goes to home directory
2nd command: creates .vimrc file
3rd command: adds “set numbers” property into vimrc
4th command: saves and quits out of file
How to Query from MySQL Database in Python
Link: https://www.w3schools.com/python/python_mysql_select.asp
fetch-all()
import mysql.connector
mydb = mysql.connector.connect (
host="localhost",
user="yourusername",
password="yourpassword",
database="mydatabase"
)
mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM customers")
myresult = mycursor.fetchall()
for x in myresult:
print(x)
fetchone()
import mysql.connector
mydb = mysql.connector.connect (
host="localhost",
user="yourusername",
password="yourpassword",
database="mydatabase"
)
mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM customers")
myresult = mycursor.fetchone()
for x in myresult:
print(x)
Python UUID
Generating UUID in Python: https://docs.python.org/3/library/uuid.html
>>> import uuid >>> # make a UUID based on the host ID and current time >>> uuid.uuid1() UUID('a8098c1a-f86e-11da-bd1a-00112444be1e') >>> # make a UUID using an MD5 hash of a namespace UUID and a name >>> uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org') UUID('6fa459ea-ee8a-3ca4-894e-db77e160355e') >>> # make a random UUID >>> uuid.uuid4() UUID('16fd2706-8baf-433b-82eb-8c7fada847da') >>> # make a UUID using a SHA-1 hash of a namespace UUID and a name >>> uuid.uuid5(uuid.NAMESPACE_DNS, 'python.org') UUID('886313e1-3b8a-5372-9b90-0c9aee199e5d') >>> # make a UUID from a string of hex digits (braces and hyphens ignored) >>> x = uuid.UUID('{00010203-0405-0607-0809-0a0b0c0d0e0f}') >>> # convert a UUID to a string of hex digits in standard form >>> str(x) '00010203-0405-0607-0809-0a0b0c0d0e0f' >>> # get the raw 16 bytes of the UUID >>> x.bytes b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f' >>> # make a UUID from a 16-byte string >>> uuid.UUID(bytes=x.bytes) UUID('00010203-0405-0607-0809-0a0b0c0d0e0f')
Installing Postgres on MacOS with Brew
Pre-Reqs
brew doctor
brew update
Installing
brew install postgres
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
Create aliases:
alias pg_start="launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist"
-
alias pg_stop="launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist"
This alias is only set for that terminal window, so to set this permanently, find your shell path by:
-
echo $SHELL
Then you can append the alias to the computer shell file. For me, this was ~/.zshrc
Note: Make sure to echo the alias and use “>>” to append, not “>” which completely wipes the file with the text. This is what I did, and unfortunately, all the past things I added to my shell file were erased and it could not be undone.
Installing a Virtual Machine from VirtualBox
Link to download VirtualBox: https://www.virtualbox.org
After downloading, must download a Virtual Machine Image: https://www.osboxes.org/virtualbox-images/
