Jekyll2024-08-30T14:21:44+00:00https://theprojectsguy.github.io/feed.xmlblankMy personal webpage based on the [al-folio](https://github.com/alshedivat/al-folio) theme. Creating a Python Project with Docs2022-12-17T14:30:00+00:002022-12-17T14:30:00+00:00https://theprojectsguy.github.io/blog/2022/projrepoThis is a template I use to create projects and docs. This page is to give a special emphasis on docs. I’ll be creating a project named FeatMF.

Table of contents

Pre-requisites

You must have the following

  • A github account. I prefer to have SSH keys and gh CLI setup.
  • A readthedocs account with GitHub (or other platforms) connected.
  • For environment management, you have pyenv and Python poetry installed.
  • Knowledge of git, bash, python environments, documentation. Some reference is included below.

Steps

Do the following

Step 1: Setup the empty repository locally

mkdir FeatMF && cd $_
git init -b main
touch README.rst

Add other things like IDE files, .gitignore files, etc. We’ll choose the GNU LGPL v3 license.

Add the first commit

git add --all
git commit -m "First commit"

Step 2: Upload the repository to GitHub

  • On GitHub (or any git hosting platform), create repository with no README or LICENSE (everything will be uploaded from local).
  • Add remote

      git remote add origin https://github.com/TheProjectsGuy/FeatMF.git
    
  • Push the changes to GitHub

      git push origin -u main
    

Step 3: Setup Python Poetry

  1. Setup Python poetry for this project (using Python from pyenv)

    • Initialize it (an interactive menu setup follows)

        poetry init
      

      I choose python 3.8 for this project (supported by multiple libraries), but my OS has python 3.10.6. I do not prefer using the system interpreter (unless it’s absolutely necessary)

    • We’ll create a pyenv for python 3.8 and make the local folder use that python all the time.

        # Depending on what you have in `~/.zshrc`
        pyenv-init || eval "$(pyenv init -)"
        # Install Python 3.8
        pyenv install 3.8
        pyenv local 3.8
        python --version    # Should be 3.8.*
      

      I like to use my system python by default, so I have a pyenv-init function in my ~/.zshrc to initialize pyenv (same init command).

    • Make sure poetry uses this Python

        poetry env use python
        # Test that this worked
        poetry shell
      
  2. Install core libraries through poetry

    In pyproject.toml file, add the dependencies. For now, we’ll just install the latest versions of numpy, scipy, matplotlib, opencv-contrib-python, and PyTorch (version 1.13).

     python = "^3.8.0"
     numpy = "*"
     scipy = "*"
     matplotlib = "*"
     opencv-contrib-python = "*"
     torch = "^1.13"
     torchvision = "*"
     torchaudio = "*"
    

    Such wildcard entries are better left to the development builds. Make them concrete before releasing this to public. Run the poetry commands to install everything

     poetry install
     poetry update
    
  3. Show the installed packages as a tree

     poetry show --tree
    

Step 4: Create Documentation

Create Local Docs

  1. Create entry in the pyproject.toml file

     [tool.poetry.group.docs]
     optional = true
    
     [tool.poetry.group.docs.dependencies]
     sphinx = ">= 5.2"
    

    And install everything

     poetry install --with docs
    
  2. Create folder with basic quickstart

     cd FeatMF
     poetry shell
     sphinx-quickstart docs
    

    Put the docs/build folder in .gitignore

  3. Build the docs

     sphinx-build -b html docs/source/ docs/build/html
    

    See the preview in ./docs/build/html/index.html file

Choose a Theme

  1. Install the theme. We’ll use the rtc-theme

    In pyproject.toml add the theme (under the docs group dependencies)

     sphinx-rtd-theme = ">= 1.0"
    

    Update poetry

     poetry install --with docs
     poetry update
    
  2. Use that theme

    In ./docs/source/conf.py, add/change the following

     html_theme = 'sphinx_rtd_theme'
    

    Rebuild the site

     sphinx-build -b html docs/source/ docs/build/html
    

Deploy

Deploy on readthedocs.org

  1. Push all the latest changes to remote (GitHub)
  2. Import project and reach the dashboard.
  3. Choose the repository in the list.

Recommendations

  • For (offline) reference, you can optionally save the entire theme (source)

      cd /scratch
      wget --recursive --no-parent https://sphinx-themes.org/sample-sites/sphinx-rtd-theme/
    

References

]]>
Template: A Post with Diagrams2021-07-04T17:39:00+00:002021-07-04T17:39:00+00:00https://theprojectsguy.github.io/blog/2021/diagramsThis theme supports generating various diagrams from a text description using jekyll-diagrams plugin. Below, we generate a few examples of such diagrams using languages such as mermaid, plantuml, vega-lite, etc.

