Monday, November 30, 2015

Renew or release DHCP IP address

Recently I had an issue with the network on one of my test machines. After some debugging and some help, we figured out that the DHCP IP address needed to be released and renewed. 

I ran the following command:
sudo dhclient eth0

Wednesday, October 21, 2015

Search for results excluding a word

To search for something excluding a certain word or phrase, use
grep -v "word" <file or location>
For example, the results of a grep search can include a lot of results which are not relevant. Eliminate those by using grep -v

 grep "blah" filename | grep -v "foo"

This will get you results with "blah" but nothing with "blah" and "foo" in them. 
 
 

Wednesday, August 12, 2015

Get public IP address of your computer

Open up the Terminal Application and run the command below to get the public IP address of your computer
dig +short myip.opendns.com @resolver1.opendns.com

Reference:
How to find my public IP address from command line on linux

Monday, August 3, 2015

Getting backtrace from qemu-kvm crash

When I'm running automated tests, qemu-kvm sometimes crashes and this needs to be debugged ASAP. To file a bug, I need a backtrace. As part of the test, the core which is dumped is saved.


  1. SSH into the machine where qemu-kvm crashed
  2. debuginfo-install qemu-kvm => This should install a bunch of packages to get a lot of symbol info. 
  3. gdb /usr/libexec/qemu-kvm <path to core file>
  4. Pass "thread apply all bt" to get the backtrace at the gdb prompt

Thursday, July 30, 2015

./configure options

When building packages, often we need to run ./configure with a bunch of options to build the package. To find out what the last options were used for configure, use this command:
./config.status --config

How to remember ./configure script arguments a year later

Monday, July 13, 2015

Execute a command, display output and get it's return code in Python

Often in my tests, I need to display the output and use the return code of the command I want to run. But I can't use check_output because my tests need to support RHEL6 and RHEL7 and RHEL6 is still on python 2.6.x and check_output is only available in Python 2.7

The following code snippet is modified from another website:

from subprocess import Popen, PIPE
 
cmd = "blah blah"
process = Popen(cmd.split(), stdout=PIPE)
process.communicate()    # execute it, the output goes to the stdout
exit_code = process.wait() # when finished, get the exit code


Thursday, July 2, 2015

Access Environment Vars in Python

To access environment variables in Python, import os module and run the following command
import os
print os.environ['ENV_VAR_YOU_WANT']

Monday, June 29, 2015

Combine 2 commits into one and update pull request

Finally, I was able to combine 2 commits into 1 commit and update the pull request. This will save me lots of time instead of creating a new pull request everytime and re-do work.

First time:
git clone <my-clone-of-upstream-repo>
cd <upstream-repo>
git remote add upstream <upstream-repo>
git config --global push.default simple
When starting a new pull request:
git checkout -b <new-branch>
Make changes, commit and send pull request. 

When combining n commits:
git fetch upstream
git merge-base new-branch master => This will generate a commit hash
git rebase --interactive <commit hash>
Your text editor will open with a file that lists all the commits in new-branch, and in front of each commit is the word "pick". For every line except the first, you want to replace the word "pick" with the word "squash" or "fixup". Save this file. 
git rebase upstream/master
git push -f

Thursday, June 11, 2015

Start vim without .vim settings

In my .vim settings, I have audo indent and smart indent enabled. Sometimes when I'm copying code, this causes the code to completely go wonky.

So, to avoid this and just copy the code, I disable the vim settings and open the file using
vim -u NONE filename
 

Wednesday, May 27, 2015

Restarting gnome-shell

Often, my desktop will get stuck into a weird position - particularly when I plug in and out of my dock (multi-monitors). Restarting gnome-shell fixes the problem.

You can restart the gnome-shell by pressing Alt+F2 and then typing in either "restart" or just "r" and pressing enter

Tuesday, April 28, 2015

Commenting a block of code in vi

Many times, when modifying code or debugging, I comment out blocks of code. This is tedious to do manually.

I searched around for a way to do it fast and came across this tip:

For commenting a block of text is almost the same: First, go to the first line you want to comment, press CtrlV, and select until the last line. Second, press ShiftI#Esc (then give it a second), and it will insert a # character on all selected lines. For the stripped-down version of vim shipped with debian/ubuntu by default, type : s/^/# in the second step instead.

Thursday, April 16, 2015

Use a specific repo for installing a package

I was facing an issue at work today where I needed to install a package from a repo. The repo for that package had been created in yum. However, one of the other repos had an issue where the url for that repo was not reachable and this caused "yum install" to fail for me constantly. 

 So I wanted to a way to install my package from a particular repo and not involve any other repo. The only way I found to do this is to disable all other repos and enable only the repo I want and install the package from it. 

To do that:

yum --disablerepo="*" --enablerepo="reponame" install pkgName

You can substitute reponame and pkgName with the names of the actual repo you want to use and package you want to install.

Wednesday, April 15, 2015

Syncing a fork of github

I use github for my work and have a fork of some repositories. When I send a pull request, often I have issues with my fork being out of sync with the main repository.

Today, I synced up my fork without any issues. Here's how I did it.

Go to folder which contains the clone of of your fork.

git remote add upstream https://github.com/upstreamreponame/repo.git
git fetch upstream
git checkout master (to make sure you're on master)

If you want to make sure these changes don't show up as a checkin on ur fork:

git merge upstream/master

This worked great for me!


References:
Syncing a fork
How to update GitHub forked respository
Updating a fork directly from github

Tuesday, April 14, 2015

Welcome to my blog!

Hi!

I'm a QA Engineer and a tech nerd. I love testing and automation. I love my Mac and my iPhone. I love checking out new websites and apps.

I like learning new things everyday and would love to share what I learn every day.

Hope to see you all around!