There are many facts and tricks that I have come across that I frequently forget. This page tried to remedy that and hopefully help others :)
Git and GitHub
Here are some tricks pertaining to Git and GitHub.
Force GitHub Pages Build
Once upon a time I tried to update my GitHub Pages website (this one) by pushing a commit. Unfortunately, it did not succeed! I got an email stating my "pages build and deployment" had failed. It turned out that GitHub Actions had failed. Unsure what to do, I looked around a little for a solution. Many of them either recommended pushing an empty commit, or setting up some fancy yml script for Actions. Seeing as how my webpage is very simple, and that I didn't want to clutter my commit history with empty rebuild requests, I decided to use the following solution:
- Download GitHub CLI.
- In the Command Prompt (or terminal if you're using Mac or Linux), run the following command
- REPO: the name of the repository you want to rebuild (nathangs6.github.io for me)
- OWNER: the owner of the repository you want to rebuild (nathangs6 for me)
gh api --method POST /repos/OWNER/REPO/pages/builds
where,
Source: this answer by Bennet Blodinger.
LaTeX
TikZ
HTML and CSS
Here are some tricks regarding HTML and CSS.
Fun Tab Icons
If you are on a computer, look up at the tab you are currently on. You should see . If you want something similar, here is how you can do so:
- Find the image you want, and save it as "favicon.io" somewhere in your repository.
- In the head element of your .html page, add
<link rel="icon" type="image/x-icon" href="link/to/favicon.ico">
Making Your Site Mobile-Friendly
Making your website mobile-friendly is pretty easy. First, in your head element, add the following line:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Then, in the relevant CSS file, add the following:
@media all and (max-width: dimension) {
identifier {
styling
}
}
If you would like to go from mobile-friendly to computer-friendly, simply replace max-width: dimension
to min-width: dimension
. You can chain these one after another to be adaptable to many screen sizes, but remember that the later styling will overwrite the earlier ones!
Google Apps Script
Here are some tricks I've come across when using Google Apps Script (which is so much better than Excel VBA wow)
Global Constants
To simplify my code, I usually like to use global constants. Doing so was particularly useful for my finance tracker. Unfortunately, in Google Apps Script, this isn't really possible like it is in Python (for example). I stumbled across a StackOverflow answer that provided a simple enough solution for my purposes. Essentially, you can just make a "constants function" which, when called, gives you all your global constants. For example, it could look like this:
function globalConstants() {
var constants = {
x: 10
};
return constants
}
Then, when you want to use it, you can just do:
gc = globalConstants();
y = 1 + gc.x;
Source: this answer by KrzFra and edited by Magne.
UofT Website
If you are a student at UofT, you can host your own static webpage through them! It functions exactly like a GitHub Pages site does. Here is how that is done:
- Go here and read the FAQ and conditions and use.
- To request the web space you'll be sent to this website. Go to "Get Information" -> get information.
- Login, go to make changes, and click on "individual web space".
- There should be a subsection on that page for "Individual Web Space" where you can request web space.
- Within a day you should have a website ready for use!