Note: different diagram-generation packages require external dependencies to be installed on your machine. Also, be mindful of that because of diagram generation the fist time you build your Jekyll website after adding new diagrams will be SLOW. For any other details, please refer to jekyll-diagrams README.

Mermaid

Install mermaid using node.js package manager npm by running the following command:

npm install -g mermaid.cli

The diagram below was generated by the following code:

{% mermaid %}
sequenceDiagram
    participant John
    participant Alice
    Alice->>John: Hello John, how are you?
    John-->>Alice: Great!
{% endmermaid %}
JohnAliceHello John, how are you?Great!JohnAlice
]]>
Template: A Post with Redirect2021-07-04T17:39:00+00:002021-07-04T17:39:00+00:00https://theprojectsguy.github.io/blog/2021/redirectTemplate: A Distill-style Blog Post2021-05-22T00:00:00+00:002021-05-22T00:00:00+00:00https://theprojectsguy.github.io/blog/2021/distillEquations

This theme supports rendering beautiful math in inline and display modes using MathJax 3 engine. You just need to surround your math expression with $$, like $$ E = mc^2 $$. If you leave it inside a paragraph, it will produce an inline expression, just like \(E = mc^2\).

To use display mode, again surround your expression with $$ and place it as a separate paragraph. Here is an example:

\[\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)\]

Note that MathJax 3 is a major re-write of MathJax that brought a significant improvement to the loading and rendering speed, which is now on par with KaTeX.


Citations

Citations are then used in the article body with the <d-cite> tag. The key attribute is a reference to the id provided in the bibliography. The key attribute can take multiple ids, separated by commas.

The citation is presented inline like this: (a number that displays more information on hover). If you have an appendix, a bibliography is automatically created and populated in it.

Distill chose a numerical inline citation style to improve readability of citation dense articles and because many of the benefits of longer citations are obviated by displaying more information on hover. However, we consider it good style to mention author last names if you discuss something at length and it fits into the flow well — the authors are human and it’s nice for them to have the community associate them with their work.


Footnotes

Just wrap the text you would like to show up in a footnote in a <d-footnote> tag. The number of the footnote will be automatically generated.This will become a hoverable footnote.


Code Blocks

Syntax highlighting is provided within <d-code> tags. An example of inline code snippets: <d-code language="html">let x = 10;</d-code>. For larger blocks of code, add a block attribute:

var x = 25; function(x) { return x * x; }

Note: <d-code> blocks do not look good in the dark mode. You can always use the default code-highlight using the highlight liquid tag:

var x = 25;
function(x) {
  return x * x;
}

Layouts

The main text column is referred to as the body. It is the assumed layout of any direct descendants of the d-article element.

.l-body

For images you want to display a little larger, try .l-page:

.l-page

All of these have an outset variant if you want to poke out from the body text a little bit. For instance:

.l-body-outset

.l-page-outset

Occasionally you’ll want to use the full browser width. For this, use .l-screen. You can also inset the element a little from the edge of the browser by using the inset variant.

.l-screen

.l-screen-inset

The final layout is for marginalia, asides, and footnotes. It does not interrupt the normal flow of .l-body sized text except on mobile screen sizes.

.l-gutter


Other Typography?

Emphasis, aka italics, with asterisks (*asterisks*) or underscores (_underscores_).

Strong emphasis, aka bold, with asterisks or underscores.

Combined emphasis with asterisks and underscores.

Strikethrough uses two tildes. Scratch this.

  1. First ordered list item
  2. Another item ⋅⋅* Unordered sub-list.
  3. Actual numbers don’t matter, just that it’s a number ⋅⋅1. Ordered sub-list
  4. And another item.

⋅⋅⋅You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we’ll use three here to also align the raw Markdown).

⋅⋅⋅To have a line break without a paragraph, you will need to use two trailing spaces.⋅⋅ ⋅⋅⋅Note that this line is separate, but within the same paragraph.⋅⋅ ⋅⋅⋅(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)

  • Unordered list can use asterisks
  • Or minuses
  • Or pluses

I’m an inline-style link

I’m an inline-style link with title

I’m a reference-style link

I’m a relative reference to a repository file

You can use numbers for reference-style link definitions

Or leave it empty and use the link text itself.

URLs and URLs in angle brackets will automatically get turned into links. http://www.example.com or http://www.example.com and sometimes example.com (but not on Github, for example).

Some text to show that the reference links can follow later.

Here’s our logo (hover to see the title text):

Inline-style: alt text

Reference-style: alt text

Inline code has back-ticks around it.

