Productivity

Read Later Tools are Productivity Killers

First, lets take a count of your open tabs as well as ‘Pocket’ like tools which are marked ‘Read Later’.

Post the creation of Insta Paper, everyone wanted to read their information in a clean way, those who cannot tried to push it to their Kindles or Evernote. These people read a lot and wanted to read a lot. When you push to other devices, you may lose count on what you need to read.

What I have realized is that > Reading and Watching makes you do less Writing (be it code or language)

I was this person about an year ago till a friend talked me down. Its really really impossible to keep up in realtime about Javascript frameworks, Apple Rumors, what changed where and when its being released.

I have heard in podcasts, seen and read about people that

  1. have tens (even 50+) of open tabs and complain about how Chrome / Firefox is hogging the memory
  2. Some wish for the browser to crash so that they happily forget (eventually people reach this from above)
  3. Some keep their browser clean with pushing the stuff to read into Pocket like tools.

The Read Later tools are for whom who have lots of spare time on weekends and clear off their tabs and read list in a week or two. If you keep something for later, it gets missed and forgotten leading it into the virtual blackhole. This is a reality whether you like it or not. This happens a lot when you are researching.

For those interested in the math, 10s of HN new posts every four hours will pile up to 40 or so in a week (at the least), averaging to 8 on weekdays.

When you mark an article as ‘Read Later’, its telling the tool to remind you to forget about it

The Solution - An fixed size array

Write stuff you can’t remember and maintain a list of top 50 things you want to read online at any point of time in each section. If you want to read new stuff in Java or Go or Linux or about politics, spend the time then or add to your fixed size array, not a queue, not a stack, not a linked list. Just close it off once its done.

Keeps you 😴 better at night.


CLI Productivity Tools - FZF & Yank

fzf

Came across an powerful CLI fzf utility. There are plugins for vim, tmux and bash too. If you are a command line junkie like I am, you should definitely not miss this.

yank

do check out yank and on mac with

brew install yank

source: http://brewformulas.org/yank

Now fzf | yank

ps -ef | fzf | yank

copy the selected output from fzf and copy it into clipboard. There are lots of other options. The demo is just the book cover.


Bypassing the paste restriction on the browser

Banking sites and Mac OS Keychain makes you intentionally type in your credentials. These can be usually bypassed with help of browser specific extensions using Password Managers like 1Password or LastPass. Its also important to note that have their own downsides aka bugs.

Being a developer using a keyboard for hours every day since 10+ years, being productive will become a mandatory requirement for me personally. By unblocking websites and Mac from restricting me to use the bypassed paste, I feel invincible on the keyboard. Although you need to think through of other security implications of using the clipboard to store sensitive data.

The advantages for me were

  1. Bypassing the paste restrictions
  2. Pasting text from the browser without styles into existing notes / cheatsheets.

The paste has been both an important and tough to bypass. The bank websites stop you to use the Paste option in all possible ways with the help of Javascript and they do not work without Javascript (which is sad)

Old Solution

I used an Alfred Workflow called Type to achieve that till it became unusable when I upgraded to Sierra (10.12). The workflow has become buggy, I think its part of the OS itself or something I did not spend time figuring out.

When I had input text in the clipboard as a mix of lower case and upper case, it used to juggle lower case into upper case which has been a pain to correct. Especially when its an input field.

New Solution

While struggling with this problem for about a week and avoiding to type where ever possible, I came across “HammerSpoon”, a desktop automation tool . A desktop automation tools helps you script/automate tasks. Its written in Lua.

What can HammerSpoon do?

You can write Lua code that interacts with OS X APIs for applications, windows, mouse pointers, filesystem objects, audio devices, batteries, screens, low-level keyboard/mouse events, clipboards, location services, wifi, and more.

It is simple to script out what you need with the help of the exhaustive documentation

Find the script for Paste bypass

Here is my current configuration. I can now right click with my keyboard or even scroll without going to the arrow keys on the browser.


Making Code Cheatsheets

I used to be a Google / Stack Overflow junkie for syntax issues or finding configuration/compatability issues in the vast amount of dimensions software gives us.

An approach I used to solve this problem was to document snippets once I have solved the problem (don’t forget to upvote the answer on SO). This is especially useful when you start learning a language. When you start learning a language, there are

  1. Syntax
  2. Style Guide
  3. Bad Practices to avoid
  4. Good Practices to start with
  5. Test cases to cover
  6. Libraries to use
  7. Libraries which are not upto date
  8. Highly opiniated frameworks
  9. The philosophy of the community
  10. Tooling
  11. Vendoring
  12. Advanced Syntax
  13. Backward compatible changes
  14. Where to find help instantly (when stuck)
  15. How to maintain, build and deploy
  16. The Database interaction
  17. The Spec (may be)

