Categories
personal

Minimize interrupting notifications to stay focused

annoying notifications

I work remotely, so I have to be communicated through chats, emails and service notifications. On my desk at all times are a laptop, a tablet, a phone and a smart watch (on my wrist). When a notification comes along, all four beep almost at the same time. Technology connects us more every year with more devices, wearables and social apps. But sometimes being too connected gets in the way of truly connecting, and specially, being productive.

As a software engineer, my work is more in the creative process than in the task oriented type of work. Many times when planning or designing software, I need absolute silence and long moments of full concentration to build the mind model of the software I’m working on. Notifications get in the way of full concentration. Even when you can dismiss them right away, it’s a “ding” that goes into your workflow and ends focus.

Programmer Interrupted

Considerations for interrupting

Here are some considerations to take in mind when communicating with others (or, what I would like others consider when communicating with me):

When sending someone a message, get to the point in one long sentence rather than several short ones. Never start with “hey” or “can I ask you a question?” or worse, send one word messages and trigger 10 notifications in 5 seconds. I can’t count the times I get a message, a one line that says “hey” and then I have to wait until the real message/question comes in before I get back to what I was doing. Just type in your message, even if it is one long message. Chat applications can handle long messages, only Twitter is still limited to 140 chars (and considering changing that). That will create less constant interruptions and straight forward communication.
Use chats for short conversations, email for long explanations. If your question, message, or the expected answer to it, is too long to explain in one single chat message (or paragraph) then consider using e-mail as your communication channel. E-mails are easier to track back and check the context of the conversation than scrolling back in a chat window. Some chat programs don’t even have a search function.
Only use chat programs when you need real-time conversation. A few years ago, messaging or chat applications were called “Instant Messaging” apps. I don’t know where they lost that classification, but not everything needs instant reply. Use forums, message board applications, e-mail or other types of communication instead.
Consider the time of your interruption. Avoid annoying people in chat windows with irrelevant questions. Don’t send chat messages extremely early in the morning or very late at night, unless an immediate attention at those times is required.

Tips to minimize distractions

Some tips to stop notification saturation:

If you’re like me with many gadgets in your desk, put all of them except for one in silence. This way you’ll avoid multiple beepings everywhere when a notification comes along. And believe me, you’ll feel less stressed or annoyed during the day. It has made a huge impact in my daily life.
Prefer vibration over sound. In my experience, sound creates an annoyance Palvlov response faster than vibration.
If you use Gmail, activate the “priority inbox”. Then in your apps, set the notifications to only trigger on emails marked as important.
Use web versions of mobile chat applications. Most mobile chat applications have a desktop or web equivalent version (WhatsApp web, Telegram, iChat, Skype, Hangouts). Having the chat in your computer will avoid the need to pull up your phone to read or reply back. It’s easier to just switch windows or browser tabs and faster to reply back with a physical keyboard.
Schedule notification downtimes. On Android devices you can set notification downtimes to avoid getting interrupted. I set them at night to sleep like a sane person and sometimes during the day when I need full concentration moments. If you already do this for night times, consider expanding the downtime to your first hour or two of the day. Enjoy your morning and start your day without beeps and inquiries.

Unless you’re a doctor or a sysadmin, emergencies are not life or death situations. If emergencies are constantly coming up in your life, you should analyze your environment because then the problem is much bigger than notifications.

Categories
personal

My ideal morning daily routine

morning tea

I’ve been very interested in how successful people (in different areas) have established morning routines. The most common claim is that it frees you from early decision fatigue and structures your day. Some of the morning routines are inspiring.

It has been a struggle for me to achieve a perfect morning routine because I have early meetings with my team in India. My biggest problem is going to bed early the night before to be able to wake up without much struggle at 6:30am the next morning.

This is how my typical uninspiring and stumbling morning routine looks like:

– 8:20 Wake up.
– 8:25 Make tea.
– 8:30 Start conference calls while sipping the tea.
– 11:00 After conference calls, take a quick shower (if this is skipped, then shower time is at 6pm).
– 11:30 Figure out the rest of the day’s activities as they come.

