I came across python_training [1] from AnkurDedania [2], and it’s packed with great features and ideas.
Intro to Python
References:
[1]: https://github.com/AnkurDedania/python_training
[2]: https://github.com/AnkurDedania
Publishing rhythm
github [1] has done a fantastic job with renaming [2]. Highly recommend taking a look.
Guidance for changing the default branch name for GitHub repositories
References:
[1]: https://github.com/github
[2]: https://github.com/github/renaming
Reclaim memory usage in Jupyter
Today I ran into an issue where we had a one-off script that just needed to
work, but it was just chewing threw memory like nothing.
It started with a colleague asking me How do I clear the memory in a Jupyter
notebook, these are the steps we took to debug the issue and free up some
memory in their notebook.
How do I clear the memory in a Jupyter notebook?
Pre check the status of memory # [1]
There are a number of ways that you can check the amount of memory on your
system. The easiest is not necessarily my first go to is free… literally
free.
check for free space
$ free -h
total used free shared buffers cached
Mem: 15G 15G 150M 0B 59M 8.7G
Generally my first go to is a bit more graphical, and not available on a stock
stystem, but far more useful…. htop. htop [2] is a
terminal process explorer that shows cpu usage, mem usage, and running
processes.
htop
sudo apt-get install htop # install it from your package repo
htop
[3]
First step throw more swap at it # [4]
Often be...
Strip Trailing Whitespace from Git projects
A common linting error thrown by various linters is for trailing whitespace. I
most often use flake8. I generally have
[pre-commit](https://waylonwalker.com/pre-commit-is-awesome
hooks setup to strip this,
but sometimes I run into situations where I jump into a project without it, and
my editor lights up with errors. A simple fix is to run this one-liner.
One-Liner to strip whitespace # [1]
bash
git grep -I --name-only -z -e '' | xargs -0 sed -i -e 's/[ \t]\+\(\r\?\)$/\1/'
pre-commit is awesome
I recently discovered the ✨ awesomeness that is pre-commit. I steered away from it for so long because it seemed like a big daunting thing to set up, but...
Jun 5, 2020 [2]
References:
[1]: #one-liner-to-strip-whitespace
[2]: /pre-commit-is-awesome/
tpope [1] has done a fantastic job with vim-sleuth [2]. Highly recommend taking a look.
sleuth.vim: Heuristically set buffer options
References:
[1]: https://github.com/tpope
[2]: https://github.com/tpope/vim-sleuth
actions [1] has done a fantastic job with setup-python [2]. Highly recommend taking a look.
Set up your GitHub Actions workflow with a specific version of Python
References:
[1]: https://github.com/actions
[2]: https://github.com/actions/setup-python
I came across starter-workflows [1] from actions [2], and it’s packed with great features and ideas.
Accelerating new GitHub Actions workflows
References:
[1]: https://github.com/actions/starter-workflows
[2]: https://github.com/actions
checkout [1] by actions [2] is a game-changer in its space. Excited to see how it evolves.
Action for checking out a repo
References:
[1]: https://github.com/actions/checkout
[2]: https://github.com/actions
Looking for inspiration? dotfiles [1] by nicknisi [2].
vim, zsh, git [3], homebrew, neovim - my whole world
References:
[1]: https://github.com/nicknisi/dotfiles
[2]: https://github.com/nicknisi
[3]: /glossary/git/
Just starred zk [1] by sirupsen [2]. It’s an exciting project with a lot to offer.
Zettelkasten on the command-line 📚 🔍
References:
[1]: https://github.com/sirupsen/zk
[2]: https://github.com/sirupsen
The work on napkin-math [1] by sirupsen [2].
Techniques and numbers for estimating system’s performance from first-principles
References:
[1]: https://github.com/sirupsen/napkin-math
[2]: https://github.com/sirupsen
deepyaman [1] has done a fantastic job with kedro-accelerator [2]. Highly recommend taking a look.
Kedro-Accelerator speeds up pipelines by parallelizing I/O in the background.
References:
[1]: https://github.com/deepyaman
[2]: https://github.com/deepyaman/kedro-accelerator
Chrome Extensions I use
There are many useful chrome extensions out there. I probably have way too many installed, here are four that I am currently using.
This post was inspired from Chris over at daily-dev-tips [1]
- LastPass [2]
- Stylus [3]
- Vimium [4]
- hypothesis [5]
---
LastPass [6] # [7]
Love it or hate it passwords are hard to manage. Everyone needs a password manager to avoid the dreaded password reuse, and to be able to quickly rotate them with a service. I use lastpass, thus it’s browser extension is my most used extension.
[6]
---
Stylus [8] # [9]
Stylus is an extension that allows you to add your own CSS to style pages how you want. There seems to be a full community of folks that really use this to the nth degree to style all of their commonly used sites somewhat similarly or add dark mode to sites without it.
Personally I mostly use it to add my favorite syntax highlighting theme to jupyter, onedark. I’ve long lost the original author, but have posted the CSS I use in this gi...
The work on find-kedro [1] by WaylonWalker [2].
kedro plugin to automatically construct pipelines using pytest style pattern matching
References:
[1]: https://github.com/WaylonWalker/find-kedro
[2]: https://github.com/WaylonWalker
Looking for inspiration? steel-toes [1] by WaylonWalker [2].
a kedro hook to protect against breaking changes to data
References:
[1]: https://github.com/WaylonWalker/steel-toes
[2]: https://github.com/WaylonWalker
I like htop-dev’s [1] project htop [2].
htop - an interactive process viewer
References:
[1]: https://github.com/htop-dev
[2]: https://github.com/htop-dev/htop
Creating Reusable Bash Scripts
Bash is a language that is quite useful for automation no matter what language
you write in. Bash can do so many powerful system-level tasks. Even if you are
on windows these days you are likely to come across bash inside a cloud VM,
Continuous Integration, or even inside of docker.
I have three techniques that help me write more composable bash scripts.
- functions [1]
- Arguments [2]
- positional arguments [3]
- All Arguments [4]
- Error Handling [5]
- main script [6]
---
Functions # [1]
Break scripts down into reusable components
Functions in bash are quite simple. They are something that I wish I would have
started using long ago. They make your code much more reusable. I often use
them in my aliases as well since they can simplify the process and allow more
flexibility.
syntax
#!/bin/sh
# hello_world
hello_world () {
echo "hello world"
}
Source the file to load the function and run it from the terminal.
run it
source hello_world
hello_world
outputs
hello world
...
Three things to Automate with Python using Pandas
Here are three things that I see my non programming counterparts doing every single day. These really sum up so much of what folks do within an office. So many of us dabble in or become power users of spreadsheets without knowing there is an alternative out there that can save us time, automate boring things, and allow us to open up our minds for the part that we add value, Thinking about the data.
Focus on Value Add Operations # [1]
Lets face it, stitching together spreadsheets is zero value add by itself, but if you can see something in the data and take action on it, this can be huge value add to your company. Learning just a bit of python will help focus more of your attention on “value add operations” and leave the mundane stuff to your computer.
Merge a directory full of spreadsheets into one # [2]
I see this one all the time. One team gets a spreadsheet from another team once per month and they need to stich all the pieces together. Excel really opens the door for some na...
How to Install miniconda on linux (from the command line only)
miniconda is a python distribution from continuum. It’s a slimmed-down version of their very popular anaconda distribution. It comes with its own environment manager and has eased the install process for many that do not have a way to compile c-extensions. It made it much easier to install the data science stack on windows a few years ago. These days windows are much better than it was back then at compiling c-extensions. I still like its environment manager, which installs to a global directory rather than a local directory for your project.
Installing miniconda on Linux # [1]
Installing miniconda on Linux can be a bit tricky the first time you do it completely from the terminal. The following snippet will create a directory to install miniconda into, download the latest python 3 based install script for Linux 64 bit, run the install script, delete the install script, then add a conda initialize to your bash or zsh shell. After doing this you can restart your shell and conda will...
How to crush amazing posts on DEV
This post was inspired by a comment I left on @dsteenman’s post.
{% post dsteenman/how-long-should-a-blogpost-be-2k6n %}
Most of the time I prefer short as I am more likely to read the whole thing. If its setup as a series I am more likely to work my way through the whole series in a matter of a few sessions. Just my preference
I will say though there are certain articles that fit well to the long format. They are articles that folks tend to come back to often as a reference again and again.
Sections # [1]
- layout is key [2]
- Break it up [3]
- Article types [4]
- superpost [5]
- single post [6]
- series [7]
- discussion [8]
- Post what you want to read [9]
layout is key # [2]
Either way, you go layout is key. You are not Steven King, no matter how great of a writer you are, you are unlikely to hold attention like he can. Most folks reading blogs scan articles first. I often scan, then read. If the article is really good or pertains well to me I will read everything, ...