Thursday, December 8, 2022

SNIP vs Mspaint - which one is better for taking screenshot

Hey readers, 

I think its damn simple, no blog needed. Still, I thought to pen this down.


If you need to take a screenshot on a page, where you have a dropdown or any ajax-event called; something like on the Indian-railway-portal side, where you can search for the list of running trains between two stations- like below


You definitely have to use mspaint - Windows +R -> mspaint


Can you take the above using any other tool like SNIP, I doubt. Try on your own.


For the remaining cases, snip is definitely better - its lightweight, cropped image automatically gets copied, user can edit, highlight texts and so many other features.


Happy screensaving.

Saturday, July 20, 2019

Git, gitlab and the saga of merge-conflicts

I have been using git for version control for sometime. And as all the software developers around are aware of this fact - to get a merge conflict during the final days of the release-cycle is very common in today's fast business world. Here I will try to list some steps, which if followed regularly, will reduce the chances of getting a conflict during code-merge.

My guidelines

1. Take frequent code updates, this will ensure you are receiving the latest changes in your codebase from all other developers.

$ git pull

2. Before creating a pull-request, get all the changes from the destination branch to your local branch.

$ git pull
$ git add your-file/files
$ git commit -m "your message"
$ git merge origin/release-branch-name
$ git push origin your-branch-name

The fourth step from the above is the most important - you try to get all other code-changes from the release branch to your local branch. 4th and fifth steps can be interchanged, but after git-merge, if you find some changes in the code, you should always push it. Else the same story of receiving a code-conflict can happen later. After the final push to upstream, create the pull request.


Some typical cases

Case 1 - You working on your branch, you finished coding and testing, want to merge your changes to release branch

This is what is described in point 2 above, stick to that guideline.


Case 2 - You were about to finish your current work, your manager asks you to look into another critical issue. You finish that critical task first and come back to your old work.

This also should be a cakewalk, if you follow point 2 above. Commit changes in branch-one first. Checkout the critical branch, finish the code, push changes and create the PR ( request to merge to release branch) Come back to your old branch, finish the work, take a pull, merge with release branch, and a create a PR for your branch to release.

Gradually with time, you can master the art of using git for version control. Keep in mind the four kinds of files under git - unstaged, staged, committed and stashed. Git is now the most widely used version control tool in the software industry. And if you are using it at work, you should have more commands on it.

External links

1. https://git-scm.com/docs/gittutorial

Saturday, July 16, 2016

Column to Row Conversion in Oracle

While working on your SQL queries, did you ever face the challenge of transposing your set of columns to a set of rows in your work? As in like changing the direction of a text "I Love my Family" from reading row-wise to reading column-wise (see screenshot below).




Then this post will definitely prove meaningful to you.


Solution

The crux behind the solution is to use rownum feature of a table, rownum inherently numbers the rows returned by a select query as 1,2,3,4 etc. For the sake of this particular problem, you can take any table from the list of your your database tables which has at least 4 records in it, but we will use this Oracle table:  USER_OBJECTS .


Run the following query to get a feeling

Select rownum as rown from user_objects   where rownum <= 10 ;


Building the set of queries for the problem straightway ...


Query1
 Select   'I Love My Family' Str  from  dual  ;



Query2
 Select  Substr ('I Love My Family', 1, instr('I Love My Family', ' ', 1, 1)-1) str1,
         Substr ('I Love My Family', instr('I Love My Family', ' ', 1, 1)+1, instr('I Love My Family', ' ', 1, 2)-instr('I Love My Family', ' ', 1, 1)-1) str2,
         Substr ('I Love My Family', instr('I Love My Family', ' ', 1, 2)+1, instr('I Love My Family', ' ', 1, 3)-instr('I Love My Family', ' ', 1, 2)-1) str3,
         Substr ('I Love My Family', instr('I Love My Family', ' ', 1, 3)+1) str4   
 from dual ;




Query3
Select   decode (rn, 1, str1, 2, str2, 3, str3, 4, str4) Str_Name  
 from  (
        Select  Substr ('I Love My Family', 1, instr('I Love My Family', ' ', 1, 1)-1) str1,
                Substr ('I Love My Family', instr('I Love My Family', ' ', 1, 1)+1, instr('I Love My Family', ' ', 1, 2)-instr('I Love My Family', ' ', 1, 1)-1) str2,
                Substr ('I Love My Family', instr('I Love My Family', ' ', 1, 2)+1, instr('I Love My Family', ' ', 1, 3)-instr('I Love My Family', ' ', 1, 2)-1) str3,
                Substr ('I Love My Family', instr('I Love My Family', ' ', 1, 3)+1) str4,
                rn   
         from  dual,
         (Select  rownum  rn  from  User_Objects  where rownum <=4)
    )    ;


