Useful Keys

If you had asked me ten years ago, whether I find the keys we are going to talk about in this post any useful, I would have said NO. But ironically, I use them quite a lot these days and I cannot live without them as well.

Home and End Keys

If you program or do document editing a lot you will understand the importance of Home and End. There is no quicker way to get to the start and end of a line.

Ctrl + (Shift) + Left/Right Arrow

Ctrl + the arrow keys, can be used to move over words rather than characters. Can be really useful for programming and document editing. I cannot live without this. Just makes navigation faster and easier.

Using Shift along with this combination helps you select words rather than selecting characters as is the case with Shift + Arrow Keys

Page Up/Down

Again, for people who handle many lines of code on text editors and huge documents, there are no better friends than Page Up/Down. Scrolling can be the most annoying thing sometimes on the mouse and these keys work like a charm in these situations.

F2 Key

F2 is one of those keys you cannot live without whether you are browsing files in a file explorer or working in an excel. F2 can be used to rename a file or edit a cell swiftly. It is very handy.

Ctrl + Shift + T

This combination is extremely useful on browsers. They reopen closed tabs. The function may prompt you to ask if this is really that useful, but once you start managing tabs in the order of 10 to 15 or more, you will start realizing the need for it.

 

Those would be my top five. Of course the obvious ones like Ctrl + S for save; Alt + Tab for window switching; Super + L for locking the pc and just the Super key for entering into the search menu on Ubuntu are really important too. There are a lot of shortcuts that pertain to specific software and are really useful, but I wanted this list to be as generic as possible.

 

Advertisements

Stop Sound – Matlab

clear sound will stop a sound that is playing on matlab.

The sound command on Matlab (sound(some_variable,sampling_rate)) plays a sound based on the values in a variable and a sampling rate. But it almost seems like there is no way to stop it. You can, though, if you clear all the variables by typing in clear all. But that can be problematic as it will wipe out all the variables you are working with. The best thing to do instead, is to type in clear sound.

Listing absolute paths with `ls`

Normally when you list the files in your directory/sub-directory with the ls command you would get the paths to those files with respect to the current directory.

But what if you wanted to save this list and you wanted the absolute paths rather than the relative paths. Well it doesn’t strike you first but then when you know it, its like, “Oh its that obvious!”

So you do

ls -d $PWD/what_ever_you_are_trying_to_list

The $PWD gets filled with the path to the current directory.

Example:
ls work/*.md

might have yielded

work/this.md
work/that.md
work/something.md
work/someotherthing.md

But,
ls -d $PWD/work/*.md

would yield something like

/home/username/work/this.md
/home/username/work/that.md
/home/username/work/something.md
/home/username/work/someotherthing.md

Good Uses for Old Phones

We live in a day and age where mobile phones are as common as shirts and pants. There is a good possibility that a lot of good phones that are lying around in your house which can be put to good use. Here I list a few ways in no particular order. Some of these functions can only be performed by a smart phone, some by ordinary phones as well.

  1. Download Manager – If you have a slow wifi connection at home, your downloads might take a really long time to complete. If you have an old android phone lying around, you can install a torrent downloader on that and any sort of download manager that you need and start downloading. You might have some old memory card lying around as well. If that is the case, then well and good. You are all set for your download journeys. This is less power consuming as opposed to leaving your desktop on all the time as well.
  2. Timer – Timers come of good use in a lot of places. For example, in the kitchen; when you want to time your game time, tv time and so on. There is one good technique called the pomodoro technique that works based on the principle of concentrating for 20 minutes and then relaxing for five. Repeating this set three times and then taking a long break for 15 mins at the end of those three cycles. It can help you be more productive. I have tried it and it works. Use your old phones for that, you will save yourselves from the distractions of all the notifications from your current phone.
  3. Music Player – Your current phone may have a lot of space, but I am sure you would want more. Why not push all the music to your old phone and just have the hits on your phone. This works well if you don’t own an iPod and you probably don’t need to. An old phone works really well for this.
  4. GPS Device – How many times have you been frustrated with maps and GPS consuming your battery like crazy. Why not use an old phone for that. You don’t have to worry about your phone going out of battery at the end of the journey. Sure you can use your car charger but isn’t it less fussy to just forget about having to charge your phone all the time.
  5. E-Reader – If your old phone has a good screen you can use it as an e-Reader and save battery on your current phone.
  6. Backup Phone – When you have your old phone lying around for any use mentioned above. You will have it charged. This will come in handy when your current phone dies and you don’t have a power bank with you.
  7. Fitness Tracker – Install a fitness tracker that requires just your accelerometer and your GPS. You will again not have to worry about your battery draining in such activities.
  8. Donate It – Last but not least. Rather than just keeping in a shelf and letting it die, give it to someone who really needs it. You will have earned their love.

pushd and popd – File Navigation Gems

pushd and popd are two commands that are absolutely worth their learning time if you are in the business of using the command line on a regular basis on linux. One of the biggest hindrances of using a command line for file manipulation and such would be navigation between folders. Sometimes its might be a pain to navigate between two folders, even using TABs for auto completion. This is where pushd and popd comes in to the picture.

What this does, in short, is, create a stack containing the paths that you have traversed using pushd. You can revisit these paths using popd. Remember that this is a stack in all aspects.

A short intro on how a stack works, if you haven’t come across it already. Skip this paragraph if you know what a stack is. Stack is a data structure that is like a stack of books or a stack of biscuits or best, pringles. You can stack one item on top of each other, but you can only take the item on top. Logical  right?. You stack an item using push. As in, pushing a potato chip into a pringles case. And you take one out using pop. Of course, you can only take the one on the top, a position called the ‘top of stack’.

Example:

Suppose you are in your home folder (~). You move to another directory by typing,

Command: pushd ~/Documents/work-docs

This will give you an output with two directory listings. The first one is the directory that you have navigated ‘to’. The second one is the directory that you just navigated ‘from’.

Output: ~/Documents/work-docs ~

You can navigate to another folder with something like say,

Command: pushd ~/Downloads

Now you will have the following output

Output: ~/Downloads ~/Documents/work-docs ~

What this shows is a history of your past navigations, or a ‘stack’ of your previous directories. The top of stack being the left most. Now to go back one step to ~/Documents/work-docs/, all you have to do is type,

Command: popd

and it will give you the following output

Output: ~/Documents/work-docs ~

That would be a quick intro of pushd and popd. Have a good time navigating through your directories.

Compress, Split and Join Tar files – Linux

Creating a tar file and splitting it for storing it in cds, dvds or any other storage with small capacity.

Create a tarball and compress it using bz2 or gz compression algorithms by using one of the following commands.

tar -cvjf tarofsomefolder.tar.bz2 /home/someone/Documents/*
tar -cvzf tarfileofsomeiso.tar.gz some.iso

To split you can use the split command
split -b 4500M tarofsomefolder.tar.bz2 "tarofsomefolder.tar.bz2.part"

You can use both of them together in a single command by piping the outputs of the tar command to the split command,

tar -cvzf downloads.tar.bz2 ~/Downloads/* | split -b 4500M - "downloads-part"

To extract these split tar files together, you have to cat those individual tar files either by listing them one after the other or by using a regular expression that covers all of it and then piping the output to a tar extract command. Something like,

cat downloads.tar.bz2.part* | tar -xvzf -