And here’s what my ideal morning routine should look like:

– 6:30am Wake up
– 6:35 Have a cup of tea (typically Monkey picked Oolong tea) in complete silence while I plan my day.
– 6:50 Meditate for 15-20 minutes.
– 7:15 Exercise for 30-40 minutes (elliptical machine or walking outside).
– 7:55 Shower.
– 8:15 Breakfast
– 8:30 Ready to start conference calls.

Achieving this morning routine is important for me because no matter how chaotic or busy the day can get, I’ve already had some time for myself (meditation), done at least some exercise and had the first meal of the day. This gives me a feeling of accomplishment: The day starts and I already have stuff done, even if that stuff is not exactly work related.

Do you have a morning routine? Does it helps you be more focused or productive during the day?

Here are a few videos of people I look up to with morning or daily routines.

Categories
Emacs GNU/Linux Free Software & Open Source

Quick note taking with Emacs and Org Capture

Taking notes has to be a taks that is fast, easy and must not get in the way of the things you’re doing. How many times do we forget something because we didn’t write it down right away? Or how many times you didn’t took a note of something because you don’t have a quick and simple way to easily write down that idea for later use?

Using Emacs for most of my daily workflow and Org mode as my organizing GTD system, having a quick way to take notes and store ideas or links quickly is a huge advantage. This is the fastest note taking system I’ve used so far and even if you’re not using Emacs or Org mode, this feature alone is worth spending a little time learning the tools.

Remember mode was the way to capture ideas fast and easy without getting in the way. Until Org mode version 6.36, you had to hook up remember mode to interact with Org to capture your notes. Now you don’t need to since there’s Org Capture. It is part of Org mode and it’s got all the functionality of remember mode with the advantage of being built-in with Org mode.

Setup org-capture with global keybindings so that no matter what you’re doing (within Emacs) you can quickly capture something with a fast shortcut. I like to bind it to C-c r

(setq org-default-notes-file (concat org-directory "/notes.org"))
;; Bind Org Capture to C-c r
(global-set-key "\C-cr" 'org-capture)

If you are using Emacs prelude setup a different shortcut because this one will conflict with prelude rename command. Since I’m already wired to use that shortcut and I barely use the prelude-rename command that often, I added this to my setup:

;; Unbind prelude rename command
(global-unset-key "\C-cr")

Like with remember mode, you can set up templates for your captured notes. If you’re already using Remember mode, you can import your old templates to the new org-capture templates. To convert your org-remember-templates, run the command:

M-x org-capture-import-remember-templates 

Here’s an example of two templates I always set up with org-capture:

;; Org Capture
(setq org-capture-templates
      '(("t" "Todo" entry (file+headline (concat org-directory "/gtd.org") "Tasks")
         "* TODO %?\n %i\n")
        ("l" "Link" plain (file (concat org-directory "/links.org"))
         "- %?\n %x\n")))

The first one will capture a TODO entry under the headline Tasks inside the file gtd.org in my org directory. I’ll use this one whenever I want to add a todo task quickly. The second one will copy the contents of my clipboard and will paste it as a new entry in the file links.org as a list item without any header and will have my cursor ready to type the item list description. This one I use it when I want to save a link url, typically a bookmark from the browser, in my links.org file to consult it later.

To access each template, a key has been set for each. When org-capture is run, it will prompt you what you want to capture. Press ‘t’ for a Todo or press ‘l’ for a link. You can add more templates to suit your needs with the extensive template options described in the Org manual.

org-capture
Using org-capture

Finish the capturing process by typing C-c C-c which runs org-capture-finalize and the capture buffer will disappear so you can continue what you were doing without interruption.

Note photo by [email protected] on Flickr
Categories
GNU/Linux Free Software & Open Source Tutorials & Tips

Quick search and replace recursively in multiple files

