#! Ramblings
of an autodidact...
#! Ramblings
Playing around with adding plugins to Pelican

Wanted to add some extra styling to my blog posts

Some parts of my blog were looking pretty blah

Math syntax

I've been tweaking my blog like crazy. Just making minor changes here and there. I wanted to make things look a little better.

For instance, for my rescaling article, I had the following mathematical syntax:

ScaledQuantity = (ActualQuantity-MinQuantity)/(MaxQuantity-MinQuantity)

What the hell is that? That looks horrible! I know that markdown supports Latex, so I looked and found this awesome resource: Writing Mathematic Formulars in Markdown

ScaledQuantity = \frac{ActualQuantity-MinQuantity}{MaxQuantity-MinQuantity}

Um, not quite there yet. Something was up. I searched to see if Pelican had any plugins for rendering math and sure enough, found that pelican-plugins included render_math. I followed the instructions and cloned the repo into my blog directory. Probably should have dropped it somewhere outside of it, but I added it to my .gitignore and it's fine...

I added the following to my pelicanconf.py file:

PLUGIN_PATHS = ['./pelican-plugins']
PLUGINS = ['render_math']

I tried the previous code once again and was still getting the same results. After some more reading I found that you have to enclose the mathematical equation within double $.

$$ScaledQuantity = \frac{ActualQuantity-MinQuantity}{MaxQuantity-MinQuantity}$$

NICE!

Markdown tables

My original tables were so bland that it was almost hard to tell that they were even tables! Unfortunately I didn't save a screenshot of it, so I can't show you what they looked like, but I can definitely show you the end result! Thanks to mockaroo I was able to generate some mock data relatively quickly.

id first_name last_name email gender ip_address
1 Odilia O'Meara oomeara0@yahoo.co.jp Female 244.53.86.185
2 Marcelo Tunna mtunna1@netvibes.com Male 128.140.17.56
3 Farris Roston froston2@ucla.edu Male 111.104.78.209
4 Gene Benzies gbenzies3@nymag.com Male 67.169.248.21
5 Ellsworth Goodered egoodered4@hud.gov Male 227.48.46.133
6 Jan Garnsworth jgarnsworth5@amazon.de Male 138.13.211.142
7 Robby Rosenstengel rrosenstengel6@chron.com Female 105.76.137.198
8 Granthem Rymer grymer7@yolasite.com Male 15.60.66.25
9 Claire Stuther cstuther8@salon.com Female 5.36.242.109
10 Maggy Jearum mjearum9@npr.org Female 179.12.188.75

CSS changes

I hope it doesn't bite me in the butt later on, but I'm forcing the table headers into uppercase. In case anyone is curious, this are the styles that I added to the theme:

table {
  border-collapse: collapse;
  margin-left: auto;
  margin-right: auto;
  width: 90%;
}

td, th {
  border: 1px solid #ddd;
  padding: 8px;
}

tr:nth-child(even){background-color: #f2f2f2;}

tr:hover {background-color: #ddd;}

th {
  padding-top: 12px;
  padding-bottom: 12px;
  text-transform: uppercase;
  font-weight: bold;
  background-color: #607D8B;
  color: white;
}

.math {
  font-size: medium;
}

The default math syntax rendering was kind of small, so I changed the font-size to medium.

On a side note

I noticed that some of my changes wouldn't take effect until after I removed the pycache and .pytest_cache directories. In order to automate this, I modified my Makefile's clean code to the following:

clean:
    [ ! -d $(OUTPUTDIR) ] || rm -rf $(OUTPUTDIR)
    rm -rf __pycache__
    rm -rf .pytest_cache

Conclusion

This web development stuff is pretty complex. There are lots of moving parts, so I give all of my fellow web developers a high-five for being so awesome! I can see how this can be pretty overwhelming if you're new to this, but just keep at it and you'll get there.

This old dog can still learn some new tricks!


Finally getting the hang of working with Pelican!

Nothing beats learning something new than just jumping in and playing around with it!

Stumbling into a nice Pelican workflow If you've seen my source repo for this site, you know that I followed Erik O'Shaughnessy's Run your blog on GitHub Pages with Python tutorial. It's a great tutorial, I specifically love his one weird trick, but it leaves so many unanswered questions. Go read it now if you haven't and we'll pick up where he leaves off. Luckily he does provide the link to the official documentation. It was...

Read More


Pytest fixtures with tear down

Figured out how to tear down a pytest fixture

Setting up pytest fixtures with teardown code Today after listening to Brian Okken's Test & Code podcast with Anthony Shaw, I was reminded that I wanted to install Anthony's Python Security Plugin for JetBrain's PyCharm IDE. That was a breeze to install and it just worked out of the box. I fired it up and it automatically checked my code and called it good. I then started to write some tests and while checking...

Read More


Into the cryptography rabbit hole

Learning about how to encrypt files

Venture Into Cryptography with PyCryptodome Learning about how to encrypt files As dumb as it is, I have an unsecured text file that I use to keep track of all my username and passwords for all of the sites that I frequent. In order to not be so "hackable", I've decided to encrypt the file. I had recently written a couple of coding challenges for Pybites Code Challenges site, using the cryptography module. One was a coding...

Read More


Rescaling values for DataScience

Quick discussion about rescaling values for data science

Scaling values Today while reading Data Science Algorithms in a Week, from packt, I came across the concept of rescaling values so that when measuring their distances they would be more relevant. The dataset consisted of "House Ownership": Age Annual income in USD House ownership status 23 50,000 Non-owner 37 34,000 Non-owner 20 100,000 Owner 35 130,000 Owner etc.. The aim being to predict whether a person that is 50 years old with an income of $80,000, would...

Read More


This is my first post here

Initial Post for my Ramblings of an autodidact Blog

Getting my feet wet with this blogging stuff It's not much to look at, but my goal is to show what I'm learning as I go. There's no real "topic" but it will mostly be about what I'm working on and what I have to learn to get it done. Hope that it's of interest to someone......

Read More


  • 1
  • 2

Receive Updates

ATOM