If you run the above 3 queries in succession, you will understand the solution. "Rownum" is a really powerful tool for some serious sql query formation.

Hope this post comes meaningful to many of the sql-developers around.

Wednesday, January 20, 2016

How to get rid of "New Notifications" window in Skype?

Many of you may have faced the problem in skype when your new notification window remains even after you read the message.

As for example, I have 5 to 6 people in the office with whom I have to chat everyday. But of late, I have seen the new notification window in my skype was not vanishing even after reading the message/event.

I found a solution for this.
a. Open your main Skype messenger window
b. Select the people name for whom you have the notification
c. Right click and choose "Mark as Read", it will go away.




Hope this post is useful for you.

Wednesday, September 9, 2015

Some PlSql tips

It's been more than 4 years now that I have been programming in SQL and Oracle PlSql. I thought about to put some tips for my fellow coders.

Q1. You are fetching a million records from a table by a select clause followed by updates. Whats the best way to commit the transactions?

A. If database load is a concern, you should take the approach of bulk commit instead of commit after every update. You can define a temp variable t_count as a number, initialize it to zero; and then do something like this.


Update  <table>
Set <col_name> = val
Where id = 1000;

t_count := t_count + sql%rowcount ;
if (t_count >= 5000) then
  Commit;
  t_count := 0 ;
end if ;

Commit ; // put this commit in the outer loop/ outer block/ after the end-loop

This way if your whole dataset has 1 million rows to update, total no. of commit statements can be reduced to 1 m/5000 = 200 +1 = 201; you can see the difference yourself in the execution time of your program.


Q2. In the same program above, if I do little alteration like below (only pseudo-code given)

Case 1:

Update table statement ;
t_count := sql%rowcount ;
Commit;
Print t_count ;


Case 2

Update table statement ;
Commit ;
t_count := sql%rowcount ;
Print  t_count ;

What is the difference in the 2 print statements above?

The first one prints no. of rows updated, the second one always prints 1.

Don't believe it? Try it yourself.



Q3. You want to print the date information with a timestamp, but the DBMS output function many times are not guaranteed to print the timestamp in all IDEs ( in SQL developer, printing date field prints only the date portion, not the time). What's the way to overcome this?

A. Simple, use the powerful to_char function from Oracle with some formatting changes.

In this case, use this:
 to_char (date_in, 'mm/dd/yyyy hh24:mi:ss')

This will solve your problem.


Saturday, April 21, 2007

Wikis

Wiki, Wiki and some more wiki. The latest sensational wiki-stuff is wikimapia. See this link. Those who have already knowledges about this site please leave the next paragraph.

Wikimapia is a wiki-like concept that take into account the google-map feature. That is they are using the services of google-map for the map purposes with wiki feature i.e. anyone can edit his/her places of interest. Though it was launched in September, 2005, it has already crossed 3 Million marked place in the map. This shows how the popularity of wikimapia is crossing all the limits. But my request to any editor would be first register yourself. U might gain some advantages over the unregistered users in long run.

With so many sites providing these mapping features, we may guess whats the situation would be ten years down the line. There would be broadband connectivity almost all the corners in the country. The word 'Globalisation' will reach its highest peak that day. I shouldn't say it the highest. Since the improvement of a society would know no bounds.

Though the zooming level of Indian cities are one or two levels less than that of London, New York and Chicago. I hope with the advancement in time we would have better zoomed in imag of Indian cities too.

Often i wonder, how do they gather these satellite images? There must be some collaboration of google with NASA, most renowned space body today. The way images are captured reminds of a painting of Nabab Siraj-Ud_Doulla in Murshidabad. I went there way back in 1996. The specialty of the oil painting was it will simply look at you wherever you go in that room. and it could cover a range of 1 km sideways. This might not make any sense though. Analogy is, "Wherever you go, our network follows.. same for the painting and wikimapia.

Next i would post something really of my interest. Not of this wiki-sort. Cheers.