Glide or Picasso?- My Views

So, last Sunday was a quite productive one. The mid sem exams had been over and I could finally spend time on learning Android Development.

std

I had no prior experience of using a Recycler View with the CardView. I decided to make a layout which picks up image from the given URLs and loads it in a circle image. I came across the Glide library and was fascinated by its various features.
But there was a problem that the there was BLANK image until the image was fully loaded. In Picasso, I had used placeholder. But this was not the solution I was looking for.

Finally, in Glide I used the thumbnail feature after .load to load the 1/10th of image first. It makes the placeholder dynamic unlike Picasso.
thumbnail(0.1f)

Some OVERLOADING….

In this post, I have focused on some proficiency in C++. You can solve this easy question using another approach but you will learn something new today.

TOPICS: padding, overloading, modulo use, output formatting, C++ features- friend function

Let’s overload some operators today.
In the given question, you have to use class (named time) , operator overloading to print the object directly(overload << operator).
NOTE: The ahead time can even have a parameter(hour, minutes or second) more than 60.
Don’t use this logic in overloading of  + operator(+1 to HH and -60 to MM or so). Think in a better way.
You are given two clocks- A and B. The clocks show time in HH : MM : SS format. One of these clocks denote the time at GMT and another the time it is ahead of GMT. You have a hi-tech clock. Now you are at an island having these two watches. As soon as you add the time in both clocks- A and B and set it to your watch, a message will be sent to the helpers. You want to leave this sinking island.
Now
make a program for the above case.
In input, you will get two lines of integers- first denoting the GMT time and second the ahead time.
INPUT:
11 22 57
02 55 07
OUTPUT:
14 18 04

The code is given below:

#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
class time1
{
private: int hh,mm,ss;
public:
time1()
{
hh=mm=ss=0;
}
time1(int hh,int mm,int ss)
{
this->hh=hh;
this->mm=mm;
this->ss=ss;
}

time1 operator +(time1 &t)
{
time1 tmp;
tmp.mm+= (ss+ t.ss)/60;
tmp.ss+=(ss+ t.ss)%60;
tmp.hh=hh+ t.hh;
tmp.hh+= (mm+ t.mm)/60;
tmp.mm+= (mm+ t.mm)%60;
return tmp;
}
friend istream &operator >>(istream &input,time1 &t);

friend ostream &operator <<(ostream &output,time1 &t);
};
ostream &operator <<(ostream &output,time1 &t)
{
output<<setw(2)<<t.hh<<” “<<setw(2)<<t.mm<<” “<<setw(2)<<t.ss<<‘\n’;
return output;
}
istream &operator >>(istream &input,time1 &t)
{
cin>>t.hh>>t.mm>>t.ss;
return input;
}
int main()
{
cout.fill(‘0’);
time1 t1;
time1 t2;
time1 t3;
cin>>t1;
cin>>t2;
t3=t1+t2;
cout<<t3;
}

Starting with Git…

  • Git Repository: It is different from a normal folder. In this all the data of our project will be stored. It can be local machine or remote machine. It contains files and folders with their complete history.
    First of all specify the directory where you want to create your repository. You can create a new directory for the purpose.
    $mkdir mywebpage
    $cd mywebpage
    The prompt will appear like the below:
    /mywebpage$
    We will write commands in the above prompt.
    To initialize the git:
    $git init
    Initialized empty git
    repository…
    *A hidden folder .git is created.
    To see the hidden folder in linux:
    $ls -a
    To set identity:
    $git config –global user.email abc@example.com
    $git config –global user.name AbcRaj
    $git config –global core.editor gedit
      //This command is optional as it specifies the editor that you will work upon. It can be gedit, notepad, mousepad etc.
  • –global flag: Multiple repositories can be created in a single machine.
    The setting will be applied to all the repositories of the machine if –global is used.
  • Staging area is a file that stores information of the changes that need to be committed.
    Before commiting them, the file contents should be added to the staging area.
    $git add mypage.html &
    Note:
    Here, & is used to free the prompt.
  • What is Commit?
    After attaining a particular stage, we can save our work in the repository. This is called commit.
    Each commit is saved with the information of username, email-id, date, time and commit message.
    $git commit
    Note:
    To add all files to the staging area ‘-a’ tag is used. To give commit message ‘-m’ tag is used.
    $git commit -a -m “Added first file”
  • Knowing the git log: The full log of git can be known as:
    $git log
    The commits are listed in chronological order i.e. the last commit is shown first.

SHA-1 hash:

  • It is a unique id of 40 alpha-numeric characters.
  • Git stores all the information in its database by the hash value.

Git can be used to restore the changes made to the repository. It can be used to create more than one branch from the master branch. These branches may contain different features of the version of the software being worked in master branch. Thus, working on them individually helps in improving the software without disturbing the main branch.
We will learn how to restore file, create branches and merge them in future posts.
Stay Connected for more.

 

Number triangle with little twist

I have to print the following pattern:

1
232
34543
4567654
567898765
67890109876
7890123210987
890123454321098
90123456765432109
0123456789876543210

The github link for the following code is:
https://github.com/itsmeprakhar22/Basic-problems/blob/master/anumber_triangle.cpp

The code is also given below:

#include <iostream>
using namespace std;
int main()
{
int i,p,j,k,c,t;
for(i=1;i<=10;i++)
{
c=i;
int x[i];
for(j=1;j<=10-i;j++)
cout<< ;
for(p=1;p<=i;p++)
{
t=c%10;
x[p]=t;
cout<<t;
c++;
}
for(k=i-1;k>=1;k–)
{
cout<<x[k];
}
cout<<endl;
}
return 0;

}

Starting with the Diamond…

Today I solved the basic problem of drawing a diamond pattern in C but with three loops only…

I have used a different approach of using  abs() function to reduce the number of loops for printing spaces in the diamond pattern.

The github link is:
https://github.com/itsmeprakhar22/Basic-problems/blob/master/diamond_pattern.c

The code is also given below:

#include <stdio.h>
#include <math.h>
int main()
{
int c,i,p,k,n;
printf(Enter number of lines-Odd number);
scanf(%d,&n);
for(i=1;i<=n;i++)
{
if(i>=(n+1)/2)
c=n+1-i;
else
c=i;
for(p=1;p<=abs((n+1)/2-i);p++)
printf( );
for(k=1;k<=2*c-1;k++)
printf(*);
printf(\n);
}

}