When assessing your environment, problem or your goal, meticulously scout the tools at your disposal. When you're learning a new job, a new project or a programming language's tools for example, it pays to have a grasp of your options. Researching what documentation, guides, tools or libraries are at your disposal will help you accomplish your goal. That sounds obvious but here's what I mean.
Seek out resources. Bookmark links and support info in an Excel spreadsheet with a handful of columns, for example.
Soon, you'll amass a collection tools and guides to get things done. Most companies or products have "resource centers",
mountains of internal documentation, tools and blogs. At many organizations, people have likely made tools for something
they needed in the past then moved on. Often these tools can be leveraged for anyone who cares enough to seek out,
read about and learn how to use them. Dig for these tools too. Find resources by googling products you use.
Subscribe to their status pages. Look for other tools that may help you in a pinch
like GoToWebinar's system check to help someone figure out what's wrong
with their browser. I love these types of browser-based troubleshooting software. These are ways to gain a better understanding of technologies
that might affect or improve your productivity or day to day goals.
I think of "resource scoping" as crawling these types of resources for every tool, guide and support contact that might good to know. The effort you put in to scope available resources is worth the time spent. Check out the "resource scoping"
I did in this post I wrote focused on tools for writers!
This morning I'm meditating on my usual apps or websites I visit through the course of a typical day. I wonder how limited or expansive it could be in the span of all that's waiting to be consumed on the internet. I like reading online or physical books too and writing. Consider your own circle of the internet. What sites do you frequent? What do you consume? This is more rhetorical. It's good to pose the question and consider what you might be missing. I recently downloaded a bunch of nature and hiking apps. Maybe that means I want more of that in my life. Happy trails.
In September 2021, I tested out the recommended ads runner, WordAds, on this WordPress blog. 6,182 ads were served over the course of a month, earning $0.86 from impressions and clicks. My average CPM or cost per thousand impressions was $0.14. My blog averages about 1,600 views a month at the moment, mostly fueled by various search engines. Here's an example of one ad that ran:
Example Ad Run on This Site Shown Above
In my WordPress account, I upgraded to the business plan. This gave me access to WordPress plug-ins. I enabled the Yoast SEO plug-in and activated its site optimization. I also enabled the maximum ads possible in my settings. In spite of these efforts, the results were sparse. Maybe there's more that I could have done. But this blog is passive and more like a hobby at the moment. I'm ok with a blog that makes $0.86 per month. Maybe someday it will be worth more. But I enjoy writing so it's all good. My skills grow and maybe I share something with someone across the world. That's what keeps me coming back.
I concluded I will not be running ads anytime soon. I wanted to get a baseline of what I was leaving on the table by not running ads. Now I can project when I might tap into the blog's potential traffic revenue, if ever. It seems I would need much higher views per month before ads makes sense with my level of traffic, 65 blog followers and minor social media clout.
There's also the added benefit of not serving up people's data to ad companies. Ads seem to be a generally accepted way to earn from your internet labors. But right now, they're not for this blog. Good luck monetizing your blog. Or just writing for the hell of it!
Black is a code formatting tool that I have been testing out recently to see what the hype is about. It is the defacto "uncompromising code formatter in Python". I normally do not use any code formatters since I'm not required to use them. This short post aims to convince you that Black is an insightful way to see the parts of your code that are dangerously unreadable.
I have found it interesting to see what black does with my gnarliest code. It has taught me what is considered "good formatting" by some Pythonistas. The areas where I see the most improvement is how it enforces PEP-8's characters per line limit. Often before, I didn't know how to break my code into several lines. My scripts tended to have one-liners trailing off the edge of my text editor. Black teaches you new ways to organize your code and makes it easier to understand. Now I write my code like Black the first time instead of letting it trail off the screen.
Initially I was hesitant to try Black because I didn't want to sabotage my own code style. But since running Black on a few of my scripts, it has taught me new ways to write code. Give Black a chance and you will learn how to write more readable Python.
Write code everyday. Code fast and break things. Cherish your tracebacks. Keep going back, no matter how hopeless it may seem. Code habitually. Learn how to code. Get better at code. Love code.
Write Less Code
Use as few lines as possible. Nothing looks better than a program shorter than 50 or 100 lines! Avoid aggressively gnarly one-liners. Use sensible one-liners or [gasp] for loops. Read other people's code.
Lately I've been checking out the Yoast SEO plug-in and their REST API. The API returns all of the SEO metadata, meta tags, schema.org data, etc. for your Wordpress blog posts. Here's a Yoast API Python example script to fetch post metadata via requests and pandas:
1 2 3 4 5 6 7 8 9101112131415161718192021222324
importpandasaspdimportrequestsdeffetch_metadata(post_url):"""Returns the Yoast API response as pandas dataframe."""url=f'https://atomic-temporary-107329037.wpcomstaging.com/wp-json/yoast/v1/get_head?url={post_url}'r=requests.get(url)print(r.text)print(r.status_code)response_dict=r.json()metadata_df=pd.json_normalize(response_dict['json'])returnmetadata_dfurls=["https://example.com/post1","https://example.org/post2","https://example.net/post3"]posts=pd.DataFrame(urls,columns=['URLs'])# Update url domain with pandas .str accessor.posts.url=posts.url.str.replace(pat='.wordpress',repl='',regex=False)posts['metadata']=posts.url.apply(fetch_metadata)metadata_df=pd.concat(list(posts['results']))metadata_df.to_csv('Wordpress Blog Post Yoast API Metadata.csv',index=False)
What this script is doing:
Read a list of my blog posts from Github into a pandas dataframe.
Use pandas .apply to fetch the metadata for each post url.
Deserialize + normalize the JSON response.
Convert to a pandas dataframe and store in a pandas Series named 'metadata'.
Merge the series and write the metadata to a csv file.
The Payoff:
You'll end up with blobs of JSON formatted metadata to sift through or wrangle to your liking! Check out the Yoast documentation if you're interested in finding out more about their APIs.
webbrowser is a convenient Python standard library module. It opened my
Firefox browser on my Ubuntu Linux operating system running on a
Chromebook. This code is adapted from a Python Examples blog post.
Below is a list of other browsers you can open with webbrowser. At the
bottom of this post, you'll find more tools to interact with browsers
and GUIs programmatically.
A static site generator creates static HTML and markdown files to serve as a website. They're commonly used to host blogs but not exclusively.
I recently researched my options to roll a static site in Python. I'm assessing them as a potential future self-hosted blogging solution
for this blog.
Why Statics?
Most "modern" websites are dynamic in the sense that the contents of the site live in a database, and are converted into presentation-ready HTML only when a user wants to see the page. That's great. However, it presents some minor issues that static site generators try to solve.
In a static site, the whole site, every page, everything, is created before the first user even sees it and uploaded to the server as a simple folder full of HTML files (and images, CSS, etc).
Seems to be the front running static site generator in Python's ecosystem. It contains a convenient pelican-importer tool to import existing content from WordPress, Dotclear, or RSS feeds. Enjoying the modular nature of the pelican-plugins and pelican-themes!
"Simple but powerful static website generator using Python and the Django template system... typical users would be designers that are tech-savvy, want to use templates, but don't like to mess with setting up django or S3." (Mac OS) Demo Video
I initially installed my Python version from the Windows Store and it worked fine for almost a year on my Windows 10 computer. Then I started getting this error message when trying to use the requests library on all HTTP requests:
1
requests.exceptions.SSLError:HTTPSConnectionPool(host='api.example.com',port=443):Maxretriesexceededwithurl:/oauth/token?grant_type=client_credentials(CausedbySSLError(SSLCertVerificationError(1,'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1131)')))
Apparently my Python certificates were not valid or up to date on my computer. These are ".PEM" or ".cert" files that certify your connection for the SSL protocol. I googled this error until I found the python-certifi-win32 library. I only needed to pip install this library and it fixed the problem:
pip install python-certifi-win32
Huge thank you to the maintainer of this package. It solved my issues and now I can make HTTP requests again!
Today I scoured the internet for tools written in Python that assist writing in any form. After some relentless Google and Github searching, here are my favorites. I found tools to help write modular stories and novels, screenwriting with Trelby and several libraries for academic papers. I haven't tried all of these... yet!
Miscellaneous Writing, Text Cleaning and Proofreading Resources
Language Tool API: Open Source proofreading software for English, French, German, Polish, Russian, and more than 20 other languages. It finds many errors that a simple spell checker cannot detect. See also: language_tool_python library (Github)
Sumy: Module for automatic summarization of text documents and HTML pages.
Mackerel: Mackerel provides an automated, easy to use alternative for company or school writing tasks. Simply provide the topic and/or files and we will do the rest.
Verb Miner: This tool can help you analyze a document and discover cool verbs from pdf papers.
paper-translater: Chinese and English essay translator, paper translator, clipboard listener
PyLaTeX: A Python library for creating LaTeX files
Begin LaTeX in minutes: Brief Intro to LaTeX for beginners that helps you use LaTeX with ease.
Texbib: A program that helps you to manage your BibTeX references.
BibLatex-Check: A python script for checking BibLatex .bib files for common referencing mistakes!
paperpy: Tools for simplifying the preparation of version-controlled and well-written academic papers.
Academic Writing Check: Check for passive words, weasel words, duplicate words, typographical errors and words strunk & white don't like. (Written in Perl.)
In Math, Computer Science, Physics, or any field where your typical paper has even a modest amount of mathematical notation the percentage of papers written using LaTeX (or even plain TeX!) is probably about 90%+.
BibTeX is reference management software for formatting lists of references. The BibTeX tool is typically used together with the LaTeX document preparation system.