As a curious person wanting to learn everything you can with tens of open tabs, believe that once you start doing a project, you will eventually get to all these.

I started learning Elixir and it took me a while to get over syntax itself. I thought I would make a different approach while starting Go. This is about in August 2016 that I started to write down (copy often) the code snippets and what they mean from the books I was reading.

Maintaining a cheatsheet in a 3 column layout for code snippets has been a huge time savor when I was searching on how was this done here. (well, may look better with Borders)


Example:

What Code Snippet Reference Link
H1 heading # heading 1 Ref H1 Link
Links [link](text) Ref Link

I use a table structure in Evernote for now which I will have to soon move to a Git Repo in markdown. Inspired by other cheatsheets I find, I have decided to make my own so that

  1. Help others work like me so that they dont have to search SO
  2. I can reference them from any where outside my private laptop
  3. Try to make the development world a better place

This approach has worked well for me when I was learning the Go language and resuming my work on Ruby has made this better.


You can track any organisation’s new open source repositories or code changes in public repos from Github or Gitlab using Gitnotify.com

GitNotify > Sign Up with Github > Track Organisations > sairam


Screen Capture Command on Mac

(This article was intended to be written on 18th Sep 2016, but actually written on 8th April 2017)

In order to take a screenshot on Mac, the standard way is to the Grab application.

Keyboard users often get used to these.

⌘ + ⇧ + 3  - full screen which generated a file on Desktop
⌘ + ⇧ + 4 - capture custom dimensions using the mouse.

I recently discovered that screencapture command is part of the OS X. I happen to have the need to paste a screenshot in a chat (in the current world, input boxes or gmail compose allows you to paste an image inline without the need to have a file on disk)

screencapture: illegal option -- h
usage: screencapture [-icMPmwsWxSCUtoa] [files]
  -c         force screen capture to go to the clipboard
  -C         capture the cursor as well as the screen. only in non-interactive modes
  -d         display errors to the user graphically
  -i         capture screen interactively, by selection or window
               control key - causes screen shot to go to clipboard
               space key   - toggle between mouse selection and
                             window selection modes
               escape key  - cancels interactive screen shot
  -m         only capture the main monitor, undefined if -i is set
  -M         screen capture output will go to a new Mail message
  -o         in window capture mode, do not capture the shadow of the window
  -P         screen capture output will open in Preview
  -s         only allow mouse selection mode
  -S         in window capture mode, capture the screen not the window
  -t<format> image format to create, default is png (other options include pdf, jpg, tiff and other formats)
  -T<seconds> Take the picture after a delay of <seconds>, default is 5
  -w         only allow window selection mode
  -W         start interaction in window selection mode
  -x         do not play sounds
  -a         do not include windows attached to selected windows
  -r         do not add dpi meta data to image
  -l<windowid> capture this windowsid
  -R<x,y,w,h> capture screen rect
  files   where to save the screen capture, 1 file per screen

screencapture -c -i

solves most of my needs to capture interactively with output into the clipboard.


TIL: Bash History CLI Shortcuts

## Previous Command's All Arguments
mkdir long_path_here/new_dir
cd !*

## Previous Command's Last Argument
mkdir long_path_here/new_dir
cd !$

or even use $_ instead of !$

## Previous Command's First Argument
mkdir long_path_here/new_dir
cd !^
## History
mkdir long_path_here/new_dir
cd `Esc` `.`
cd `Alt`+`.`

Pressing Esc followed by . will give previous arguments

## "More Options"

!^      first argument
!$      last argument
!*      all arguments
!:2     second argument

!:2-3   second to third arguments
!:2-$   second to last arguments
!:2*    second to last arguments
!:2-    second to next to last arguments

Getting Alt to run on iTerm

  • Open Preferences in iTerm using Command+,
  • Go to Profiles
  • Go to Keys
  • Fix the setting Left option key acts as

    iTerm Preferences - How to Change Alt as Meta key

If you are Terminal on Mac, consider moving to iTerm(if you are not a power user)

  • If you still want this setting in Terminal, look here

Sources


Bye bye Delicious! Yo Pinboard!

Delicious has been one of my favourite and a tool that I have held since 200[78]. The entity has been through several transitions. People have feared and moved out and became in-active. del.icio.us the most famous domain hack around 2008. Yahoo bought it, later sold it and I don’t know what happened later on.

Then, starting around Dec 2015, Delicious started popping up Advertisements. They were like the ads from 2000s where you see amazing animations which sucked. Improvising to it, in March 2016, they decided to move from https to http which blew my mind away (not literally).

Time to evaluate choices

What I really want? (aka The Product Spec)

What I really wanted was a place where I can maintain a public list and query bookmarks by tag for later references.

