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.

Advertisements

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. 🙂

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.

Gnome and Unity vs Cinnamon and MATE

Gnome and Unity desktop interfaces go for a similar approach while Cinnamon and MATE do the something similar. There is a good contrast between Team 1 and Team 2. But little contrast between members of each team. Remember that, when ever I use the term Gnome, I mean Gnome 3.

Team 1

Gnome and Unity are similar in the fact that they both try to address laptop users. They are good interfaces when you want to reduce the trackpad usage. For some, using the trackpad slows them down. Both Gnome and Unity use the Super key to launch applications and for bringing up the dock and a lot of other things. You can do a lot of things without the trackpad. The buttons in these DEs are usually bigger than those in the DEs in Team 2. Their interfaces also seem to have lesser readymade options in all the places. Settings, Context Menus, etc.. If I have to pick one between these two, I would pick unity because it just seems to do something better than Gnome. Maybe it is just that, since Gnome seems to be the most popular desktop environment, I have higher expectations for it. Sure you can tweak a lot of things, but I do not have the patience for it. So how much would I rate these two environments.

Gnome – 6/10
Unity – 7/10

Team 2

Cinnamon and MATE do similar things. They are really good for dektops and laptops that are being used like a desktop, with auxillary keyboards and mouse and all that. MATE is a fork of Gnome 2, the older version of Gnome, which used to look a lot like how MATE looks right now (The first Linux OS that I started using was Fedora 13 which had Gnome 2). But I cannot seem to remember how it differed though. MATE is really good if you want to get things done, and you do not mind how your desktop looks. It is lightweight and slick. You can notice it when you switch from Gnome to MATE. Apps open faster and there is this snappy feeling to it that I cannot deny. Keep it simple is the name of the game here. I would recommend it on old systems for sure. In contrast, installing Gnome on old systems is not advisable at all I would say.

Cinnamon on the other hand has become my recent favourite. It is especially nice on desktop and lap-desktops (laptops that are used as desktops sometimes. Just pulled that out of thin air, haha. Maybe it is already a word). They seem to have done everything right on it. The size and aspect ratio of every button, every icon, the task bar, the menus, the file manager(nemo), the text editor(xed), the terminal etc. The design decisions have been perfect. I am all praise for it. I havent spotted a single bug so far after a week of good use. Probably KDE might be the only thing better than it, but I wouldn’t know, because I have no experience with KDE apart from looking at it on youtube videos. Never had the interest somehow. Maybe some day. So rating.

MATE – 8/10
Cinnamon – 9/10

Again these ratings are subjective. I have specific needs. Namely,
1. It needs to work well with a mouse-keyboard interface, but should be good enough on a keyboard-touchpad interface as well.
2. Needs to use all the screen space efficiently. You have limited space on a laptop or a desktop with a smaller screen.
3. It needs to be snappy.
4. The most used options should be available readily. Like in the context menus and the task bar.
5. Needs to come with a good bundle of finely crafted basic software that are properly tested on its desktop environment.
6. Visual treats are good, but not at the expense of a lot of processing power.
7. Must be all this, right out of the box.

A point to note. If you want to properly experience a desktop interface, you must look for that particular spin, and then use that to determine how good it is. If you install cinnamon on something that already has Gnome 3 on it for example, chances are that, you will not have a good time and you will not appreciate it as well. For example, If you want to experience MATE, look for Fedora MATE, it was good. If you want to experience Cinnamon, look for Linux Mint with Cinnamon. If you want to experience Gnome3, you have a lot of options. A lot of distros come with Gnome3 as the default (which actually surprises me).

Thanks for reading! 🙂

Fedora to Linux Mint – Major Switch

A major switch requires a major blog post. This will be a long one.

Five days before I changed my OS. I switched from Fedora – which I had been using for a really long time (i think five years) – to Linux Mint. Had a lot of thought, before choosing Linux mint. But in the end I did go for it. In this blog I talk about why I moved.

Linux is all about options. There are so many distributions out there that sometimes, it is not wise at all to keep browsing the web for new distributions and features. Because you will definitely get sucked in and want to switch. If all your work is in the cloud, then I think switching should not cause much irritation to you. Or if you are trying out distros on a virtual box. But if you are like me, with loads of post installation work to be done after getting a new OS, switching is not really a walk in the park. Sometimes it can be really frustrating. So, the point is, do not switch, unless you really have to or something about your distribution really bothers you. With that said, I was accumulating my grievances for a long time before I made the switch. I want to list those here.

Package Manager/Packages

Although dnf is really good and i liked it a lot more than apt because of the really nice way it summarizes the things you are going to install, i recently found out that there is a HUGE difference between the number of debian packages compared to rpm packages. This literally means that I will have more of the software that the rest of the world has been using under the debian/ubuntu umbrella.

I am not sure why. But there was a time when I had a lot of trouble installing a simple virtual box on fedora. Not sure what I did wrong. But I did not spend time on it to find out what happened. I left it after that. It could be my lack of knowledge.

Policies

There are a lot of policies that red hat based systems seem to have that hinder the installation and support of drivers and software. I am not really clear about this. But it annoyed me a lot in a lot of instances and, unless you are a sys admin, I think it is not worth to go learn these things as well. I did not have this much trouble with the ubuntu machines at work. The word SELINUX brings a lot of stress to me.

