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.

ls work/*.md

might have yielded


ls -d $PWD/work/*.md

would yield something like



Crossfade – The Smooth Operator

Do you have your crossfade on in your music player? If not, you should turn it on now. You are missing out some really good stuff.

Smooth Transitions from Song to Song.Β Crossfades create a really smooth transition from one song to another. That means that your brain also transitions much smoother, if you are sensitive to that sort of thing. Usually music producers add a crossfade between songs, themselves, in the mastering stage or during arrangement itself. But still, there are times when this maybe a good thing to have in your music player when you navigate to the next track maybe?.

Smooth Transitions between Pausing and Playing.Β Abrupt pause and playback can be annoying. You would understand what you were missing so far when you turn on Crossfade. When you pause and play a song without a crossfade, it can get glitchy as well.

But where this makes a huge difference is subconsciously in your brain. Have you tried suddenly halting from running? How did your body feel. So how do you stop running usually? If it was possible to go from 0 to 10 km/hr in an instant, would it be a pleasant experience? But that’s what happens in your brain when pause and play randomly without a crossfade on if you are actively listening to a song.

Easier to handle interruptions.Β A lot of us don’t like to be interrupted when we are listening to music. We soak ourself in the immense joy of tingling our basilar membranes with a spectrum of frequencies being activated in rhythmic fashion. That is a lot to turn off suddenly, to divert our attention to a pesky request from a friend asking for ten bucks, right? πŸ˜›

Well it can get a lot easier if you had your crossfade on. Trust me. It will definitely ease your irritation.

So, switch it on, and let me know how it went for you. πŸ™‚

My Experience With Laptop Batteries

I have been using laptops for about 8 years now. Just like everyone else, I have always wanted to make my battery last for a really long time. Not in terms of back up time, but in terms of how long it keeps working until I have to replace it. When I say working, I mean decently, with a backup time of at least about 20 minutes. But how many of us have had trouble with this. I would say most.

There are so many blog posts around, with so many ways to go about it. Some say, its better that you keep charging and discharging it. Some say, keep charging and discharging only between 40 to 80 percent. That would be around 3 to 7 times a day for someone who works on his laptop all day, depending on the laptop and the battery. How would that work out? I am not sure. Some say that it is better to just work without the battery when ever you can. So what is good and what is bad. Over the years, I have tried a lot to keep my batteries running the best way possible. So I wanted to list out some of the things that I do at the moment and why I do it. Maybe it could help you out. But if you don’t agree with any of it, let me know why. Maybe I can adopt your logic. But please talk only out of experience, and not based on things you have read. The reality is really different from the theory.

I work with my power supply connected all the time. I work on my laptop for about 10 to 15 hours a day. Typically, my battery lasts for about 2.5 hours. That would mean that I would have around 2 to 4 charge-discharge cycles a day assuming 2.5 hours to discharge and 1.5 hours to charge back up again. This would mean that my battery would last for only a year if I go around charging and discharging it. I did some investigation as to how my power supply works. I visited my laptop manufacturer’s forum and I found out that once the batteries are full, the supply gets directed away from the battery so I will not be overcharging it. I think this has helped me a lot.

I sometimes work without the battery as well. When ever possible. But there is a lot of fuss associated with that, so I don’t do that much these days. When you are done working and you want to pack up, you have to shut it down before you connect your battery. I don’t think it is a good idea to plug in the battery when the laptop is on. I don’t think I want to face the electrical mess that may happen. Most of the time, I like to have my laptop on standby, to continue working from home. I don’t like the trouble of booting up all my tools again. I don’t shut it down.

Standby’s are perfectly Ok. Some always shut down their laptops thinking giving it a rest would be a good idea. But when your laptop is on standby, only your RAM is being used. So its not really a big deal, unless you are thinking that you are straining your RAM. We leave our phone ON all the time, but we apply a different logic when it comes to the laptop. But also consider this, there is a theory that when you reboot your system, it actually puts more pressure on the electronic components than just being On all the time, because of the temperature changes that they go through. I shut it down once in three or four days probably. I work on linux and I have come to realize that going to a standby state and coming back up again does a few things specific to my hardware. So when I sense some hic ups, I reboot it. But coming back to the battery! Being on stand by consumes ~1 percent per hour on my laptop that lasts 2.5 hours normally when it is up and running. So if I leave my laptop on stand by over night, I would probably only lose about 10 percent..

If I discharge it, I discharge it. What I mean is that, once I let my battery discharge even a little, I count it as one discharge cycle, and I let it fully discharge. I wait for it to reach 25% and I start charging it back again, and continue using it with the power supply plugged in until I vacate the place. The reason behind this is the theory that the life of a battery is based on the number of charge-discharge cycles. Although some people refute that, I assume it is an active theory and just do it, and it works for me.

I saved the most important one for last. If you read any blog any where, you would see one aspect that is common to all of it. It is that Heat Kills your Battery. It is its worst enemy. So no matter what precaution you take and what you do, if your battery is unnecessarily heating up, you would definitely see some degradation in its health. The best way to prevent it would be to get a good cooling pad. “Oh, come on man. The laptop already has a fan inside. You think the makers of the laptop, who took into consideration all those design aspects would have forgotten this one?”. Eh, well I think, for a number of good solid reasons, that they do compromise on this (looks, weight,..). So I think we better do something about it ourself. Especially if you are from a hot city, which naturally provides a good environment for your batteries to heat up. 90% of the time, I run my laptop only on a cooling pad, and I think I am seeing a lot of difference. I think a good cooling pad has a lot of uses, the batteries are just one of it.

How do you treat your batteries? Let me know.


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.

Matlab – Without GUI – Part 1.5/2

I said I would return in a week or so to talk about my experiences with using Matlab without a GUI in part 1/2 of this series. I also said I would get back with a report on how debugging works in a command line environment because it could be pretty important for a lot of us. But it seems Matlab has a pretty good setup to debug using the command line. This is just awesome and I am so happy.

With the following commands, you will be well setup to do some basic debugging. You can refer the help docs for your specific needs. This will give you a quick review of what you can do.

Set breakpoints at different places in the script using dbstop. Mention the script name and the line number where you need to stop, using the following line of code on the command line. dbstop in scriptname at linenumber

Look at all the places you have used a breakpoint using, dbstatus. Just type in dbstatus in the command line and it will let you know.

When you are running the program, it would stop at the places where you have added breakpoints. When you are done analyzing your variables and what not, you can type in dbcont to continue execution until it encounters the next breakpoint, or the end of the program.

You can use dbstep to step one line at a time just like how you would with the GUI. You can also say something like dbstep 5 to step through five lines of code.

Remove breakpoints in a line or, all of it in a file or, all of it in all files using dbclear. dbclear all will clear all of it in all places. dbclear in script/filename will clear all breakpoints in a file. You can also add line number to remove something specific from a specific place.

Last, use dbquit to exit debugging mode.

For more interesting ways to debug, take a look at the help files. They have a load of information along with examples. You can use some of these commands with an if statement. Like for example, adding a break point when some condition is satisfied. This could be very useful. A lot of actual debugging does happen this way when you are working with a lot of code. Happy debugging.

It has not been one week yet. So I named this post 1.5/2. You can only really get a good picture of things over time. So it is not just a sensation but rather the actual fact. I will be back again in a week or so with my conclusions.

Matlab – Without GUI – Part 1/2

Matlab can be invoked without its GUI on linux systems by typing in the following on the terminal.

matlab -nodesktop

This opens up matlab just like an Octave or Python prompt on the terminal. What is the use you may ask. You might be perfectly happy with the IDE like environment. But personally, there is something nice about using the terminal. Less fuss and more work. Makes you feel at home. If you are like me. Then you should try it.

I can use vim to edit my scripts. I can run my matlab scripts by typing in run scriptname.m. I can see all the variables by typing in who. I can see all the details of the variables by typing in whos. It gives me the type, shape and name of the variables. I can just type in the name of the variable to print it out.

Wouldn’t that be ‘a lot’ of what we would require? It feels really similar to using python scripts with scipy and numpy packages for signal processing. Sometimes I am using vim even when i am using the Matlab GUI as well. I use the gui just to run the code and look at the variables.

Wouldn’t it be possible to just use a text editor and then run the code alone on the terminal without starting up matlab in the first place? Yeah, technically Yes, with some other arguments you can do that. But every time you run it, matlab seems to load everything and you’d probably have to wait ten to twenty seconds for an output. That is not efficient.

Yeah, line by line debugging would also be really helpful sometimes. I will see if there are any workarounds for that, by the time i write part 2 of this blog. I will work with this for a week or so and get back with some updates about whether I am going to continue using it this way.

My Affinity Towards DVDs

In the age of the cloud, pen drives and external hard disks with huge capacities, a DVD might seem so obsolete. I might be among very few but, I still love DVDs. Reasons below.

1. It is cheap. 15rs for 4.7 GB of data. Doesn’t get better than that when you want to quickly share something to a friend. If it is meant to last anything less than two years, you can even get a DVD for 10 bucks.

2. It is secure against viruses. Say you have some database that needs to go through couple of computers. In a flash drive, this could potentially meanΒ  adding viruses from each of these computers if they are windows machines. Annoying!. Doesn’t work if you have the virus laden pc though. Haha.

3. As sort of an USB drive. With the proper settings, you can use a DVD as ‘sort’ of an usb drive. Adding data to it each time. You cannot erase and make use of that space, but you can make it disappear.

4. Sort of Stable. If you have the habit of storing stuff on pen drives. If you use them as backup. Please, stop. That might be the worst thing you can do. You might have better luck with a dvd. Pen drives can fail in a lot of scenarios. Even as simple as one hasty moment where you pluck the drive out of the port.

Now, I know that this post may seem a little out dated. But there are scenarios in which DVDs can be really helpful. That is why I always have a few with me all the time. Lets see a couple of those scenarios.

Scenario 1: You meet a friend after a long time. He sees that you have a bulk of old photos that he wants to have. This friend lives in a remote area and does not have good internet. DVD time! It will cost you probably 45 bucks to transfer all of your photos. Assuming you have around 12-14GB of photos.

Scenario 2: You have an iso file that someone wants. Someone who does not have good internet. Plus, you know that he is not the ‘pen drive returning’ type of person.

Scenario 3: You don’t have a printer and you usually print it out in a cool shop near by that prints on the cheap. But problem is that, it has one pesky computer loaded with viruses. You will be safe to use a pen drive if you are on linux. But if you are on windows, maybe a dvd might be a really cool way to stay safe and get the job done at the same time using point 3 mentioned above.Β  Since documents are really small in size. You could end up using a dvd for the next 10 to 50 times maybe! For 15 bucks, Yes.

So, do you like DVDs? Let me know.

I may have left out just one point in my list. So let me add that here,

5. Its vintage. There is something nice about vintage stuff. You know, if PCs still come with floppy disks, I might probably use it to store code that can fit in it. There is some good feeling about it somehow! Partly because, it brings back old memories of me meddling with windows 95 and windows 98. You had to boot with a boot floppy disk you know? You needed a separate boot disk. It was amazing. And what about using a walkman, or using a discman or a boom box? Yeah, there is a certain flavor to using those things.

As a final warning. There are some really bad disadvantages of using a DVD as well. Things like, being prone to scratches, having a limited lifespan, sensitive to storage conditions, lack of support of newer laptops and so on. So know what you are getting into. πŸ™‚