var s = "JavaScript syntax highlighting";
alert(s);
s = "Python syntax highlighting"
print s
No language indicated, so no syntax highlighting. 
But let's throw in a <b>tag</b>.

Colons can be used to align columns.

Tables Are Cool
col 3 is right-aligned $1600
col 2 is centered $12
zebra stripes are neat $1

There must be at least 3 dashes separating each header cell. The outer pipes (|) are optional, and you don’t need to make the raw Markdown line up prettily. You can also use inline Markdown.

Markdown Less Pretty
Still renders nicely
1 2 3

Blockquotes are very handy in email to emulate reply text. This line is part of the same quote.

Quote break.

This is a very long line that will still be quoted properly when it wraps. Oh boy let’s keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can put Markdown into a blockquote.

Here’s a line for us to start with.

This line is separated from the one above by two newlines, so it will be a separate paragraph.

This line is also a separate paragraph, but… This line is only separated by a single newline, so it’s a separate line in the same paragraph.

]]>
Albert Einstein
Template: A Post with Github Metadata2020-09-28T21:01:00+00:002020-09-28T21:01:00+00:00https://theprojectsguy.github.io/blog/2020/github-metadataA sample blog page that demonstrates the accessing of github meta data.

What does Github-MetaData do?

  • Propagates the site.github namespace with repository metadata
  • Setting site variables :
    • site.title
    • site.description
    • site.url
    • site.baseurl
  • Accessing the metadata - duh.
  • Generating edittable links.

Additional Reading

  • If you’re recieving incorrect/missing data, you may need to perform a Github API authentication.
  • Go through this README for more details on the topic.
  • This page highlights all the feilds you can access with github-metadata.

Example MetaData

  • Host Name :
  • URL :
  • BaseURL :
  • Archived :
  • Contributors :
]]>
Template: A Post with Twitter2020-09-28T15:12:00+00:002020-09-28T15:12:00+00:00https://theprojectsguy.github.io/blog/2020/twitterA sample blog page that demonstrates the inclusion of Tweets/Timelines/etc.

Tweet

An example of displaying a tweet:

Timeline

An example of pulling from a timeline:

Additional Details

For more details on using the plugin visit: jekyll-twitter-plugin

]]>
Template: A Post with Comments2015-10-20T15:59:00+00:002015-10-20T15:59:00+00:00https://theprojectsguy.github.io/blog/2015/commentsThis post shows how to add DISQUS comments.

]]>
Template: A Post with Math2015-10-20T15:12:00+00:002015-10-20T15:12:00+00:00https://theprojectsguy.github.io/blog/2015/mathThis theme supports rendering beautiful math in inline and display modes using MathJax 3 engine. You just need to surround your math expression with $$, like $$ E = mc^2 $$. If you leave it inside a paragraph, it will produce an inline expression, just like \(E = mc^2\).

To use display mode, again surround your expression with $$ and place it as a separate paragraph. Here is an example:

\[\sum_{k=1}^\infty |\langle x, e_k \rangle|^2 \leq \|x\|^2\]

You can also use \begin{equation}...\end{equation} instead of $$ for display mode math. MathJax will automatically number equations:

\begin{equation} \label{eq:cauchy-schwarz} \left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right) \end{equation}

and by adding \label{...} inside the equation environment, we can now refer to the equation using \eqref.

Note that MathJax 3 is a major re-write of MathJax that brought a significant improvement to the loading and rendering speed, which is now on par with KaTeX.

]]>
Template: A Post with Code2015-07-15T15:09:00+00:002015-07-15T15:09:00+00:00https://theprojectsguy.github.io/blog/2015/codeThis theme implements a built-in Jekyll feature, the use of Rouge, for syntax highlighting. It supports more than 100 languages. This example is in C++. All you have to do is wrap your code in a liquid tag:

{% highlight c++ linenos %}
code code code
{% endhighlight %}

The keyword linenos triggers display of line numbers. Produces something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
int main(int argc, char const *argv[])
{
    string myString;

    cout << "input a string: ";
    getline(cin, myString);
    int length = myString.length();

    char charArray = new char * [length];

    charArray = myString;
    for(int i = 0; i < length; ++i){
        cout << charArray[i] << " ";
    }

    return 0;
}
]]>
Template: a post with images2015-05-15T21:01:00+00:002015-05-15T21:01:00+00:00https://theprojectsguy.github.io/blog/2015/imagesThis is an example post with image galleries.

A simple, elegant caption looks good between image rows, after each row, or doesn't have to be there at all.

Images can be made zoomable. Simply add data-zoomable to <img> tags that you want to make zoomable.

The rest of the images in this post are all zoomable, arranged into different mini-galleries.

]]>