Posts

Showing posts from 2018

Placements: SQL Advance join (Hackerrank Problem)

Image
Problem: You are given three tables:  Students , Friends and Packages.   Students contains two columns: ID  and Name . Friends contains two columns: ID and Friend_ID ( ID of the ONLY best friend). Packages  contains two columns: ID and Salary (offered salary in $ thousands per month). Write a query to output the names of those students whose best friends got offered a higher salary than them. Names must be ordered by the salary amount offered to the best friends. It is guaranteed that no two students got same salary offer. Solution: select temp1.sn from (select S.ID si,S.Name sn,P.Salary ps from Students S join Packages P on S.ID=P.ID) temp1 join (select FF.ID fi,FF.Friend_ID fd,PP.Salary pps from Friends FF join Packages PP on FF.Friend_ID=pp.ID) temp2 on temp1.si=temp2.fi and temp1.ps<temp2.pps order by temp2.pps asc ; Explanation: As the problem states that we have to select the name of the friend whose salary is lesser than what his/her friend is ha

Contest Leaderboard: hackerrank problem (Level medium)

Problem Statement: You did such a great job helping Julia with her last coding contest challenge that she wants you to work on this one, too! The total score of a hacker is the sum of their maximum scores for all of the challenges. Write a query to print the hacker_id , name , and total score of the hackers ordered by the descending score. If more than one hacker achieved the same total score, then sort the result by ascending hacker_id . Exclude all hackers with a total score of from your result. Tables: Hackers: The hacker_id is the id of the hacker, and name is the name of the hacker.  Submissions: The submission_id is the id of the submission, hacker_id is the id of the hacker who made the submission, challenge_id is the id of the challenge for which the submission belongs to, and score is the score of the submission.   Solutions: select h.hacker_id,h.name,sum(sscore) from Hackers h inner join (select s.hacker_id,max(score) as sscore from Submissions s g

changing purple background on ubuntu 18.04 and fixing issues

Image
This is the default purple background while login on my ubuntu 18.04...                                    Default ubunut 18.04 login background This blog is going to show you how to change the purple login screen background on your ubuntu 18.04. After getting into lots of trouble and almost breaking my OS i was able to change it to something spidery which you can see in the video below. Links for the wallpapers that i've used are given at the end of this blog, you can download them if you want the same feel as shown in the video or be ready with your own png format images that you wanna see behind login screen. NOTE: sorry for the folks who won't be able to play the clip in their firefox browser..i suggest to use google chrome for that. if you're on windows, firefox uses the Media Foundation to decode MP4 videos and you may not be getting update for Media foundation.. while the Ubuntu user facing issues in firefox playing videos from the blog, can run the following

Bypassing Gmail Virus Scanner ::"VIRUS DETECTED", error message

Now most of the time when you are going to share the files over mail to your friend or someone. you face the issue that gmail can't attach the file with mail because it may contain virus or spam or something...you will be given the option for sending the mail without attachment. why basically it happens because google has automated its own email checking bot type virus scanner, which scans for the threats in the files that you are sending and if it finds any malicious content that can harm the users system environment it will block it from sending. in order send your mail without getting it detected by gmail Virus scanner. what to do bypass scanner is just follow the steps..  1. Open the file in winzip or gzip file compressor.  2. Compress it with the password. (even with the password one time compressed file can be detected by gmail scanner..)  3. Take the compressed file and compress it again. (just to be sure...)  4. now attach the double compressed file in attachmen

Connecting WIFI from terminal or Recovery on Debian system

Connecting to the wifi:- Here in this post we are going to talk about how one can connect their system to the wireless network available in their vicinity. To do so, start the network manager that will cofigure the /etc/resolv.conf file for dns, Most of the people face the issue of can not find resolv.conf or can not resolve the host about which we are going to talk in the post later. provided, follow the steps to connect to wifi and PING google.com just to be sure that your packets are getting transmitted and being recieved at the other side. write the following commands at the terminal in the sequence... STEPS:-   term@terminal:~$ sudo ifconfig -a        //this will give you all the NIC           //available for your pc. lets say your wireless adapter is 'wlp0' term@terminal:~$ sudo ifconfig wlp0 up //setting the adapter to up and listening term@terminal:~$ sudo iwlist wlp0 scanning //this will give you the list of the available wifi networks select the one your want

Upgrading to Ubuntu 18.04 (Bionic Beaver)

Image
Note: To upgrade your os to Bionic Beaver(18.04) you must have prior version of ubuntu 17.10 or the last long time support(LTS) version 16.04 . error "Target configured multiple times" fixed. scroll down to see the solution. UBUNTU 18.04 Bionic Beaver         To upgrade to the latest version you must have the root privileges or you can use sudo command with the administrator password. For ubuntu 18.04 LTS the support will be provided till  2023 . steps to upgrade to 18.04:-   $sudo apt update $sudo apt upgrade  Now that you are upgraded to 18.04 you should remove the duplicate packages using following command:   -$sudo apt dist-upgrade   dist-upgrade in addition to performing the function of upgrade, also intelligently handles changing dependencies with new versions of packages; apt-get has a "smart" conflict resolution system, and it will attempt to upgrade the most important packages at the expense of less important ones if n

Passing Data from Fragment to Activity

For passing the data from the fragment to the activity we can define "interface" in the fragment class which should be implemented it the activity class in which you want to transfer the data. for this, here is an small example which will show you how to pass the data the to the activity class. interface is the collection of abstract methods that are implemented by the class. A class that implements an interface must implement all of the non-default methods described in the interface , or be an abstract class. inside myfragment.java class:  //define the interface as shown below and call it in the fragment wher you want // to pass the data to the activity..in this case for example we will be passing //sample strings. public interface myInterface{  public void addData(ArrayList<String> lst) ; //here we can pass the data using Bundle also.  } inside myActivity.java class: //Activity in which you are recieving your data must look like the

Sending Mails using Intents

Using ACTION_SEND in intent for mail.. The code written below is using ACTION_SEND in the intent to generate mail which can be used to send the email to the single or multiple  person. firstly we will generate the intent with ACTION_SEND or ACTION_SENDTO. ACTION_SENDTO has one drawback that we can not add the attachment/files to the intent that we are sending. after setting the ACTION we will set up the intent with the type of the data that it is holding, for now we will use "message/rfc822", documentation on the type you can get here ( rfc822 ). Now we will move on to the setting the parameters that we are going to pass to our email using the function putExtras(). after setting up parameters for the mail we will create a chooser and launch our intent. NOTE: The Android device on which application is going to run must have already setup their mailing application. CODE:  Intent emailIntent=new Intent(Intent.ACTION_SEND);   //add the multiple or single reciev

Tips and Tweaks for Android and Windows (terminal,MAC Spoofing)

ANDROID TERMINAL AND MAC SPOOFING   1.Portable terminal (save 200mb space on your internal disk of android device to use 1st and 2nd script ) Root your android handset(for rooting go online with your device name to xda-developer) , patch the busy box or download it or askme ,now add any good terminal from android playstore and start using most of the featres of linux terminal. ....now dont bother bringing laptops for linux class . and the many thing you will be able do..for ex:spoofing mac address (just put the mac address of your registered college laptop and use it in phone also..) and more.. 2.This one to help you guys with the commands to spoof your MAC address on you android, and for general knowledge MAC address is a 12 character address given by the device manufacturers (though you all are genius i thought you might need it ).. $~>su ;dont bother about this ,it is just to enable the "superuser"..now next one $~>busybox iplink show eth0 ;this one wi

TOP COMPETITORS: HACKERRANK

Problem Statement:  Julia just finished conducting a coding contest, and she needs your help assembling the leaderboard! Write a query to print the respective hacker_id and name of hackers who achieved full scores for more than one challenge. Order your output in descending order by the total number of challenges in which the hacker earned a full score. If more than one hacker received full scores in same number of challenges, then sort them by ascending hacker_id . Tables: 1. Hackers: The hacker_id is the id of the hacker, and name is the name of the hacker.   2. Difficulty: The difficult_level is the level of difficulty of the challenge, and score is the score of the challenge for the difficulty level. 3. Challenges: The challenge_id is the id of the challenge, the hacker_id is the id of the hacker who created the challenge, and difficulty_level is the level of difficulty of the challenge. 4. Submissions: The submission_id is the id of the submission,

The Occupation: hackerrank problem

Problem Statement: Pivot the Occupation column in OCCUPATIONS so that each Name is sorted alphabetically and displayed underneath its corresponding Occupation . The output column headers should be Doctor , Professor , Singer , and Actor , respectively. Note: Print NULL when there are no more names corresponding to an occupation. Table:   'OCCUPATIONS' table contain the column 'Name' and 'Occupation' Solution: select doc,prof,singer,act from ( select row_number() over(partition by Occupation order by Name) ron,Name as n,Occupation as o from OCCUPATIONS ) pro pivot (max(n)  for o in ('Doctor' as doc,'Actor' as act,'Professor' as prof,'Singer' as singer))  order by ron asc; Explanation: in the above query statement i am using row_number() function with the 'partition by' clause to append one column that contains row_number for each row in the subquery. in the subquery while assigning row_number() we

Hackerrank: The Pads

Problem Statement: Generate the following two result sets: Query an alphabetically ordered list of all names in OCCUPATIONS , immediately followed by the first letter of each profession as a parenthetical (i.e.: enclosed in parentheses). For example: AnActorName(A) , ADoctorName(D) , AProfessorName(P) , and ASingerName(S) . Query the number of ocurrences of each occupation in OCCUPATIONS . Sort the occurrences in ascending order , and output them in the following format: There are a total of [occupation_count] [occupation]s. where [occupation_count] is the number of occurrences of an occupation in OCCUPATIONS and [occupation] is the lowercase occupation name. If more than one Occupation has the same [occupation_count] , they should be ordered alphabetically. Note: There will be at least two entries in the table for each type of occupations. SOLUTION: here is what you have been looking for.. the query format is for the oracle SQL. The problem uses

How to recover if all the partitions in the system marked "deleted".

I first came across this problem when I was trying to install the Ubuntu 14.04 alongside windows 8...I installed it in legacy firmware while the windows was in UEFI  firmware this caused the problem and started showing all partition as deleted and I was not able to boot into the any system ... now moving on to the solution ..... Before procee ding further ..First try to repair it using official windows 10/8 live cd/thumbdrive. Try the below link for reference if you are doing it for the first time... How to repair/reset windows? If the repairing windows doesn 't solves the issue. And windows still doesn't boot up try the method 1. Method 1 : 1. make a windows bootable thumbdrive or use your recovery CD and follow this instructions. If you don't know how to make a bootable ... Follow this tutorial given below .. Link to make bootable pendrive/thumbdrive. 2. Now that your bootable thumbdrive is ready. Insert it and boot from it. If it doesn&