How to hide tab bar while using Tree Style Tab or Tab Center Redux in Firefox

The following post is for Macbook however for windows and linux users steps remains the same.

Go to Navigation sidebar with three dashes in the top right corner
Click on it.
Go to Help
Go to Troubleshooting information
You get an about:support page.

Go To location pointed by Profile Folder - Use Show in Finder for macbook.

Now - Create a folder - "chrome" inside that profile folder

Create a new file named userChrome.css in chrome folder

Paste this content

/* hides the native tabs */
#TabsToolbar {
visibility: collapse;

/* leaves space for the window buttons */
#nav-bar {
margin-top: -4px;
margin-left: 74px;
margin-bottom: -4px;
Close firefox and reload.


Block Ads on Spotify for Macbook

In this post I will detail how to block ads on Spotify for Macbook using etc hosts file. Perfectly legal way to block ads.

Open the following -

sudo vi /private/etc/hosts

Add following lines.
Save the file

Enjoy your day!

If you would like to treat me for a coffee - venmo me @ankitshah009

How to run GUI applications with Docker on MacBook

For one of my recent projects where I am required to use Docker on Macbook, I had a hard time figuring out how to run GUI applications with Docker installed on Macbook.

1. Pull your docker image.

2. Install socat on macbook

Steps to install socat is "brew install socat"
Get Homebrew if you dont use it.

3. Run the following command in a terminal

socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"

4. Install XQuartz

brew cask install xquartz
open -a XQuartz

4. Find out the IP address you are connected to

ipconfig getifaddr en0

5. Run your docker container using the following command

docker run -it --rm -e DISPLAY=<ip address from previous command>:0 -v /tmp/.X11-unix:/tmp/.X11-unix <Your favoriet docker image>

Another command for non Macbook systems like linux servers

docker run -it --net=host --env="DISPLAY" --volume="$HOME/.Xauthority:/root/.Xauthority:rw"  <image name>

Efficient ways to use Amazon AWS services.

Use a better compression program.

sudo apt install pgiz

tar -c --use-compress-program=pigz -f {TAR File name} [PATH to tar]

Edit - I will keep this post updated as I begin to use more of the Amazon AWS services and discover faster ways to perform certain actions. 

How to get video or audio duration of a file using ffmpeg?

Today we will learn How to get the duration of a file using ffmpeg

1. Format Container Duration - [This works for both Video and Audio Files - better to report numbers using this command]

ffprobe -v error -show_entries format=duration \
  -of default=noprint_wrappers=1:nokey=1 input.mp4
2. Video Stream Duration - [This works only for Videos]
ffprobe -v error -select_streams v:0 -show_entries stream=duration \
  -of default=noprint_wrappers=1:nokey=1 input.mp4
Content author - 

iTunes hidden secret - Song Lovers

For all the song lovers out there using iTunes - there is a secret feature I want to share...

Go to Internet Radio - Under Library section of Music.

Top 40/Pop - Stream -

1. Top 40 Hits All Day.

2. GotRadio ^ Top 40

Who needs Subscription to Music service when ITunes is giving such an amazing song collection all day.

To checkout more Music collection - Look at my playlists -

1. YouTube Version

Hindi Songs - Best Collection

English Songs - Best Collection

2. Spotify Same list -

English Songs - Best

Hindi Songs - Best

How to print contents of any database file

  1 import sqlite3 as lite
  2 import sys
  4 def print_db_content(database_to_read):
  5         conn = lite.connect(database_to_read);
  6         cur = conn.cursor()
  7         #
  8         # Below query is equivalent to typing .tables in sqlite command line
  9         query = "SELECT name from sqlite_master where type = 'table'"
 10         tables_list = list(cur.execute(query))
 11         print tables_list
 12         for item in tables_list:
 13                 query = "SELECT * from '" + str(item[0]) + "'"
 14                 print query
 15                 cur = conn.cursor()
 16                 data = list(cur.execute(query))
 17                 for item1 in data:
 18                         print item1

 if __name__ == "__main__":
         if (len(sys.argv)<0):
                 print 'Usage: python [database_absolute_path]'               