Both services (Pocket and Pinboard) offer you a way to search through the text itself for the higher versions of the service. You can achieve that with the help of Evernote. Evernote has that capability as well. Google and Chrome Bookmarks sync through devices and follow you, but they lack the UX feel I have been used to(like Delicious). Pocket felt overwhelmingly because of the UI. Its a 2015 UI product, while Pinboard UI continued to stay in the 2010s with the light-weight and simple(way too simple) UI.

I realized that Evernote gives this and way more, but I made the hard choice of keeping Evernote to referencing data from sites instead of actually bookmarking them. Evernote does a lot of things(A LOT).

The DECISION - Pinboard

Pinboard has a yearly $11 pricing for the basic version and been in service more than others. I might move to Pocket later only for the UI, even if it means $45 for the Pro version Also, Pinboard does not bug me with weekly newsletters like Pocket does 😃

Pinboard has the social angle of tagging “for:user” which Delicious killed off just after the Yahoo acquisition(to my knowledge) or after the news Yahoo was buying Delicious. My social circle who were in Delicious immediately reached ZER0.

Follow and suggest me links https://pinboard.in/u:sairam/

The bookmarklet which I can invoke through the keystrokes on chrome helps a lot. yd which invoke the bookmark to open a new window to prompt to add tags.

I am yet to explore notes in Pinboard



csshX with lincastor on Mac

Problem Statement: I want to SSH into a list of hosts from the browser(from a host monitoring UI).

Note: At this point of time, we did not have Service Discovery present.

To identify this, in our team, we maintained a single service which has this list. The service is responsible for bunch of things including displaying host metrics, checking health statuses, disk space, querying the LB status for the service/port.

A regular deployment usually consists of updating a puppet script and running a puppet command on all servers in batches of 20% at a time. When you start dealing with multiple hosts, you realize you want to use a utility command like csshX which opens multiple windows. Though this is limited by the configuration file or copy/pasting the host list.

I wanted to pass on this host list data from the browser and with a click of a link, the user should be able to get the list of hosts.

A Solution was to use LinCastor, a Mac utility where you can register your own protocol with your multi ssh utility.

Once, you register the csshx protocol.

## To install csshX
brew install csshX

Open LinCastor App

Add new Scheme Title: csshX schemes: csshx

select Shell. Add this line before exit 0

/usr/local/bin/csshX $URL_VALUE

Now if you have a link like csshx://127.0.0.1%20127.0.0.2%20127.0.0.3 , it will open 3 shells using the csshX command installed passing it as csshX 127.0.0.1 127.0.0.2 127.0.0.3. The protocol handler transfers the ownership in a very clean way.

Security Warning: Beware about any URL injections that may happen while using this. As long as you trust the source, you should be good.


Moving to a Smarter Life

After losing my iPhone 3 years ago, I lost hope of ever buying an iPhone again. I lived on with Nokia phones without access to internet, relying on my laptop for source of real time information. I adored smartphones, but despised Android because of lack of quality, security and consitency of buttons, features, app store. After buying my first Mac 4 years ago, my world has changed. I was into iPhone, Apple news, develpers who have their working environment on Mac. Linux is a solid server rather than a development environment. TextMate, iTerm and Alfred are the best applications. Adopting a Android phone seemed an unlikely fit.

When the news about the Motorola phone) hit the Flipkart office, I decided to take a chance with Android. There was a general discussion on 8 vs 16 Gig models. One person mentioned that there was 11 Gig free space on his 16 Gig phone, then I decided an 8GB would be more than enough for my usage if ever I use it like I used my first iPhone. The Flipkart site was reported down on the launch day of Moto G. It was an exclusive launch on Flipkart where the site experienced higher traffic than it was provisioned for. I ended up placing my order with a 1 day delivery. Next day morning, I went to the delivery hub and picked up my phone. (Yes, you can visit a Flipkart’s Delivery hub and pickup your item before they dispatch with the courier).

Flipkart launched the phone at 12am where the stock was ordered in minutes. There was a relaunch in the afternoon to take in preorders for both 8 and 16 Gigs. There was a review by a lost and frustrated soul that it was harder to book the Moto G than to book a Tatkal ticket.

The good: WhatsApp was the biggest hype of all. Most of my friends stopped using conventional email and started WhatsApp since its easier on the go and easier for group messaging. Remember the desktop client which had group messaging ? - Yahoo. You can send the same message to all members. The nicest and most annoying feature was a ‘Buzz’. You buzz a person to get notice of the chat window. Well, Google killed it. From my perspective, WhatsApp is a group messaging app on the phone where Yahoo Messenger was to web. Obviously, this is a perspective from an eighty thousand feet view. There is security, scale, laws, hacking etc., Its worth $19 billion for Facebook because of the users and the ads and the content being flown around to understand people and direct advertisements.

