## PowerShell keep printing 1 before expected output

By | 2017-05-15T10:26:40+00:00 May 15th, 2017|languages, Scripts|

I had written a script to parse the contents of a URL and store the contents in a SQL Server table. The script has a couple of write-host commandlets to track the progress of the script. Here is a snippet of the script. [crayon-5ae275f78067c326002988/] However on executing the script, before the write-host commandlet a couple of "1" would be written in the console. I had nowhere written in the script to write "1" to the console! On having a closer look, I realized that the SqlCommand.ExecuteNonQuery method was the culprit. Here is why. As per the documentation, the return value of SqlCommand.ExecuteNonQuery method will always be the number of [...]

## How to convert multiple matrices into one single vector in Python?

By | 2017-04-24T20:38:51+00:00 April 24th, 2017|languages, python|

This is a quick post on how to convert multiple matrices into a single vector using Python's numpy package. To begin with let us define 2 matrices. [crayon-5ae275f789a6e151666777/] What we want to do is to merge the contents of mat1 and mat2 into a single vector. To reach that goal first we need to convert each of them into vectors. For this we will make use of Numpy's reshape. [crayon-5ae275f789a7d690497951/] The -1 value for the newshape parameter of reshape ensures that the output has only 1 dimension. A matrix with 1 dimension is called a vector, which is what we want to achieve. Now that we have flattened both the matrices, we can merge (concatenate) [...]

## Move panel to the top on Linux Mint 18

By | 2017-04-18T12:05:27+00:00 April 23rd, 2017|Linux, operating systems|

Linux Mint is a very stable operating system for Desktops and I personally use it on my laptop. However I like Ubuntu GNOME's panel on the top feature. In this post, I will quickly show how to move Linux Mint's panel to the top of the screen rather the default at the bottom of the screen. Here is how the Panel looks like on Linux Mint 18 Cinnamon Desktop edition. The panel is at the left hand bottom. To move it right click anywhere on the panel and click Modify Panel. Next click on Move Panel option. Now the screen turns little greyish and you are given [...]

## How to find out the recently installed package on Ubuntu/Linux Mint

By | 2017-04-17T15:34:21+00:00 April 22nd, 2017|Linux, operating systems|

On many occasions I tend to install and try out new packages on Ubuntu/Linux Mint. If the operating systems does not work as expected I usually check which was the last package that I had installed or on what date a particular package was installed. In this post I will share few commands that I use to get this information. APT and apt-get are very powerful commands which works with Ubuntu's Advanced Packaging Tool (APT). The following command gives us the list of all the packages installed [crayon-5ae275f78b80f692269767/] As you see in the following output it does not give the details of the date installed, hence the output cannot [...]

## How to copy files in Ubuntu and skip files if they are already in the destination

By | 2017-04-17T06:43:43+00:00 April 21st, 2017|Linux, operating systems|

I usually backup my work to an external hard drive. Since this is a weekly task, I want to be able to copy only the files which had changed in the past week rather than copying all the files all over again. The file explorers in Ubuntu/Linix Mint are very stable but the GUI does not have an option to meet this requirement of mine. Thanks to the CP command I am able to get this done. Here is the command that I use. [crayon-5ae275f78d819310710268/] The parameters used with the CP command mean the following. -r copy directories recursively -u copy the source file only if the destination [...]

## How to resolve time differences after dual booting Windows 10 and Linux Mint 18

By | 2017-04-16T21:14:48+00:00 April 20th, 2017|Linux|

I use Linux Mint 18 as primary operating system and sometimes boot to Windows 10. Since both of these operating systems are installed side-by-side, I boot to them using dual options in grub. Every time I boot to Windows and boot to Linux Mint or vice versa, I faced a strange problem. On Linux Mint, the system time would jump by few hours however if I check the Date and time settings, the timezone is correct represented. After troubleshooting this for sometime, I noticed the following. Ubuntu by default maintains the realtime clock in UTC time Windows maintains the realtime clock in Local Time Hence the [...]

## Using PyCharm with Anaconda Virtual Environments

By | 2017-04-15T20:37:34+00:00 April 19th, 2017|Linux, operating systems, python, tools|

If you are regular reader of my blog, you would have noticed that I use Python mostly in Anaconda virtual environments. PyCharm is my favourite IDE for Python. Now the question is does PyCharm support conda environments? Fortunately the answer is Yes! In this post I will walk through the settings in PyCharm so that you can chose the right conda environment. Launch PyCharm and navigate to Settings --> Project Interpreter. If you click on the dropdown arrow, it should list all the interpreters currently available on the system which also includes interpreters from conda environments. If for some reasons you don't see the desired interpreter [...]

## Finding the dot product in Python without using Numpy

By | 2017-04-18T12:16:20+00:00 April 18th, 2017|machine learning, python|

In Deep Learning one of the most common operation that is usually done is finding the dot product of vectors. In very simple terms dot product is a way of finding the product of the summation of two vectors and the output will be a single vector. This Wikipedia article has more details on dot products. The following formula should make it clear where $latex \vec{X}&s=1$ and $latex \vec{Y}&s=1$ are vectors. $latex \vec{X}=(x_1,x_2...x_n)&s=1$ $latex \vec{Y}=(y_1,y_2...y_n)&s=1$ then the dot product formula will be $latex \vec{X}.\vec{Y}=(x_1y_1+x_2y_2+...+x_ny_n)&s=1$ Here is an example of dot product of 2 vectors. $latex \vec{X}=(6,5,4)\vec {Y}=(3,2,1)&s=1$ so $latex \vec{X}&s=1$  dot $latex \vec{Y}&s=1$ will be $latex \vec{X}.\vec{Y}=(6*3+5*2+4*1) = 32&s=1$ Finding the dot [...]

## How to install PyCharm on Ubuntu

By | 2017-04-15T12:39:01+00:00 April 17th, 2017|languages, python, tools|

Pycharm is my favorite IDE for Python especially its feature rich debugger. This is a quick post where will be installing PyCharm on Ubuntu. Let's first download PyCharm Community Edition installer to the desired location where we want to have PyCharm installed. I had chosen ~/pycharm folder. Next we will extract the archive using the following command [crayon-5ae275f796456466091399/] In the terminal navigate to the folder where the pycharm.sh file is located, in my case /home/pradeep/pycharm/pycharm-community-2017.1.1/bin. Then execute the following command in the following terminal. [crayon-5ae275f796463557076596/] If you just execute pycharm.sh you may encounter "command not found error". So make sure to enter the command with the "./" along with [...]

## Find battery usage details from Ubuntu terminal

By | 2017-04-13T21:59:06+00:00 April 16th, 2017|Linux, operating systems|

Requirement I usually connect to my laptop using SSH from my workstation. At times I need to check the battery remaining on the laptop. In order to do this I need to remote desktop into the laptop. Since this is a small task, I don't want to remote desktop to the laptop every time. Solution There is no doubt that the Linux Terminal is very powerful. In this case as well I can get the battery information right from the terminal. Upower is what we will use for this task. [crayon-5ae275f79920a960582567/] Executing the above code will enumerate and list the power devices attached to the computer. Here [...]