Working effectively with iTerm2

I have been using iTerm in daily work for almost a year now. Along the way, I learned a few handy settings tweaks and shortcut keys to boost my productivity in command-line environment.

Install iTerm2

If you haven’t heard of iTerm, it’s a popular open source alternative to Mac OS X Terminal. Give it a try, download and install it from

Fine-Tune Settings

Launch iTerm, open iTerm > Preferences or just Cmd + ,.

Open tab/pane with current working directory

Under Profiles tab, go to General subtab, set Working Directory to “Reuse previous session’s directory”.

Enable Meta key

To enable Meta key for Bash readline editing e.g. Alt + b to move to previous word, under Profiles tab, go to Keys subtab, set Left option key acts as: to “+Esc”.

Hotkey to toggle iTerm2

Under Keys tab, in Hotkey section, enable “Show/hide iTerm2 with a system-wide hotkey” and input your hotkey combination, e.g. I use Ctrl + Shift + L.

Switch pane with mouse cursor

Under Pointer, in Miscellaneous Settings section, enable “Focus follows mouse”.

Handy Shortcut Keys

Here’s a set of shortcut keys I commonly use. You can always look for other shortcut keys in the iTerm menu.

Tab navigation

  • open new tab Cmd + t
  • next tab Cmd + Shift + ]
  • previous tab Cmd + Shift + [

Pane navigation

  • split pane left-right Cmd + d
  • split pane top-bottom Cmd + Shift + d
  • next pane Cmd + ]
  • previous pane Cmd + [
  • open search bar Cmd + f
  • find next Cmd + g

Input to all panes

  • input to all panes in current tab Cmd + Alt + i

Clear screen

  • clear buffer Cmd + k
  • clear lines (Bash command) Ctrl + l

Zooming / Font Resize

  • toggle maximize window Cmd + Alt + =
  • toggle full screen Cmd + Enter
  • make font larger Cmd + +
  • make font smaller Cmd + -

Macbook Keyboard Tips for Windows users

Original Post -

The three most important keys on your Mac can be found to the left and right of the spacebar (for right and left handed use). Unfortunately these three keys seem to cause more confusion than any others.

Using the Option or Alt key on a Mac

There is a great deal of confusion over what Apple referrs to as the Option key. If you'are using a UK keyboard chances are this is called the Alt key so it's no wonder most people don't know where it is.
The Alt (aka Option) key can be found between Control and Command. It has an icon that looks like a slope and a dip with a line above it.
Chances are the first time you hear mention of Option you are following a tutorial and trying to fix something on your Mac. The Alt key is the one you use if you wish to select a boot partition when starting the computer, you also press it when typing certain characters on your keyboard, such as # (Alt-3) or ¢ (Alt-4).
Here's an overview of the hidden characters that you can type using Alt (the keys might be a bit different if you aren't using a UK keyboard as we are).

You may be wondering whether you can use the Alt key ctrl-alt-delete to shut down an unresponsive Mac. Force quitting on a Mac is slightly different to on a PC, here's how to ctrl-alt-delete on a Mac, aka Force Quit on a Mac.

