I like benawad’s [1] project destiny [2].
Prettier for File Structures
References:
[1]: https://github.com/benawad
[2]: https://github.com/benawad/destiny
Publishing rhythm
2020 waylonwalker.com rebrand
Moving into 2020 I have been really leaning on using purple as my theme color
everywhere more and more. Its time for an update to my personal site, not
just because it feels plain, not just because the cover art I am using for
dev.to doesn’t fit my current card layout, but because I feel inspired and
I want to.
Starting point # [1]
[2]
This is what we are working with. It has been my card design for at least a
year now. Its not bad but, its a bit play, doesnt fit my new cover art style,
and that date is not working over top of the cover art text.
- plain
- cover art does not fit
- I am not digging the date on cover art that also has text
Colors # [3]
I have been really into using a deep purple lately. It is a neutral color that
does not get enough respect, i.e. it’s not used as frequently and kinda stands
out when used.
How I pick colors # [4]
I am really bad at picking colors that go well together so for this I punt to
utilizing others who have a better eye for this. I c...
I just added react-headroom to my site
It was so easy to get a professional looking navbar with just 3 lines of code.
This package seriously is so usable on mobile it is ridiculous. I found this
package from
day-4 [1]
of the 100 days of gatsby challenge. It is by the wonderful man who brought us
gatsbyjs Kyle Mathews, so you know its gotta be good.
install react-headroom # [2]
installation is easy
npm i react-headroom
Import Headroom # [3]
There was no instructions for es6 style imports that are common with gatsbyjs
sites like mine, but it was intuitive to figure out.
import Headroom from 'react-headroom'
Using Headroom # [4]
Simply wrap your existing content, Nav in my case, with the <Headroom />
component and your off to the races. The content will pop back into view when
you scroll past then back up.
<Headroom>
<-- Your content goes here -->
</Headroom>
See it in action # [5]
I think this simple package completely changes the ux of your site on mobile.
You can get that sticky nav out of the way, but its still...
I finally fixed my Styled-Components in gatsby.js
I finally fixed my Styled-Components in gatsby.js. I am starting a redesign of
my website. I have started cross posting to dev.to [1] more
regularly. With that I have been making more detailed cover images at the
recommended 1000x420. These images get cut off on my own site, which is a
bit ridiculous to have my own content not look right on my own site. But
before we start a heavy redesign I have a small issue that has plagued the site
for at least a year!
I have a small issue that has plagued the site for at least a year!
I have been using styled components in my gatsby.js site for about a year now. And it has been plagued by styled-components not being in the ssr causing some jank in the styles being loaded. You can see it in the lighthouse performance report below. It generally loads super quick, and is only caused on first load. Anything using the gatsby <Link/> component typically is fine and unaffected by the issue.
The fix # [2]
The fix was so simple it was only 2 lines t...
Check out kedro-org [1] and their project kedro-community [2].
Examples of data science projects created with Kedro.
References:
[1]: https://github.com/kedro-org
[2]: https://github.com/kedro-org/kedro-community
I’m impressed by kedro-viz [1] from kedro-org [2].
Visualise your Kedro data and machine-learning pipelines and track your experiments.
References:
[1]: https://github.com/kedro-org/kedro-viz
[2]: https://github.com/kedro-org
Should I switch to Zeit Now
Netlify # [1]
I have happily had my personal site waylonwalker.com [2] hosted on netlify for nearly 2 years now. In fact I have hosted about a dozen different toy projects to play with on there, 4 of which have gone far enough to get a custom domain name. They are fast to deploy and consistently do so on every git push to main.
Zeit # [3]
I have recently started playing with zeit again. I really like their cli tool, its dead simple and makes sense. I tried the netlify one early on and dont think I really gave it much of a chance. I was able to backup a site we were modifying by saving everything locally (literally control+s) and running now in the command line.
While I was on the site I realized that when switching to gatsby v2 I had deployed it to now.sh while testing, before cutting over to the updated one on netlify. It has been building every version since without issue!
It has been building every version since without issue!
What I am using # [4]
- gatsby
- forestry.io
...
git push without setting upstream
Finally after years of hand typing out a full git push --upstream my_really_long_and_descriptive_branch_name I found there is a setting to
automatcally push to the current branch. More realisitically I just did a git push let git [1] yell at me, and copying the suggestion.
git config # [2]
git config --global push.default current
This one setting will now git push to the current branch without yelling at
you that your upstream does not match your current branch. This helps me ship
chnages faster as I am constantly chnaging projects and branches.
References:
[1]: /glossary/git/
[2]: #git-config
Out of Space
This morning I logged into my machine and was nearly out of space
- 64GB miniconda3!
- 5GB conda cache
- 4GM pip cache
- 34GB docker
Find it # [1]
[2]
These are the commands that I often use to reclaim space. Its so easy to fill
up small vm’s in the cloud, or in my case today let your dev machine go way too
long without a good cleanup.
Show Remaining Space on Drives # [3]
This shows us where to start and gives a baseline of how much space we have
reclaimed.
df -h
show largest files in current directory # [4]
Next keep drilling into directories that are big and running this command to
see whats big inside of it. When you find somethign that you are willing to
part with rm -rf <directory> it and check df -h to see if you have enough
reclaimed yet.
du . -h --max-depth=1
Honestly I rarely bother unless the directory is in the GB’s of space. A super
simple filter for that is to just grep for G.
du . -h --max-depth=1 | grep G
conda # [5]
How Many? # [6]
As a first baseline...
simple click
cli tools are super handy and easy to add to your python libraries to supercharge them. Even if your library is not a cli tool there are a number of things that a cli can do to your library.
Example Ideas # [1]
Things a cli can do to enhance your library.
🆚 print version
🕶 print readme
📝 print changelog
📃 print config
✏ change config
👩🎓 run a tutorial
🏗 scaffold a project with cookiecutter
🖱 Click [2] # [3]
Click [2] is the most popular python cli tool framework for python. There are others, some old, some new comers that make take the crown. For now Click [2] is the gold standard if you want to make a powerful cli quickly. If you are dependency conscious and dont need a lot of tooling, use argparse [4].
Project Structure # [5]
.
├── setup.py
└── simple_click
├── cli.py
└── __init__.py
❯ cli.py # [6]
# simple_click/cli.py
import click
__version__ = "1.0.0"
@click.group()
def cli():
pass
@cli.command()
def version():
"""prints project version"""
click.echo(__...
Personal URL shortener with Netlify Redirects
I love using URL shorteners to easily share links without hitting character
limits, but they loose their meaning. Services like bit.ly will save my links
for me so that I can find them, but I would rather them to be easy to remember.
https://bit.ly/2ruLwQz does
not roll of the tongue so well.
301 🤸♀️ # [1]
I recently discovered a really cool feature of netlify that I have always looked past, _redirects. It is so simple cool and powerful, every netlify site should do this!
But how 🤷♀️ # [2]
simply add a _redirects file to the root of your your published site with the following format. The trick I found with my gatsby site was that it needed to be in my static directory /static/_redirects, not root. Next you just put space separated links on separate lines. #’s can be used for comments.
# netlify redirects
# from_url to_url
# Short-Blog
/blog/scli /blog/simple-click/
/blog/cmdt /blog/cmd-exe-tips/
.
.
.
# splats
/b* /blog/:splat
/n* /notes/:splat
# External
/twitter https...
szsdk [1] has done a fantastic job with quick [2]. Highly recommend taking a look.
A real QUICK Qt5 based gUI generator for ClicK
References:
[1]: https://github.com/szsdk
[2]: https://github.com/szsdk/quick
cmd.exe tips
I spend a lot of my time at the terminal for my daily work, mostly in Linux or wsl. One big reason for using wsl over cmd.exe is the ease of walking through history that fzf provides. This week we had a windows bug in a cli and I was stuck in vanilla cmd.exe 😭
> Cmder # [1]
[2]
First off if you are stuck using cmd.exe, do yourself a favor and get cmder. It makes life just a bit easier. It is super confugurable and comes with several power ups that make it a bit more enjoyable than cmd.exe.
History # [3]
F7 - Scroll through history
F8 - Search history based
Example # [4]
image [5]
.bat # [6]
The next simple technique is to save your commands into a .bat file. Any valid command ran with cmd.exe can be saved into a bat file and called again later by running it in the terminal.
save your command
use f7/f8 to get your command back add > filename.bat at the end, hit the home key and add echo to the front. Do not wrap with quotes. This is not bash.
echo python cmd_example.py ...
If you’re into interesting projects, don’t miss out on forgit [1], created by wfxr [2].
💤 A utility tool powered by fzf for using git [3] interactively.
References:
[1]: https://github.com/wfxr/forgit
[2]: https://github.com/wfxr
[3]: /glossary/git/
I’m really excited about python-c2f [1], an amazing project by grantjenks [2]. It’s worth exploring!
Cython for All with GitHub Actions
References:
[1]: https://github.com/grantjenks/python-c2f
[2]: https://github.com/grantjenks
Check out wesbos [1] and their project beginner-javascript [2].
Slam Dunk JavaScript
References:
[1]: https://github.com/wesbos
[2]: https://github.com/wesbos/beginner-javascript
If you’re into interesting projects, don’t miss out on awesome-react-components [1], created by brillout [2].
Curated List of React Components & Libraries.
References:
[1]: https://github.com/brillout/awesome-react-components
[2]: https://github.com/brillout
What is something you should have learned or understood earlier?
Mine is the python debugger. I was a long holdout thinking that print statements were sufficient. That was untill I started having errors crop up in functions that took minutes to run. The thing that I most notably wish I would have known about is post_mortem.
Example # [1]
[ins] In [4]: def repeater(msg, repeats=1):
...: "repeats messages {repeats} number of times"
...: print(f'{msg}\n' * repeats)
[ins] In [5]: repeater('hi', 3)
hi
hi
hi
[ins] In [6]: repeater('hi', 'a')
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-6-0ec595774c81> in <module>
----> 1 repeater('hi', 'a')
<ipython-input-4-530890de75cd> in repeater(msg, repeats)
1 def repeater(msg, repeats=1):
2 "repeats messages {repeats} number of times"
----> 3 print(f'{msg}\n' * repeats)
4
Debug with iPython/Jupyter
%debug
Vanilla Debug # [2]
import pdb
import sys
pdb.post_mortem(sys.last_traceback)
More # [3]
For more inform...
Supercharge Zsh Startup
I have been using oh-my-zsh successfully for about 2 years now. But lately my
startup time has been really bothersome. It has grown to the point where it was
taking about 5.5s to startup a shell! This is ok if I am going to spend
some time in here for awhile and do some work that benefits from all of the
autocompletions, plugins, and shortcuts that oh-my-zsh brings. But to only
jump in to run a handful of commands is infuriating.
📑 My Setup # [1]
I believe the real issue is io speed on wsl. I have some remote servers with
similar configs that are 10x faster or more, loading in 100s of milliseconds
rather than seconds. Sourcing all of the individual plugin files are just too
much for it.
💨 How Fast can it be # [2]
Quick side note: your zsh config is controled by your ~/.zshrc file. This
file can source other files, load plugins, or run literally anything.
Time the initial time
time zsh -c exit
Move your ~/.zshrc config file.
mv ~/.zshrc ~/.zshrc-back
Time the fastest startup p...
Keep Location List Closed
Vim’s (neovim in my case) location list can provide some very useful information while developing. Mine gives me information about linting and type checking errors with fairly little config. Generally, it sits nicely at the bottom of the screen and barely affects me. Other times, especially while zoomed way in during a presentation, it just gets in the way.
[1]
location list eats the screen
Location List eating up the screen while I am zoomed in and trying to live code
Toggling the location list # [2]
Through some google search I found the culprit was syntastic. It has an auto_loc_list feature. We can turn it off by setting
syntastic_auto_loc_list=0.
let syntastic_auto_loc_list=0
Keybindings # [3]
I want to keep the location list open automatically most of the time, but when I don’t want it to keep opening it’s generally detrimental. Trying to live code while the location list keeps taking up the whole screen is not cool.
First, create a function that will toggle both the lo...
I came across jumpcutter [1] from carykh [2], and it’s packed with great features and ideas.
Automatically edits vidx. Explanation here: https://www.youtube.com/watch?v=DQ8orIurGxw
References:
[1]: https://github.com/carykh/jumpcutter
[2]: https://github.com/carykh
Check out great-expectations [1] and their project great_expectations [2].
Always know what to expect from your data.
References:
[1]: https://github.com/great-expectations
[2]: https://github.com/great-expectations/great_expectations
I’m impressed by flowy [1] from alyssaxuu [2].
The minimal javascript library to create flowcharts ✨
References:
[1]: https://github.com/alyssaxuu/flowy
[2]: https://github.com/alyssaxuu
I came across blocks [1] from blocks [2], and it’s packed with great features and ideas.
A JSX-based page builder for creating beautiful websites without writing code
References:
[1]: https://github.com/blocks/blocks
[2]: https://github.com/blocks
I like asmeurer’s [1] project removestar [2].
Tool to automatically replace ‘import *’ in Python files with explicit imports
References:
[1]: https://github.com/asmeurer
[2]: https://github.com/asmeurer/removestar
Check out lolcommits [1] and their project lolcommits [2].
📷 git [3]-based selfies for software developers
References:
[1]: https://github.com/lolcommits
[2]: https://github.com/lolcommits/lolcommits
[3]: /glossary/git/
I’m really excited about mask [1], an amazing project by jacobdeichert [2]. It’s worth exploring!
🎭 A CLI task runner defined by a simple markdown file
References:
[1]: https://github.com/jacobdeichert/mask
[2]: https://github.com/jacobdeichert
Check out pyjanitor-devs [1] and their project pandas_flavor [2].
The easy way to write your own flavor of Pandas
References:
[1]: https://github.com/pyjanitor-devs
[2]: https://github.com/pyjanitor-devs/pandas_flavor
I like tj’s [1] project go-termd [2].
Package termd provides terminal markdown rendering, with code block syntax highlighting support.
References:
[1]: https://github.com/tj
[2]: https://github.com/tj/go-termd
I recently discovered git-history [1] by pomber [2], and it’s truly impressive.
Quickly browse the history of a file from any git [3] repository
References:
[1]: https://github.com/pomber/git-history
[2]: https://github.com/pomber
[3]: /glossary/git/
Check out csurfer [1] and their project pypette [2].
Ridiculously simple flow controller for building complex pipelines
References:
[1]: https://github.com/csurfer
[2]: https://github.com/csurfer/pypette
Check out requests [1] by psf [2]. It’s a well-crafted project with great potential.
A simple, yet elegant, HTTP library.
References:
[1]: https://github.com/psf/requests
[2]: https://github.com/psf
Check out vscode-git-semantic-commit [1] by nitayneeman [2]. It’s a well-crafted project with great potential.
💬 A Visual Studio Code extension which enables to commit simply by the semantic message conventions
References:
[1]: https://github.com/nitayneeman/vscode-git-semantic-commit
[2]: https://github.com/nitayneeman
awesome-streamlit [1] by MarcSkovMadsen [2] is a game-changer in its space. Excited to see how it evolves.
The purpose of this project is to share knowledge on how awesome Streamlit is and can be
References:
[1]: https://github.com/MarcSkovMadsen/awesome-streamlit
[2]: https://github.com/MarcSkovMadsen
I’m impressed by js13k-2019 [1] from bencoder [2].
xx142-b2.exe. An entry for js13kgames 2019
References:
[1]: https://github.com/bencoder/js13k-2019
[2]: https://github.com/bencoder
Just starred death-to-ie11 [1] by gabLaroche [2]. It’s an exciting project with a lot to offer.
Countdown for IE11 end of support
References:
[1]: https://github.com/gabLaroche/death-to-ie11
[2]: https://github.com/gabLaroche
I came across awesome-data-engineering [1] from igorbarinov [2], and it’s packed with great features and ideas.
A curated list of data engineering tools for software developers
References:
[1]: https://github.com/igorbarinov/awesome-data-engineering
[2]: https://github.com/igorbarinov
I’m really excited about vscode-python [1], an amazing project by microsoft [2]. It’s worth exploring!
Python extension for Visual Studio Code
References:
[1]: https://github.com/microsoft/vscode-python
[2]: https://github.com/microsoft
If you’re into interesting projects, don’t miss out on Recreation-of-Nature [1], created by Kashu7100 [2].
ALife simulation with Python: patterns, behavior, and cognition.
References:
[1]: https://github.com/Kashu7100/Recreation-of-Nature
[2]: https://github.com/Kashu7100
Quick Progress Bars in python using TQDM
tqdm is one of my favorite general purpose utility libraries in python. It
allows me to see progress of multipart processes as they happen. I really like
this for when I am developing something that takes some amount of time and I am
unsure of performance. It allows me to be patient when the process is going
well and will finish in sufficient time, and allows me to 💥 kill it and find a
way to make it perform better if it will not finish in sufficient time.
[1]
for more gifs like these follow me on twitter
@waylonwalker [2]
Add a simple Progress bar!
from tqdm import tqdm
from time import sleep
for i in tqdm(range(10)):
sleep(1)
convenience
TQDM also has a convenience function called trange that wraps the range function with a tqdm progress bar automatically.
from tqdm import trange
from time import sleep
for i in trange(range(10)):
sleep(1)
notebook support
There is also notebook support. If you are bouncing between ipython and jupyter I recomend importing from the auto ...
I’m impressed by bake [1] from kennethreitz [2].
Bake — the strangely familiar workflow utility.
References:
[1]: https://github.com/kennethreitz/bake
[2]: https://github.com/kennethreitz
Check out terminal [1] by microsoft [2]. It’s a well-crafted project with great potential.
The new Windows Terminal and the original Windows console host, all in the same place!
References:
[1]: https://github.com/microsoft/terminal
[2]: https://github.com/microsoft
Clean up Your Data Science with Named Tuples
If you are a regular listener of TalkPython [1] or PythonBytes you have hear Michael Kennedy talk about Named Tuples many times, but what are they and how do they fit into my data science workflow.
Example # [2]
As you graduate your scripts into modules and libraries you might start to notice that you need to pass a lot of data around to all of the functions that you have created. For example if you are running some analysis utilizing sales, inventory, and pricing data. You may need to calculate total revenue, inventory on hand. You may need to pass these data sets into various models to drive production or pricing based on predicted volumes.
Load data # [3]
Here we setup functions that can load data from the sales database. Assume that we also have similar functions to get_inventory and get_pricing.
def get_engine():
engine = create_engine('postgresql://scott:tiger@localhost:5432/mydatabase')
def get_sales():
'''
gets sales history from the sales database
'''
engine = ge...
Background Tasks in Python for Data Science
This post is intended as an extension/update from background tasks in
python [1]. I started using background
the week that Kenneth Reitz released it. It takes away so much boilerplate
from running background tasks that I use it in more places than I probably
should. After taking a look at that post today, I wanted to put a better data
science example in here to help folks get started.
This post is intended as an extension/update from background tasks in python [1]. I started using background the week that Kenneth Reitz released it. It takes away so much boilerplate from running background tasks that I use it in more places than I probably should. After taking a look at that post today, I wanted to put a better data science example in here to help folks get started.
I use it in more places than I probably should
Before we get into it, I want to make a shout out to Kenneth Reitz for making this so easy. Kenneth is a python God for all that he has given to the community in so many w...
If you’re into interesting projects, don’t miss out on starship [1], created by starship [2].
☄🌌️ The minimal, blazing-fast, and infinitely customizable prompt for any shell!
References:
[1]: https://github.com/starship/starship
[2]: https://github.com/starship
alttch [1] has done a fantastic job with rapidtables [2]. Highly recommend taking a look.
Super fast list of dicts to pre-formatted tables conversion library for Python 2/3
References:
[1]: https://github.com/alttch
[2]: https://github.com/alttch/rapidtables
Autoreload in Ipython
I have used %autoreload for several years now with great success and 🔥 rapid reloads. It allows me to move super fast when developing libraries and modules. They have made some great updates this year that allows class modules to be automatically be updated.
What I like about autoreload # [1]
🔥 Blazing Fast
💥 Keeps me in the comfort of my text editor
👏 Allows me to use Jupyter when I need
👟 Extremely Reliable
One of the biggest benefits that I find is that it shortens the distance between my module/library code and test code inside of a terminal/notebook. Now I primarily use jupyter notebooks for the presentation aspect. I develop code from the comfort of my editor with all of the tools I have setup, and run the functions in a notebook to get the output. From there I might do some aggregations or plots, but the 🥩 meat of development is done outside of jupyter.
Now I primarily use jupyter notebooks for the presentation aspect.
Enabling Autoreload # [2]
📐 config
This is a sh...
If you’re into interesting projects, don’t miss out on psutil [1], created by giampaolo [2].
Cross-platform lib for process and system monitoring in Python
References:
[1]: https://github.com/giampaolo/psutil
[2]: https://github.com/giampaolo
If you’re into interesting projects, don’t miss out on promote-open-source-project [1], created by zenika-open-source [2].
📄 How to promote my open source project?
References:
[1]: https://github.com/zenika-open-source/promote-open-source-project
[2]: https://github.com/zenika-open-source
Check out watchtower [1] by kislyuk [2]. It’s a well-crafted project with great potential.
Python CloudWatch Logging: Log Analytics and Application Intelligence
References:
[1]: https://github.com/kislyuk/watchtower
[2]: https://github.com/kislyuk