It was one of those things that bothered me a lot. I was installing a LAMP stack on a fedora machine to build a web app once. Through the period of time while I was developing this app I had a lot of SELINUX related stress. It took me a lot of time to learn those things. Although this is a good thing to do, I felt it was not necessary for me. I guess I wasted a lot of time on it.

Desktop Environment

Although gnome is the most widely used Desktop Environment for linux machines, I feel it might be the worst as well. I felt bloated when I was using gnome. I also felt that it is not suitable for a desktop or a laptop used as a desktop, as in my case. Why do I say this? Because of the design decisions they have made. Large proportions given to the menu bar and icons and everything, that use up valuable space on the screen. It felt like working on a laptop with lower resolution sometimes.

I switched to MATE Desktop sometime back on fedora itself, since it was a light weight alternative to Gnome 3, which was default with Fedora. It was really good. I liked it. It was in fact a fork from Gnome 2. But then, there is something I have noticed with desktop environments. I feel it is not a good idea to install a second desktop environment. It is a lot of work to make it look like as if you downloaded the Fedora MATE spin itself. I found the Fedora MATE spin to be more stable than the Fedora Gnome edition onto which MATE was installed. Similar thing happened when I installed cinnamon on my Fedora Desktop at home. Not a good idea. There is something missing. What I’m saying is: Download the distro with its native desktop environment to reap the most stability out of it, because I think that is where most of the focus is going.

Updates and Support

When someone says fedora, the word that comes to my mind is ‘cutting edge’. Fedora focuses on providing its users with all the latest technologies. But the downside of this is that it also stops supporting older OSes in 13 months. This bothered me a lot. By the time you get adapted to one, people are already on the next one. I did not like this. I was more of a Long Term Support guy. Took sometime for me to realize this.

Ubuntu does this, with its Long Term Support editions. But the linux mint folk are offering support till 2022 for the OS I am using right now. Linux Mint 18.2 Sonya. That is just amazing. If you are looking for something stable and you want to sit on it for a long time and most of your software are old anyway, then this is it!

User Experience

I tried linux mint via a flash drive a long time back (maybe 2/3 years?) and it was not something special. Just thought that it felt like a linux that looked like windows. I read somewhere recently that the linux mint community is focusing a lot on its cinnamon desktop and user experience. I sampled the new 18.2 version and it was SO evident. So many design decisions taken just right. Nothing more nothing less. You just feel the professional desktop feeling oozing out of cinnamon. I love everything about it, right out of the box! The way a company sets its default values for first use speaks a lot about their design team, I always say. Linux Mint with Cinnamon is just a very usable distro right out of the box.

The file manager Nemo is so good, compared to Nautilus which is the default in Gnome 3. It is miles ahead in terms of user experience. Again, right out of the box.

I also installed virtual box and installed windows on it and it runs really well.

Please do not get fooled by the fact that some people say, mint is for beginners. No. It is rather for people who want to focus on their work and worry less about the rest.

Conclusion

Decide what you want from a distro before you make a choice. Different distros do different things differently. Make a choice as to what is important for you and what is not. Do not ask your friend for a suggestion with a question like “Hey what is the best distro out there”. No that is not the right question. The question is “Hey, what do you think is the right distro for me” and tell him your needs. The more accurate you are with these requirements, the more closer you will be towards finding the right one.

Almost all major distros are great. It just depends on what you want.

NTFS and Linux – An Annoying Relationship

Very recently I wrote a blog about getting rid of FAT32 file systems because the maximum file size that it can handle is 4GB. Read it here if you are interested.

By the end of that blog I had decided that I would move to either ext4/NTFS and get rid of FAT totally. ext4 was only for linux and is not compatible with windows. NTFS on the other hand is compatible with windows and linux. I started off by copying stuff off my 16GB FAT32 pen drive and loading it on my laptop, to format it into an NTFS drive, so that I can load it all back again. I was done with this process in half an hour. Then I noticed something, all the files and folders in the drive had weird (read, write, execute) permissions now. Everything was a 777 (rwxrwxrwx). Meaning, every file had permissions to read, write and execute for user, group and others. That was an irritating sight to see on a terminal.

A little searching,  and I realized that, although NTFS has a much bigger file size limit, it does not retain permissions from a linux system. Uff! That was really disappointing. It was still possible to maintain permissions, but it was a long process and I was not going to complicate my life for basic backup and file transfer. I had to do some thinking and I realized that the best way to handle this was to use ext4 along with FAT32 and NTFS, in some fashion so I get the best of both worlds. So this is what I decided for the two 16GB pen drives and one 1TB hard disk I have for work.

  1. One of the 16GB pen drive would be turned into an ext4 system for use with Linux and also for those big files. Since most of the computers around me use linux, it would not be much of a problem and I do not want any pesky virus filled windows users to use my pen drive either.
  2. The other 16 GB pen drive will remain FAT. To be compatible across all machines. It would not be able to handle huge files but who’s handling huge files all the time.
  3. The 1TB hard disk would be split into two drives
    1. 800GB ext4 for use with my machine and other linux machines if required. Again to avoid virus laden windows users and their machines. (It is pretty simple to clean off viruses from a linux system later on though. But it needs some work. Maybe I will talk about it in some other post)
    2. 200GB NTFS for use with windows if required anytime in the future. A big portion, but I thought it might be required somehow.