-
750 words a day
Iāve had increased interest in writing throughout this year. In addition to being a pleasant and fulfilling activity, it shown a number of benefits in my everyday life and career:
- Composing emails became faster and easier. When you have to reply to a couple of dozen emails a day, speed and attention to details matters. Writing more taught me to write more concise emails which are easy to read.
- Writing a lot isnāt a problem anymore. If I have to write documentation, comment code, or just put together a very long email - Iām not put off by the idea. Iām excited about it.
- Typing speed went up. I already touch type, and constant writing practice increases the acquired speed. Fast typing makes life easier, speeding up mundane tasks, freeing up brain power for more costly activities.
- Itās easy to keep a condensed work log to highlight the issues of the day. Tough programming issues, āEureka!ā moments, meeting notes - this historical data saved me hours or even days of repeating my mistakes.
A while ago, Iāve heard of a thing called ā750 wordsā, a site built around a challenge to write 750 words a day in order to improve writing skills and unleash creativity. This looked like a great idea, and I decided to give it a shot. I prefer to keep my personal entries offline, and I decided not to use the provided service, but to keep a set of plain text files on my local machine. Which worked out just fine. Itās all just text after all.
I lasted for 10 days in a row, which I am proud of (filling up approximately 3 pages a day was no easy task for me). I started of with silly entries about not knowing what to write about, and finished with a piece of a fiction story. Thatās a considerable improvement.
By the end of the challenge I was mentally exhausted. But it taught me a very important lesson: the more you write, the better you become. And thatās one of the main reasons I keep crafting new entries for this blog.
This happened half a year ago, I just never got around to writing about it. I will go ahead and start another 750 words spree today. Maybe this time Iāll be able to make it last for the whole month.
-
Beyond grep
I search for things a lot, especially in my code. Or even worse - someone elseās code. For years
grep
served as an amazing tool for this: fast, simple, and yet powerful. That was until I discoveredack
for myself. An incredibly easy to usegrep
implementation built to work with large (or not really) code trees.A lot can be said to enforce superiority of
ack
overgrep
when it comes to working with code, and itās all said here: ackās features.Amazing thing is -
ack
doesnāt even need a tutorial. Learning progression is natural and ājust happensā by researching necessary use cases as the need arises (ack
has a great manual entry).Hereās a typical use example for
ack
:ack --shell 'gr[ae]y'
Searches all shell script files in the current code tree for any occurrences of āgrayā or āgreyā. It will search
.sh
,.zsh
, and just about dot-anything;ack
will even check shebang lines for you.Ease of use, the fact that itās ready to use out of the box, extensive file types, native support for Perlās regular expressions:
ack
does really good job at searching through code.Download it from Beyond grep.
-
Effective search with Mutt
I generally donāt use Mutt for everyday emails - I find smooth non-monospace fonts to be more pleasant to the eye, and the visualization my browser offers is hard to beat. The main use-case for me is composing long emails: Mutt lets me use my favorite text editor, which speeds up the editing of long and carefully composed responses.
Recently I added a new use-case to my work flow: searching through emails. Mutt has a powerful built-in regular-expressions engine, which is something the web Gmail client is missing.
Mutt has two ways of finding things: search and limit. āSearchā just jumps from one matching letter to another, something along the lines what
/
command does inless
,more
, orvim
. āLimitā is something I am more used to with the web client, and itās what I use the most.Using limits
Limit works the way regular search works in Gmail: it limits the view to conversations matching the query. Hit
l
, and enter a search query.By default, Mutt will only search through the subject lines, but this behaviour can be changed by prefixing the command with a special identifier. For instance, searching for
~b oranges
will limit the view to all the messages which mention āorangesā in the message body. Here are a couple I use the most:~b
ā Search in the message body.~B
ā Search in the whole message.~f
ā Message originated from the user.~Q
ā Messages which have been replied to.
You can find full list in the Mutt Advanced Usage Manual.
Patterns can be chained to produce narrower results:
~f joe ~B apples
. This will search for a message mentioning āapplesā coming from an author whose name contains ājoeā.Caching mail for faster search
You may find that searching whole messages is slow, especially if you have more than a couple hundred messages to search through. Thatās because by default Mutt does not store messages for local use. This can be changed by specifying
header_cache
andmessage_cachedir
variables in your.muttrc
file:set header_cache = "$HOME/Mail" set message_cachedir = "$HOME/Mail"
Now, after you perform your first search, it will cache every message you open, making all the consecutive searches lightning fast.
Oh, and keep in mind, Mutt stores messages and headers in plain text, so make sure the cache directory is not shared with anyone but yourself.
-
One more argument for 80 character limit
Limiting code to 80 (or 100 or 120) characters per line. Itās a well-known topic, and thereās an overall consensus on the subject, not counting occasional questions by newbies and odd cases. Most established tech companies have their own line length guidelines. These are often dependent on a language, such as in the case of Google with their 80 character Python and 100 character Java limits.
In this article, I wonāt be advocating all the usual arguments, such as easier diff with version control software, or the ability to stack windows side by side on wide screens. No, I believe that battle to be won quite a long time ago, the topic is now closed. But something I didnāt find mentioned in any of the discussions is an interesting point from the world of writers and designers.
Ever since I started being interested in improving my writing skills, I found article after article mention the importance of line length in reading. Interestingly enough, this issue was raised in a world of literature. It had been resolved long before programmers were fascinated with the desire to use up rapidly expanding screen real estate.
I am talking about something known as āmeasureā in typography. It seems to be the reason newspapers use narrow columns, or books leave such vast margins around the text on a page. Hereās an exempt from the Wikipedia article:
Measure (or sometimes āThe Measureā) in typography is the length of a line of text. For a single-column design measure should ideally lie between 40 & 80 characters. Many typographers consider the perfect measure to be 65 characters. If the lines are too short then the text becomes disjointed, if they are too long the content loses rhythm as the reader searches for the start of each line. Punctuation should preferably hang outside the measure.
Most programming languages use special operators and keywords, which can be considered āpunctuationā. Some languages are more verbose (use more punctuation), and some arenāt. If you remove punctuation, the 80/100/120 character limit perfectly fits the standard time-honed āmeasureā.
Maybe I can use this as an additional argument the next time I have to explain to a junior new hire why the character limits are so strictly enforced.
-
Three favorite bash tricks
I spend most of my development time in the shell - be it editing text with Vim or executing various console commands. I have quite a number of tricks in my daily repertoire, and I would like to share three tips today.
Edit current command with a text editor
I often end up having to change a long command I just typed, and using arrow keys to get to the correct spot is not favorable. Bash has the feature which lets you edit current command in a text editor of your choice. Hit
Ctrl + x
,Ctrl + e
(orCtrl + x + e
), and you will be dropped into your text editor. Now you are able to edit the command, and it will be executed as soon as your write the file and exit the editor.You can use an editor of your choice by adding following line to your
.bashrc
file:export EDITOR=vim
Replace
vim
with the name of your favorite editor.Update: It looks like for some machines setting
EDITOR
variable is not enough. In this case, you also need to setVISUAL
environment variable.Edit recent command
You can edit your recent commands in a text editor of your choice by executing
fc beginning_of_the_command
. For instance, if you runfc l
, you will open most recent command starting with the letter ālā.You can execute
fc
without any arguments to edit last executed command.Bash history autocomplete
Another great feature - āreverse intelligent searchā. If you hit
Ctrl + r
in your shell, youāll be greeted by the following prompt:(reverse-i-search)`':
Start typing a part of the command from your history, and youāll see suggestions popping up. Hit
Enter
to pick the command (youāll be able to edit it before executing), or pushCtrl + g
to return back.Like any of these tips? Have some of your own? Donāt hesitate to share those in the comments section down below.