How to type €, #, … and © on a Mac

  • Alt-2 - Euro sign (€)
  • Alt-3 - Hash sign (#) (Sometimes called the 'pound' sign)
  • Alt-: - ellipsis (…)
  • Alt-G – copyright ©

You can also use Alt/Option to do the following:
  • Control-Alt-Command-Power Button - Quit all apps
  • Alt-Shift-Command-Q - Log out of your user account on your Mac
  • Alt-Delete - delete the word to the left of the curser
  • Alt–Left Arrow - move the curser to the beginning of the previous word, add Shift to this to highlight the text
  • Alt–Right Arrow - move the curser to the end of the next word, add Shift to this to highlight the text
  • If you are selecting large sections of text, you can do so by moving the curser to the end of the section you wish to select and pressing Alt-Shift-Up Arrow until all the text is selected. (This only works in some apps).
  • Similarly, Alt-Shift-Down Arrow lets you highlight the text below the curser
  • Alt-Command-F will open the Find and Replace feature if your application has it
  • Alt-Command-T will show or hide the toolbar
  • Alt-Command-C is the key combo to use if you wish to copy a style, or copy the formatting settings to the clipboard
  • And Alt-Command-V will paste those formatting settings onto the text you wish to change
  • Alt-Shift-Command-V will paste and match style - so that the text you paste in has the same style as the text around it, rather
  • than the style bought over from the place you copied it from
  • Alt-Command-D will show or hide the Dock at the bottom of your screen
  • In the Finder, Alt-Command-L is a handy shortcut to open the Downloads folder
  • Also in the Finder, pressing Alt-Command-P will show the path so you can see the precise location of what you are looking at
  • Alt-Command-S will show or hide the Sidebar in the Finder
  • Alt-Command-N will start a new Smart Folder in the Finder
  • If you select a few files in the Finder, you can press Alt-Command-Y to see a full-screen slideshow of those files
  • A shortcut to the Display preferences is to press Alt-Brightness Up (or Brightness Down, aka F1 or F2)
  • While you can open Mission Control preferences by pressing Alt-Mission Control (F3)
  • To duplicate/copy an item in the Finder or on your Desktop, press Alt while dragging it.
  • To create an Alias (a shortcut to a file) you press Alt and Command together while dragging the file from the location in the
  • Finder to another location, an arrow sign will appear indicating that this is a link to the file rather than a copy of it

Using the Command key on a Mac

If you thought that the jumbling of Alt and Option was baffling, there's even more opportuity for confusion when it comes to the Command key. The Command key (cmd) has a legacy that leads to confusion - many older Mac users will refer to it as the Apple key, because in the past there used to be an Apple logo on it, but this logo stopped appearing a while ago when if was decided that there were a few too many Apple logos on Apple products.
The logo you will still find on this key looks like a squiggly square, or a four petalled flower. It was designed by Susan Kare for the original iMac (and based on the Scandinavian icon for place of interest).

The Command (cmd) key works in a similar way to the Control key on a PC. On a Mac you use the Command key where on a PC you would use Control (or Ctrl).
If you were wondering why Ctrl-B didn't make your text bold, chances are you were previously a PC user and didn't realise that Command is the new Control. You might find this useful: How to move from PC to Mac: Complete guide to switching to a Mac from a PC.
Here are a few of the key combinations that use Command:
  • Command-B - Bold
  • Command-I - Italic
  • Command-Z - Undo
  • Command-Q - Quit
  • Command-W - Close window
  • Command-P - Print
  • Shift-Command-P - Page setup (for checking how it will print)
  • Command-S - Save
  • Shift-Command-S - Save As or duplicate the document
  • Command-A - select all

How to copy and paste on a Mac

  1. Select the text you wish to copy - a quick way to do this is to place your mouse pointer over a word and click twice. Once you have the text selected you can drag your mouse across or up, or down, to select more words. Alternatively, if you are selecting a number of words or sentences, or paragraphs, you can click at the beginning of the section, then press the Shift key, and click at the end of the section.
  2. Press Command-C to copy the text (or Command-X if you want to 'cut' the text from where it is currently)
  3. Go to where you wish to Paste the text in and press Command-V
  • Command-C = Copy
  • Command-X = Cut
  • Command-V = Paste

There are lots more useful key combinations that use Command including:
  • Command-F - Find 
  • Command-G - Find again
  • Command-H - Hide the windows of the app you are using
  • Command-M - Minimise the current window and send it to the Dock
  • Command-N - open a New document
  • Command-W - close the current window
  • Command-Space Bar - open the Spotlight search window
  • Command-Tab - to switch between open apps
  • Shift-Command-3 to take a screenshot of the screen (more about taking screenshots on a Mac here: How to take a screenshot on a Mac)
  • Command-Comma (,) - Open preferences for the app you are using
  • Command-T show or hide Fonts window
  • Command-Left Arrow -  move the curser to the beginning of the line
  • Command-Right Arrow -  move the curser to the end of the line
  • Command-Up Arrow -  move the curser to the beginning of the document
  • Command-Down Arrow -  move the curser to the end of the document (Press shift to select the text between the insertion point and the destination in each of these scenarios)
  • Command–Left Curly Bracket - Align Left
  • Command–Right Curly Bracket - Align Right
  • Shift-Command-| - Centre
  • Shift-Command-Minus sign - Decrease font size
  • Shift-Command-Plus sign - Increase font size
  • Shift-Command-Question mark - Open Help menu
  • If you are in the Finder or in a web browser, or any other app that supports Tabs, Command-T will open a new tab.
In the Finder you could try the following:
  • Command-D - Duplicate the file
  • Command-E - Eject the volumne
  • Command-F - Search
  • Command-I - Get Info
  • Shift-Command-D - Open the Desktop folder
  • Shift-Command-F - Open the All My Files folder
  • Shift-Command-H - Open the Home folder
  • Shift-Command-G - Open a Go To folder window
  • Shift-Command-I - Open your iCloud Drive
  • Command-K - Connect to the server
  • Shift-Command-K - Browse the network 
  • Command-L - Make an alias
  • Shift-Command-O - Open the Documents folder
  • Shift-Command-R - Shortcut to the AirDrop window
  • Command-Delete - sends the selected item to the Trash
  • Shift-Command-Delete - Empty the Trash (add the Alt key if you don't want to see the confirmation dialogue)

Using the Control key on a Mac

With the Command key doing the job of the Control key on a PC, what is the point of Control on a Mac keyboard, you may be wondering.
Content continues below
The most common use of Control is to mimic the right click on a mouse or when using the mouse pad (since some Apple mice don't have the right click option).
If you want more tips about How to right-click on a Mac read this.

There are many more uses for Control when used with other key combinations, for example:
  • Control-Command-Power button will restart your Mac
  • Control-Shift-Power button - puts your display to sleep
  • Control–Option–Command–Power button - quits all your apps and shuts your Mac
  • Control-H Delete the character on the left
  • Control-D Delete the character on the right
  • Control-K Delete the text from where your curser is to the end of the line
  • Control-A Move to the beginning of the line (more here: How to find End and Home on a Mac keyboard)
  • Control-E Move to the end of a line or paragraph
  • Control-F Move forward one character
  • Control-B Move backward one character
You can also use the Control key to add a document or folder to the Dock: Go to the Finder and select the item you wish to add to the Dock (or search for it using Spotlight: Cmd-Space, or select it on your Desktop). Then press Control-Shift-Command-T.

What do the F keys do on a Mac?

There are a few other Apple specific keys (depending on your keyboard):
F1/F2 - Brightness Up and Down
F3 – Mission Control (for an overview of all running applications, grouping windows from the same application, and your Spaces)
F4 - Is a shortcut to all the Apps you have on your Mac

F10/F11/F12 – Sound

You can set other F keys to do Mission Control actions. Go to System Preferences > Mission Control and add unused F keys to do functions such as Show Desktop or Dashboard.

How to type letters with accents on a Mac

Some letters can be typed with accents on top, like this é, ä, ö. This is easy to do on a Mac:
  1. Hold the letter down on the keyboard until a bubble menu with all the different options appears
  2. Each accent option has a number below it, tap the number on the keyboard to turn the letter into that accented version, or click on the accented letter with your mouse

How to type special characters, Emoji and maths symbols on a Mac

Emoji Characters on a Mac
You can use the Character Viewer to find special characters, Emoji and maths symbols.
Press Command-Control-Space and by default you will see the Emoji characters. To see the Character Viewer, with  special characters from any font on your Mac, click on the Character Viewer icon in the right corner of the window, or in the menu bar next to the time and date. 
Once you have the Character Viewer open, use the sidebar to view different categories, such as Currency Symbols or Maths Symbols and double-click any item in the main window to insert it into your document.
You can also search for any option using the Search field in the top-right. Enter a term like "cat" to find all the symbols that are cat-like.
The Character Viewer is placed permanently above all other windows, so you can continue typing in your app and view the Character Viewer on top of its document. You can switch between a small and large Character Viewer using the icon to the right of the Search Field.
It is also possible to add the Character Viewer as a Menu bar icon, this enables you to quickly access it from any app. Open System Preferences, choose Keyboard  > Keyboard and select the Show Keyboard & Character Viewers in Menu Bar option. Now you can click on the Character Viewer icon in the Menu bar and choose Show Character Viewer.

How do I add emoji on a Mac?

As we said above, just press Command-Control-Space and you will see a collection of Emoji you can use.
If you have the Character Viewer open you will find a section called Emoji in the sidebar.
Often it's easier to use the Search field in Character Viewer to find Emoji characters.
If you want to read more about using emoji this may be useful: How to use emoji

How to view shortcuts on a Mac

Use the Keyboard Viewer to learn special characters
One neat trick to learning keyboard shortcuts on a Mac is to use the Keyboard Viewer. Enable the Show Keyboard & Character Viewers in Menu Bar option (in System Preferences > Keyboard > Keyboard).
Now click on the Character Viewer icon in the Menu bar and choose Show Keyboard Viewer. A visual representation of the keyboard appears, and as you press keys they will be highlighted. If you hold down the Alt and Shift keys the Keyboard Viewer shows all the special characters on each key. You can use this to learn the special characters on each key.

Keyboard combinations for shutting down or Sleep your Mac

  • Ctrl-Eject = Show the restart / sleep / shutdown dialog
  • Shift-Control-Eject = Will put your displays to sleep
  • Command-Alt-Eject = Will put the computer to sleep
  • Command-Control-Eject = Save/Quit all applications then restarts Mac
  • Command-Alt-Control-Eject = Quit all applications then shuts down the Mac
  • Command-Shift-Q = Log out of your OS X user account (you'll be asked to confirm action)
  • Command-Shift-Alt-Q = Log out of your OS X user account immediately (you won't be asked to confirm action)
  • Command-Alt-esc = Force Quit
  • Command-shift-Alt-esc (for three seconds) = Force Quit the front-most application
Read next: How to lock a Mac

How to use the Application Switcher

Another handy key combo is the one that brings up the Application switcher. This is a handy way to move between different applications you have open.
  • Command-Tab = Move to the next most recently used application from your open applications
  • Command-Shift-Tab = Move backward through a list of open applications (sorted by recent use)
  • Command-~ (Tilde) = Move backward through a list of open applications (only when Application switcher is active)

Useful commands in Linux

View the job launched via process id
xargs -0 < /proc/<pid>/cmdline
Get the history of commands run from a user.
grep -e "$pattern" /home/*/.bash_history

How to find the files difference between two directories in linux and also
ignoring the extension?

comm -13 <(find dir1 -type f -exec bash -c 'basename "${0%.*}"' {} \;   
| sort) <(find dir2 -type f -exec bash -c 'basename "${0%.*}"' {} \; 
 | sort) 
Type the above command in one line.

comm -13 - will show the filenames unique to directory 2
comm -12 - will show all filenames common to both directories
comm -23 - will show the filenames unique to directory 1.

grep -F -x -v -f fileB fileA
Github change author name without edit 
git rebase -i HEAD~4 -x "git commit --amend --author 'name <email>' --no-edit" 

List of Packages to Install for Anaconda

Anaconda - Package manager used to install packages and run python as a user.

This means that you can run things on server without sudo priveliges.

Steps to installation

Download Anaconda

Run bash <>

List of packages to Install are as follows

conda install -c groakat lame
conda install -c conda-forge -y sox libvorbis
conda install -c jjhelmus tensorflow
conda install -c conda-forge matplotlib
conda install numpy pyyaml mkl setuptools cmake cffi
conda install -c conda-forge tqdm
conda install -c conda-forge libsvm
conda install -c geneko pp
conda install pytorch torchvision cuda80 -c soumith

How to use a scheduler - Torque - QSUB

Check the status of your jobs

qstat - lists all the jobs on the system.

Check status of jobs for a user
qstat -u <username>

Get all details about a particular job
qstat -f <job id>

Delete a job from queue
qdel <job id> 

Numpy Tricks

How to print/display the number in full in an array?
import numpy as np