Lately I’ve been working with a lot of static HTML files with lots of repeating text structures. In the past I’ve talked about editing multiple files with Emacs. This approach works very well when the number of multiple files and text matches in each file is manageable or you need to make sure every match to replace is correct, since you need to confirm pressing y on every text match in each file.

In other cases, like the one I had to solve, you can have 84,000 text files where each file can have more than 5 matches. This case, doing it with Emacs wouldn’t reduce much time. It also helps that the pattern I was looking for was consistent without me needing to check every match.

So to do a quick search and replace recursively in multiple files, another “old school” tool comes very handy.

GNU Sed

Quoting from the GNU Sed project page:

Sed (streams editor) isn’t really a true text editor or text processor. Instead, it is used to filter text, i.e., it takes text input and performs some operation (or set of operations) on it and outputs the modified text. Sed is typically used for extracting part of a file using pattern matching or substituting multiple occurrences of a string within a file.

The way to tell sed to do a search and replace on some given text, the syntax is the following:

sed -n -e 's/regex/text/g' filename

The -n switch makes Sed not to output its results to the standard output and overwrite the file with the results. The -e switch specifies that the following string is a command to perform on the file. The regex part is the regular expression to use for searching in your text. The text part is the text you want to replace your search with.

So Sed receives streams of text as input, makes some operations on it and outputs the results. This way of seeing it, makes it very obvious to understand that the natural way to use it is through bash calls using pipes.

The find tool will help us get a list of all the files that we need to pipe into sed. In the same way we used find from within Emacs, we can call it from bash:

$ find path/to/folder -iname "filenamepattern"

So a combination of find with sed can be used in the following way:

$ find myprojectfolder -iname "*.html" | sed -n -e 's/searchregex/replacementtext/g'

As easy as that, and you have edited 84,000 files with one single line of bash.

Hope its useful for anyone. It has been very useful to me. If you have other methods or other sed tips, I’d like to know in the comments.

Categories
Emacs GNU/Linux Free Software & Open Source

Emacs tip: How to edit multiple files on several directories in less than a minute

Recently I had to edit multiple files (239 in total) scattered in a bunch of directories and subdirectories. Here’s a quick and safe way to do it.

What I had to do was add the Google Analytics script snippet to a part of a website that was being maintained by a pair of <your favorite bad adjective here> developers.

So, first I thought of using sed or awk or something like that, but doing a quick search replace like that without checking if my match is correct in every instance in a bunch of files can lead to a big disaster.

But wait, I have Emacs! So, the first thing to do is find and list all the files you need to edit.

  1. Open the parent directory

    Use dired to open the parent directory where all the files and directories are. Open dired with:

    M-x find-dired


    and enter the path for the directory.

  2. Find the files

    Emacs will then prompt: “Run find (with args):”. So if you need to edit all HTML files, or in my case, PHP files, you type:

    -name "*.php"

    If you want all files regardless of type, enter

    -type f


    Basically you can type in any arguments you want if you know how to use the find command.

  3. Mark the files you need to edit

    A list of all found files will appear in a dired buffer. Now you need to mark the files you want to work with. Typically you’ll mark all files since you already filtered them. Press t to toggle marks and all files will get marked. Or if you want to hand pick them, move the cursor to the file line or name and press m.

  4. Do the find and replace

    Type: Press Q or M-x dired-do-query-replace-regexp to run the find and replace command. It will prompt you first for the text you want to find, then will prompt you with the text you want to replace it with.

    Then Emacs will start the find and replace operation, and will prompt you on every find if you want to replace the text or skip it. To replace, type y, to skip to the next find type n. To replace all occurrences without asking, type !. To cancel the operation, type C-g.

  5. Save the edited files

    Now that you’ve made all these changes, you need to save the files. To avoid saving manually all files, you can open ibuffer

    M-x ibuffer

    Which will list all you opened files (called buffers). Now, like in dired, you need to mark the buffers you want to work with. To mark all unsaved files, type * u and then type S (that’s shift+s, for the capital letter) to save them.

Done!

Easy and without a sweat.

photo by zyphichore on Flickr.