A list of useful programming things I'm learning and issues I fixed.
Windows machines still have carriage return + line feed (\r\n) to end a new line while unix based systems have standerdized upon just line feed (\n)
- ANSI
- Ascii
- Unicode (UTF-8 vs UTF-8 w/ Signature)
- UTF-8 with signiture has a BOM (3 bytes in the beginning)
Resources:
Create a .gitignore file in your current repo if you want to ignore certain files and folders. Each file/folder should be on a seperate line and folders need to have a / at the end. To stop tracking a file that is currently tracked, use 'git rm --cached FILENAME'
CMD-L shortcut to select a line didn't work on Vscode because a live share extension shortcut interfered. Can either delete live share or change the live share keyboard shortcut to get rid of the problem.
Use "git push --set-upstream " to use the repo as the new default when typing "git push".
$ git ls-files | xargs wc -l (only caviat is you need to have the files tracked in git)
reverse-i-search: Search backward starting at the current line and moving ‘up’ through the history as necessary. This is an incremental search.
How to use: Press the ctrl key and the r key simultaneously.
When we want to convert letters to unicode or compare between them, we can use the ord function in python.
# Example usage:
- ord('A') # 54
- ord('B') - ord('A') # 1To invert numbers, we can use the XOR bitwise operator (^1).
It's possible to backdate git commits by using the --date commit argument.
Example: git commit --date="2004.07.14 13:00" -m "an old commit"
Use pyinstaller to do this using the following command: % pyinstaller --onefile 'filename.py'
Use pyautogui to do this. Can use this code:
while True: pyautogui.scroll(-50); pyautogui.time.sleep(0.2)
Use a VPS like Linode or Digital Ocean, spin up an Ubuntu server, and use nohup to run it in the background.
nohup python myScript.py# copy myfile.txt to remote server and place in /remote/server (will place in home if left unspecified).
scp myfile.txt remoteuser@remoteserver:/remote/folder/
# copy everything in current folder to remote server.
scp * remoteuser@remoteserver:/remote/folder/Credit to this guide.
Simply insert a "breakpoint()" in the code on a line, which will trigger a built in debugger, Pdb. Then, run your program and step through it using 'n' for next. You can also query variables at any point while stepping through.
More commands can be found here