Email is the normal thing you expect to be in touch with. Camera, pictures, Clock, Alarm, Contacts are the standard set.

Being new to the Bangalore City, Google Maps is the best feature I use, but it drinks up the battery like I consume water (Gulp, gulp, gulp and the bottle is left with only 50%). I started attending meetups - Docker and Ruby for now. The usability of few of the features is not as expected. I cannot find the address of where I am (I usually get lost) when I want to notify a cab or a friend. I wish it took information from my calendar to display where I need to go.

The Calendar, When you are in a meeting, you wont be disturbed with calls. You can configure and customize it so that you notify my caller over SMS or only get the calls from your contacts.

I keep in sync with the web with Feedly (after the homicide of Google Reader). ReadMill for ebooks. Asana for tasks or errands.

JustEat should remake their app. Meru has a nice interface, but if only we could send the location to the driver without the address information. That reduces the time of conveying the information a lot.

The Flip Cover is nice. You wont get your sweat on the phone especially in the summer or after hours of talking. My parents appreciated the clarity and hands free.

If you want a talking buddy, you can talk using ‘OK Google’. I never got to talk to Siri.

The ugly: It does not have 4G. Not so great touch like Nexus 5. Moto G is 1/4th the price of Nexus 5 in India. Battery, well its only when I am using Wifi Networks or Location services.

I feel that I now moved to a smarter life. I only wish I had bought a smartphone sooner.


Configuring SSH Server

Basic README

# $OpenBSD: sshd_config,v 1.80 2008/07/02 02:24:18 djm Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options change a
# default value.

Default system level configuration

Change the default port from 22.

Port 2345

I don’t really know what this is

#AddressFamily any

There are can be associate this with either a single address or all the addresses the system has. This is important if your server is part of two networks so that you can use only one of the addresses to bind it to.

#ListenAddress 0.0.0.0
#ListenAddress ::

SSH Protocol to use

# Disable legacy (protocol version 1) support in the server for new
# installations. In future the default will change to require explicit
# activation of protocol 1
Protocol 2

Host Key is something to uniquely identify a host.

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key

# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 1024

Log files is the veins of the system. If things go bad, this is where you need to look. Describe what kind of logging should be done

# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO

Authentications

Self explanatory, paranoia in case you don’t want to hit your too often with password retries

# Authentication:
LoginGraceTime 2m
PermitRootLogin no
StrictModes yes
MaxAuthTries 6
MaxSessions 30

Public key authentication for safe and secure way. Generate an RSA token which will generate id_rsa (the private key and should not be shared) and id_rsa.pub(your public key, can be passed on to system where you want to login into).

#RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile  .ssh/authorized_keys
AuthorizedKeysCommand none
AuthorizedKeysCommandRunAs nobody

Don’t really know what this is

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

Keyboard based authentication of password from the client. If you feel too lazy to type a password all the time see public key authentication section # To disable tunneled clear text passwords, change to no here! #PasswordAuthentication yes #PermitEmptyPasswords no PasswordAuthentication no

Challenge Response Authentication

# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no

Kerberos is a network login system which is usually used in a medium to big organisations having network logins and multiple servers. If its 2-3 users and couple of servers that share passwords, its better off not setting Kerberos like systems.

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
#KerberosUseKuserok yes

You don’t want this in a normal server since the handshake itself eats up lot of time. Setting to no disables it

# GSSAPI options
GSSAPIAuthentication no
#GSSAPIAuthentication yes
#GSSAPICleanupCredentials yes
#GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
#UsePAM no
UsePAM yes

Environment variables

# Accept locale-related environment variables
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS

Other custom settings with which you can use the power of SSH and remote system

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no

If you want to open a Firefox from a different server. enable to ‘yes’

X11Forwarding no
#X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes

Print message of the day

#PrintMotd yes

Enabled by default to let the user know when s/he was logged in last.

#PrintLastLog yes

This is helpful for not timing out the user

#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#ShowPatchLevel no
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10

Tunnel is used for using the ssh server as a proxy

#PermitTunnel no

Chroot is a bigger concept which is to restrict environments / environment configuration with dependencies so that they do not interact with the rest of the system. Its like a Virtual Machine in your computer which does not know if its a Virtual Machine or a real server.

#ChrootDirectory none

Display information aka banner on what to do, what not, what the server has etc after logging in.

# no default banner path
#Banner none

Enable SFTP

# override default of no subsystems
Subsystem   sftp    /usr/libexec/openssh/sftp-server

If you want to allow a user to do something or not to do something, this is the place to put it

# Example of overriding settings on a per-user basis
#Match User anoncvs
#   X11Forwarding no
#   AllowTcpForwarding no
#   ForceCommand cvs server

Tips on ssh client configuration