Magic Constants and Magic Functions in PHP

In this article we will explore Magic Constants and Magic Methods, how they are useful to us? and what exactly they are?

In this article we will explore Magic Constants and Magic Methods, how they are useful to us? and what exactly they are?

So let’s understand Magic Constants first.

Magic Constants

Magic Constants are those constant whose value is going to be defined in the time of compilation. That is why they are also defined as Compile Time Constant.

There are nine magical constants that change depending on where they are used. For example, __FILE__ value depends on which file you are calling constant. It will give that filename. If you again call it in some another file its value will be changed and this time it will give the filename where you have accessed it.

This is magic of these type of Constants.

 

Name Description
__LINE__ The current line number of the file.
__FILE__ The full path and filename of the file with symlinks resolved. If used inside an include, the name of the included file is returned.
__DIR__ The directory of the file. If used inside an include, the directory of the included file is returned. This is equivalent to dirname(__FILE__). This directory name does not have a trailing slash unless it is the root directory.
__FUNCTION__ The function name.
__CLASS__ The class name. The class name includes the namespace it was declared in. Note that as of PHP 5.4 __CLASS__ works also in traits. When used in a trait method, __CLASS__ is the name of the class the trait is used in.
__TRAIT__ The trait name. The trait name includes the namespace it was declared in.
__METHOD__ The class method name. (It will return function name along with the classname)
__NAMESPACE__ The name of the current namespace.
ClassName::class The fully qualified class name. See also ::class.

These Constants we use when we need to debug or we are creating a logging system in our application. So that we will be able to track the process is going as we thought or if something went wrong we will be able to track it.

I hope whenever you are creating your logging mechanism you will use these Magic Constants.

 

Now let’s discuss Magic Methods.

Magic Methods

There are methods which start with “__” in PHP classes which are magical in nature. If you want these magic should be associated with them so do not define methods as defined below:

 

Name Description
__construct() It gets called when an object instantiated.
__destruct() When object is not referenced by any other variable then this will be called.
__call() __call() is triggered when invoking inaccessible methods in an object context.
__callStatic() __callStatic() is triggered when invoking inaccessible methods in a static context.
__get() __get() is utilized for reading data from inaccessible properties.
__set() __set() is run when writing data to inaccessible properties.
__isset() __isset() is triggered by calling isset() or empty() on inaccessible properties.
__unset() __unset() is invoked when unset() is used on inaccessible properties.
__sleep() use of __sleep() is to commit pending data or perform similar cleanup tasks.
__wakeup() __wakeup() is to reestablish any database connections that may have been lost during serialization and perform other reinitialization tasks.
__toString() The __toString() method allows a class to decide how it will react when it is treated like a string
__invoke() The __invoke() method is called when a script tries to call an object as a function.
__set_state() This static method is called for classes exported by var_export() since PHP 5.1.0.
__clone() An object copy is created by using the clone keyword (which calls the object’s __clone() method if possible)
__debugInfo() This method is called by var_dump() when dumping an object to get the properties that should be shown.

How to setup cron in Linux?

Linux allows user for scheduling future jobs or CRON. Jobs can be scheduled to run only once in the future or repetitively at fix time.

While working as a system administrator it is fairly regular to perform certain tasks like taking backup, rotating log files and other tasks. To perform these repetitive tasks Linux has Cron and AT.

AT

To run task only once in future at specified time.

# at 09:30
at> echo "hello World" > /dev/tty4
at> Ctrl+d
# atq
# at -c 1
# atrm 1 

CRONTAB

To run task repetitively in future at specified time. In order for cron jobs to execute, crond daemon must be running.

Every user on Linux machine can have jobs scheduled to run at fixed times. This scheduled jobs are stored in separate files for each user in /var/spool/cron/directory. Users can set their scheduled jobs with crontab command.

Time for the execution of cron job is given in a specific order.

*  *  *  *  *
|  |  |  |  |
|  |  |  |  --- Day of week (0-7)(SUN=0,7)
|  |  |  ------ Month (1-12) (Jan, Feb, Mar, ...)
|  |  --------- Day of month (1-31)
|  ------------ Hour (0-23)
--------------- Minute (0-59)

Some examples of the time format are given below.

*     *      *   *  *		Every minute
1     12     *   *  *		At 12:01
5,30  14,20  *   *  *		At 14:05, 14:30, 20:05, 20:30
*/10  17     13  *  *		Every 13th at 17:00, 17:10, 17:20, 17:30, 17:40, 17:50
*/20  14     19  5  *		On May 19 at 14:00, 14:20, 14:40
50    */6    25  9  *		On Sep 25 at 00:50, 06:50, 12:50, 18:50
23    12     15  5  4,6		On May 15 at 12:23 if day is Thu and Sat  

Every user can set their own cron jobs. An administrator user is allowed to set cron jobs for any user.

$ crontab -e
23  12  *  *  *  echo "Student user cron"
ESC:wq
$ crontab -l
$ crontab -r
# crontab -eu student
*/30  11,15  *  *  *  /home/student/backup.sh
ESC:wq
# crontab -lu student
# ls /var/spool/cron 

It is possible to restrict a user from using cron service by writing an entry in /etc/cron.deny

# vim /etc/cron.deny
student
ESC:wq
#

Understand logs and manage logs in Linux

How to manage logs in Linux?

JOURNALD

 Journal is the system that collects and manages logs – syslog messages, kernel log messages, initial ram disk and early boot messages, messages from running services. In RHEL 7 journald implements the journal and replaces rsyslog as the default log management service.

The journald daemon collects data from all available sources and stores them in a binary format for easy and dynamic manipulation.

To manage journald we have journalctl command. Let us get the hang of journald.

    • List all logs from the oldest entry.
# journalctl
    • List all logs from the oldest entry in UTC.
# journalctl --utc
    • List all logs from current boot or older boot.
# journalctl -b
# journalctl -b -2
    • List total boots of the system that journald is aware of. Takes time if the persistent logging is enabled for a long time.
# journalctl --list-boots
    • List all logs for given time.
# journalctl --since yesterday
# journalctl --since 09:00 --until "1 hour ago"
# journalctl --since "2016-12-30" --until "2017-01-01 03:00"
# journalctl --since "2017-01-01 17:15:00"
    • List all logs from a unit.
# journalctl -u sshd
# journalctl -u sshd --since today
# journalctl -u sshd -u httpd --since today
    • List all logs by UID, GID, PID. For this we will use journal fields. To get the available values of a journal fileds use -F with journalctl.
# journalctl -F _UID
# journalctl -F _GID
# journalctl -F _PID
# journalctl _UID=1000
# journalctl _GID=100
# journalctl _PID=3224
    • List all logs of an executable file or device.
# journalctl /bin/bash
    • List kernel logs.
# journalctl -k
# journalctl -k -b -3
    • Journal Disk Usage.
# journalctl --disk-usage
    • Actively follow logs.
# journalctl -f
    • Display recent logs.
# journalctl -n
# journalctl -n 20
    • Display logs in JSON format.
# journalctl -u sshd -o json
# journalctl -u sshd -o json-pretty

Journald logs are not persistently stored by default. They are stored in /run/log/journal/ directory and are cleared on system reboot. To make the journald logs persistent, create /var/log/journal/ directory so that journald logs will be stored in it and will not get cleared on system reboot.

The main configuration file for journald is /etc/systemd/journald.conf.

# mkdir /var/log/journal
# chown root.systemd-journal /var/log/journal
# chmod 2755 /var/log/journal
# killall -USR1 systemd-journald

RSYSLOG

Rsyslog is Rocket-fast SYStem for LOG processing.

Journald forwards all logs to rsyslog which stores them in plain text files under /var/log/ directory.

Important log files:

  • /var/log/messages – Most syslog messages are logged here
  • /var/log/secure – Security and Authentication related logs
  • /var/log/maillog – Mail server related logs
  • /var/log/cron – Crontab related logs
  • /var/log/boot.log Booting related logs

The main configuration file for rsyslog is /etc/rsyslog.conf. In configuration file, rule lines are written to store log messages in various files. Each rule line consists of two parts – “selector field” and “action field”. Selector field is divided into two – “facility” and “priority”. Action field specifies what action must be taken for the matched rule – generally a file name in which to store the log for the matched rule.

There are many facilities –
auth, authpriv, cron, daemon, kern, lpr, mail, mark, news, security, syslog, user, uucp, local0 … local7.

There are several priorities –
emerg, alert, crit, error, warn, notice, info, debug.

To store logs related to mail facility in user defined /var/log/mymails.log file the rule should be written to main configuration file of rsyslog as follows.

# vim /etc/rsyslog.conf
mail.*	/var/log/mymails.log
ESC:wq
# systemctl reload rsyslog
# logger -p mail.info "Test mail log"
# tail /var/log/mymails.log

Is your website GDPR compliant or not?

It is currently one of the major concern to the various website owners who is using cookies to track user activities and collect data without the permission of the user. And to make your website GDPR compliance, last date is 25 Many 2018 Almost every website is using cookies to get user data, track their browsing etc. and use it to promote their service or product which is unethical. So EU has created a new which is known as GDPR under which they have set various norms through which your website will be fined heavily if you don’t follow these rules.

The aim of the GDPR is to protect all EU citizens from privacy and data breaches in an increasingly data-driven world that is vastly different from the time in which the 1995 directive was established. Although the key principles of data privacy still hold true to the previous directive, many changes have been proposed to the regulatory policies; the key points of the GDPR, as well as information on the impacts it will have on business, can be found below.

Increased Territorial Scope (extra-territorial applicability)
Arguably the biggest change to the regulatory landscape of data privacy comes with the extended jurisdiction of the GDPR, as it applies to all companies processing the personal data of data subjects residing in the Union, regardless of the company’s location. Previously, territorial applicability of the directive was ambiguous and referred to data process ‘in context of an establishment’. This topic has arisen in a number of high profile court cases. GDPR makes its applicability very clear – it will apply to the processing of personal data by controllers and processors in the EU, regardless of whether the processing takes place in the EU or not. The GDPR will also apply to the processing of personal data of data subjects in the EU by a controller or processor not established in the EU, where the activities relate to: offering goods or services to EU citizens (irrespective of whether payment is required) and the monitoring of behaviour that takes place within the EU. Non-Eu businesses processing the data of EU citizens will also have to appoint a representative in the EU.

Penalties
Under GDPR organizations in breach of GDPR can be fined up to 4% of annual global turnover or €20 Million (whichever is greater). This is the maximum fine that can be imposed for the most serious infringements e.g.not having sufficient customer consent to process data or violating the core of Privacy by Design concepts. There is a tiered approach to fines e.g. a company can be fined 2% for not having their records in order (article 28), not notifying the supervising authority and data subject about a breach or not conducting impact assessment. It is important to note that these rules apply to both controllers and processors — meaning ‘clouds’ will not be exempt from GDPR enforcement.

Consent
The conditions for consent have been strengthened, and companies will no longer be able to use long illegible terms and conditions full of legalese, as the request for consent must be given in an intelligible and easily accessible form, with the purpose for data processing attached to that consent. Consent must be clear and distinguishable from other matters and provided in an intelligible and easily accessible form, using clear and plain language. It must be as easy to withdraw consent as it is to give it.

Data Subject Rights

Breach Notification

Under the GDPR, breach notification will become mandatory in all member states where a data breach is likely to “result in a risk for the rights and freedoms of individuals”. This must be done within 72 hours of first having become aware of the breach. Data processors will also be required to notify their customers, the controllers, “without undue delay” after first becoming aware of a data breach.

Right to Access
Part of the expanded rights of data subjects outlined by the GDPR is the right for data subjects to obtain from the data controller confirmation as to whether or not personal data concerning them is being processed, where and for what purpose. Further, the controller shall provide a copy of the personal data, free of charge, in an electronic format. This change is a dramatic shift to data transparency and empowerment of data subjects.

Right to be Forgotten
Also known as Data Erasure, the right to be forgotten entitles the data subject to have the data controller erase his/her personal data, cease further dissemination of the data, and potentially have third parties halt processing of the data. The conditions for erasure, as outlined in article 17, include the data no longer being relevant to original purposes for processing, or a data subjects withdrawing consent. It should also be noted that this right requires controllers to compare the subjects’ rights to “the public interest in the availability of the data” when considering such requests.

Data Portability

GDPR introduces data portability – the right for a data subject to receive the personal data concerning them, which they have previously provided in a ‘commonly use and machine readable format‘ and have the right to transmit that data to another controller.

Privacy by Design

Privacy by design as a concept has existed for years now, but it is only just becoming part of a legal requirement with the GDPR. At its core, privacy by design calls for the inclusion of data protection from the onset of the designing of systems, rather than an addition. More specifically – ‘The controller shall..implement appropriate technical and organisational measures..in an effective way.. in order to meet the requirements of this Regulation and protect the rights of data subjects’. Article 23 calls for controllers to hold and process only the data absolutely necessary for the completion of its duties (data minimisation), as well as limiting the access to personal data to those needing to act out the processing.

Data Protection Officers

Currently, controllers are required to notify their data processing activities with local DPAs, which, for multinationals, can be a bureaucratic nightmare with most Member States having different notification requirements. Under GDPR it will not be necessary to submit notifications / registrations to each local DPA of data processing activities, nor will it be a requirement to notify / obtain approval for transfers based on the Model Contract Clauses (MCCs). Instead, there will be internal record keeping requirements, as further explained below, and DPO appointment will be mandatory only for those controllers and processors whose core activities consist of processing operations which require regular and systematic monitoring of data subjects on a large scale or of special categories of data or data relating to criminal convictions and offences. Importantly, the DPO:

  • Must be appointed on the basis of professional qualities and, in particular, expert knowledge on data protection law and practices
  • May be a staff member or an external service provider
  • Contact details must be provided to the relevant DPA
  • Must be provided with appropriate resources to carry out their tasks and maintain their expert knowledge
  • Must report directly to the highest level of management
  • Must not carry out any other tasks that could results in a conflict of interest.

 

FIREBASE: How To Send Topic Notification in IOS App

To send Topic Notification in IOS for which we need Firebase Access Key and users should have subscribed to the topic in your app which you will need to do it internally using Firebase SDK in IOS app.

Here is the sample of PHP code through which you can send IOS notification to users Topicwise.

<?php
define( 'API_ACCESS_KEY', 'KEY-VALUE' );
$msg = array
(
'body' => "abc",
'title' => "Hello from Api",
'vibrate' => 1,
'sound' => 1,
);
$body = array (
"to" => "/topics/news",
"notification" => array(
"body" => "hello there",
"sound" => "default"
),
"data" => array(
"body" => "hello there",
"title" => "IBC24",
"key_1" => "Data for key one",
"key_2" => "Data for key two"
)
);
$headers = array
(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );
curl_setopt( $ch,CURLOPT_POST, true );
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $body ) );
$result = curl_exec($ch );
curl_close( $ch );
echo $result;
?>

Custom week range in PHP

How to get create customized  week range in PHP

Here we have created a week range from Saturday to Friday by passing any date of the month and the day from which we need to start our week.

<?php
echo "<pre>".print_r(monthArr("05-03-2018","Saturday"),true);
function monthArr($date,$startDay){
$date = strtotime($date);
$date = "01-".date("m",$date)."-".date("Y",$date);
$firstDateOfCustomWeek = date("d-m-Y",strtotime("next ".$startDay, date(strtotime($date))));
$lastDayOfMonth = date("d-m-Y",(strtotime("+1 month", date(strtotime($date)))-1));
$arr = array();
$count = strtotime($firstDateOfCustomWeek);
while($count < strtotime($lastDayOfMonth." 23:59:59")){
$arr[] =  array(date("d-m-Y",$count),date("d-m-Y",strtotime("+6 days",date($count))));
$count =  strtotime("+7 days",date($count));
}
return $arr;
}
?>

Output

Array
(
[0] => Array
(
[0] => 03-03-2018
[1] => 09-03-2018
)
[1] => Array
(
[0] => 10-03-2018
[1] => 16-03-2018
)
[2] => Array
(
[0] => 17-03-2018
[1] => 23-03-2018
)
[3] => Array
(
[0] => 24-03-2018
[1] => 30-03-2018
)
[4] => Array
(
[0] => 31-03-2018
[1] => 06-04-2018
)
)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Previous Year IIT Question Papers

IIT JEE Syllabus

CHEMISTRY

Physical chemistry

General topics 
Concept of atoms and molecules; Dalton’s atomic theory; Mole concept; Chemical formulae; Balanced chemical equations; Calculations (based on mole concept) involving common oxidation-reduction, neutralisation, and displacement reactions; Concentration in terms of mole fraction, molarity, molality and normality.

Gaseous and liquid states
Absolute scale of temperature, ideal gas equation; Deviation from ideality, van der Waals equation; Kinetic theory of gases, average, root mean square and most probable velocities and their relation with temperature; Law of partial pressures; Vapour pressure; Diffusion of gases.

Atomic structure and chemical bonding
Bohr model, spectrum of hydrogen atom, quantum numbers; Wave-particle duality, de Broglie hypothesis; Uncertainty principle; Qualitative quantum mechanical picture of hydrogen atom, shapes of sp and d orbitals; Electronic configurations of elements (up to atomic number 36); Aufbau principle; Pauli’s exclusion principle and Hund’s rule; Orbital overlap and covalent bond; Hybridisation involving sp and d orbitals only; Orbital energy diagrams for homonuclear diatomic species;  Hydrogen bond; Polarity in molecules, dipole moment (qualitative aspects only); VSEPR model and shapes of molecules (linear, angular, triangular, square planar, pyramidal, square pyramidal, trigonal bipyramidal, tetrahedral and octahedral).

Energetics
First law of thermodynamics; Internal energy, work and heat, pressure-volume work; Enthalpy, Hess’s law; Heat of reaction, fusion and vapourization; Second law of thermodynamics; Entropy; Free energy; Criterion of spontaneity.
Chemical equilibrium
Law of mass action; Equilibrium constant, Le Chatelier’s principle (effect of concentration, temperature and pressure); Significance of ΔG and ΔG0 in chemical equilibrium; Solubility product, common ion effect, pH and buffer solutions;  Acids and bases (Bronsted and Lewis concepts); Hydrolysis of salts.

Electrochemistry
Electrochemical cells and cell reactions; Standard electrode potentials; Nernst equation and its relation to ΔG; Electrochemical series, emf of galvanic cells; Faraday’s laws of electrolysis; Electrolytic conductance, specific, equivalent and molar conductivity, Kohlrausch’s law; Concentration cells.

Chemical kinetics
Rates of chemical reactions; Order of reactions; Rate constant; First order reactions; Temperature dependence of rate constant (Arrhenius equation).

Solid state
Classification of solids, crystalline state, seven crystal systems (cell parameters abc, α, β, γ), close packed structure of solids (cubic), packing in fcc, bcc and hcp lattices; Nearest neighbours, ionic radii, simple ionic compounds, point defects.

Solutions
Raoult’s law; Molecular weight determination from lowering of vapour pressure, elevation of boiling point and depression of freezing point.

Surface chemistry
Elementary concepts of adsorption (excluding adsorption isotherms); Colloids: types, methods of preparation and general properties; Elementary ideas of emulsions, surfactants and micelles (only definitions and examples).

Nuclear chemistry
Radioactivity: isotopes and isobars; Properties of α, β and γ rays; Kinetics of radioactive decay (decay series excluded), carbon dating; Stability of nuclei with respect to proton-neutron ratio; Brief discussion on fission and fusion reactions.

Inorganic Chemistry

Isolation/preparation and properties of the following non-metals
Boron, silicon, nitrogen, phosphorus, oxygen, sulphur and halogens; Properties of allotropes of carbon (only diamond and graphite), phosphorus and sulphur.

Preparation and properties of the following compounds
Oxides, peroxides, hydroxides, carbonates, bicarbonates, chlorides and sulphates of sodium, potassium, magnesium and calcium; Boron: diborane, boric acid and borax; Aluminium: alumina, aluminium chloride and alums; Carbon: oxides and oxyacid (carbonic acid); Silicon: silicones, silicates and silicon carbide;  Nitrogen: oxides, oxyacids and ammonia; Phosphorus: oxides, oxyacids (phosphorus acid, phosphoric acid) and phosphine; Oxygen: ozone and hydrogen peroxide; Sulphur: hydrogen sulphide, oxides, sulphurous acid, sulphuric acid and sodium thiosulphate; Halogens: hydrohalic acids, oxides and oxyacids of chlorine, bleaching powder; Xenon fluorides.

Transition elements (3d series)
Definition, general characteristics, oxidation states and their stabilities, colour (excluding the details of electronic transitions) and calculation of spin-only magnetic moment; Coordination compounds: nomenclature of mononuclear coordination compounds, cis-trans and ionisation isomerisms, hybridization and geometries of mononuclear coordination compounds (linear, tetrahedral, square planar and octahedral).

Preparation and properties of the following compounds:
Oxides and chlorides of tin and lead; Oxides, chlorides and sulphates of Fe2+, Cu2+ and Zn2+; Potassium permanganate, potassium dichromate, silver oxide, silver nitrate, silver thiosulphate.

Ores and minerals
Commonly occurring ores and minerals of iron, copper, tin, lead, magnesium, aluminium, zinc and silver.

Extractive metallurgy
Chemical principles and reactions only (industrial details excluded); Carbon reduction method (iron and tin); Self reduction method (copper and lead); Electrolytic reduction method (magnesium and aluminium); Cyanide process (silver and gold).

Principles of qualitative analysis:
Groups I to V (only Ag+, Hg2+, Cu2+, Pb2+, Bi3+, Fe3+, Cr3+,  Al3+, Ca2+, Ba2+, Zn2+, Mn2+ and Mg2+); Nitrate, halides (excluding fluoride), sulphate and sulphide.

Organic Chemistry

Concepts
Hybridisation of carbon; σ and π-bonds; Shapes of simple organic molecules; Structural and geometrical isomerism;  Optical isomerism of compounds containing up to two asymmetric centres, (R,S and E,Z nomenclature excluded); IUPAC nomenclature of simple organic compounds (only hydrocarbons, mono-functional and bi-functional compounds); Conformations of ethane and butane (Newman projections); Resonance and hyperconjugation; Keto-enoltautomerism; Determination of empirical and molecular formulae of simple compounds (only combustion method); Hydrogen bonds: definition and their effects on physical properties of alcohols and carboxylic acids; Inductive and resonance effects on acidity and basicity of organic acids and bases; Polarity and inductive effects in alkyl halides; Reactive intermediates produced during homolytic and heterolytic bond cleavage;  Formation, structure and stability of carbocations, carbanions and free radicals.

Preparation, properties and reactions of alkanes
Homologous series, physical properties of alkanes (melting points, boiling points and density); Combustion and halogenation of alkanes; Preparation of alkanes by Wurtz reaction and decarboxylation reactions.

Preparation, properties and reactions of alkenes and alkynes
Physical properties of alkenes and alkynes (boiling points, density and dipole moments); Acidity of alkynes; Acid catalysed hydration of alkenes and alkynes (excluding the stereochemistry of addition and elimination); Reactions of alkenes with KMnO4 and ozone; Reduction of alkenes and alkynes; Preparation of alkenes and alkynes by elimination reactions; Electrophilic addition reactions of alkenes with X2, HX, HOX and H2O (X=halogen);  Addition reactions of alkynes; Metal acetylides.

Reactions of benzene
Structure and aromaticity; Electrophilic substitution reactions: halogenation, nitration, sulphonation, Friedel-Crafts alkylation and acylation; Effect of o-, m– and p-directing groups in monosubstituted benzenes.

Phenols
Acidity, electrophilic substitution reactions (halogenation, nitration and sulphonation); Reimer-Tieman reaction, Kolbe reaction.

Characteristic reactions of the following (including those mentioned above) 
Alkyl halides: rearrangement reactions of alkyl carbocation, Grignard reactions,  nucleophilic substitution reactions;  Alcohols: esterification, dehydration and oxidation, reaction with sodium, phosphorus halides, ZnCl2/concentrated HCl, conversion of alcohols into aldehydes and ketones; Ethers: Preparation by Williamson’s  Synthesis; Aldehydes and Ketones: oxidation, reduction, oxime and hydrazone formation; aldol condensation, Perkin reaction; Cannizzaro reaction; haloform reaction and nucleophilic addition reactions (Grignard addition);  Carboxylic acids: formation of esters, acid chlorides and amides, ester hydrolysis; Amines: basicity of substituted anilines and aliphatic amines, preparation from nitro compounds, reaction with nitrous acid, azo coupling reaction of diazonium salts of aromatic amines, Sandmeyer and related reactions of diazonium salts; carbylamine reaction; Haloarenes: nucleophilic aromatic substitution in haloarenes and substituted haloarenes (excluding Benzyne mechanism and Cine substitution).

Carbohydrates
Classification; mono- and di-saccharides (glucose and sucrose); Oxidation, reduction, glycoside formation and hydrolysis of sucrose.

Amino acids and peptides
General structure (only primary structure for peptides) and physical properties.

Properties and uses of some important polymers 
Natural rubber, cellulose, nylon, teflon and PVC.

Practical organic chemistry:
Detection of elements (N, S, halogens); Detection and identification of the following functional groups: hydroxyl (alcoholic and phenolic), carbonyl (aldehyde and ketone), carboxyl, amino and nitro; Chemical methods of separation of mono-functional organic compounds from binary mixtures.

MATHEMATICS

Algebra
Algebra of complex numbers, addition, multiplication, conjugation, polar representation, properties of modulus and principal argument, triangle inequality, cube roots of unity, geometric interpretations.
Quadratic equations with real coefficients, relations between roots and coefficients, formation of quadratic equations with given roots, symmetric functions of roots.
Arithmetic, geometric and harmonic progressions, arithmetic, geometric  and harmonic means, sums of finite arithmetic and geometric progressions, infinite geometric series, sums of squares and cubes of the first n natural numbers.
Logarithms and their properties.
Permutations and combinations, binomial theorem for a positive integral index, properties of binomial coefficients.
Matrices as a rectangular array of real numbers, equality of matrices, addition, multiplication by a scalar and product of matrices, transpose of a matrix, determinant of a square matrix of order up to three, inverse of a square matrix of order up to three, properties of these matrix operations, diagonal, symmetric and skew-symmetric matrices and their properties, solutions of simultaneous linear equations in two or three variables.
Addition and multiplication rules of probability, conditional probability, Bayes Theorem, independence of events, computation of probability of events using permutations and combinations.

Trigonometry
Trigonometric functions, their periodicity and graphs, addition and subtraction formulae, formulae involving multiple and sub-multiple angles, general solution of trigonometric equations.
Relations between sides and angles of a triangle, sine rule, cosine rule, half-angle formula and the area of a triangle, inverse trigonometric functions (principal value only).

Analytical geometry
Two dimensions: Cartesian coordinates, distance between two points, section formulae, shift of origin.
Equation of a straight line in various forms, angle between two lines, distance of a point from a line; Lines through the point of intersection of two given lines, equation of the bisector of the angle between two lines, concurrency of lines;  Centroid, orthocentre, incentre and circumcentre of a triangle.
Equation of a circle in various forms, equations of tangent, normal and chord.
Parametric equations of a circle, intersection of a circle with a straight line or a circle, equation of a circle through the points  of  intersection of two circles and those of a circle and a straight line.
Equations of a parabola, ellipse and hyperbola in standard form, their foci, directrices and eccentricity, parametric equations, equations of tangent and normal.
Locus problems.
Three dimensions: Direction cosines and direction ratios, equation of a straight line in space, equation of a plane, distance of a point from a plane.

Differential calculus
Real valued functions of a real variable, into, onto and one-to-one functions, sum, difference, product and quotient of two functions, composite functions, absolute value, polynomial, rational, trigonometric, exponential and logarithmic functions.
Limit and continuity of a function, limit and continuity of the sum, difference, product and quotient of two functions, L’Hospital rule of evaluation of limits of functions.
Even and odd functions, inverse of a function, continuity of composite functions, intermediate value property of continuous functions.
Derivative of a function, derivative of the sum, difference, product and quotient of two functions, chain rule, derivatives of polynomial, rational, trigonometric, inverse trigonometric, exponential and logarithmic functions.
Derivatives of implicit functions, derivatives up to order two, geometrical interpretation of the derivative, tangents and normals, increasing and decreasing functions, maximum and minimum values of a function, Rolle’s theorem and Lagrange’s mean value theorem.

Integral calculus
Integration as the inverse process of differentiation, indefinite integrals of standard functions, definite integrals and their properties, fundamental theorem of integral calculus.
Integration by parts, integration by the methods of substitution and partial fractions, application of definite integrals to the determination of areas involving simple curves.
Formation of ordinary differential equations, solution of homogeneous differential equations, separation of variables method, linear first order differential equations.

Vectors
Addition of vectors, scalar multiplication, dot and cross products, scalar triple products and their geometrical interpretations.

PHYSICS

General
Units and dimensions, dimensional analysis; least count, significant figures; Methods of measurement and error analysis for physical quantities pertaining to the following experiments: Experiments based on using Vernier calipers and screw gauge (micrometer), Determination of g using simple pendulum, Young’s modulus by Searle’s method, Specific heat of a liquid using calorimeter, focal length of a concave mirror and a convex lens using uv method, Speed of sound using resonance column, Verification of Ohm’s law using voltmeter and ammeter, and specific resistance of the material of a wire using meter bridge and post office box.

Mechanics
Kinematics in one and two dimensions (Cartesian coordinates only), projectiles; Uniform circular motion; Relative velocity.
Newton’s laws of motion; Inertial and uniformly accelerated frames of reference; Static and dynamic friction; Kinetic and potential energy; Work and power; Conservation of linear momentum and mechanical energy.
Systems of particles; Centre of mass and its motion; Impulse; Elastic and inelastic collisions.
Law of gravitation; Gravitational potential and field; Acceleration due to gravity; Motion of planets and satellites in circular orbits; Escape velocity.
Rigid body, moment of inertia, parallel and perpendicular axes theorems, moment of inertia of uniform bodies with simple geometrical shapes; Angular momentum; Torque; Conservation of angular momentum; Dynamics of rigid bodies with fixed axis of rotation; Rolling without slipping of rings, cylinders and spheres; Equilibrium of rigid bodies; Collision of point masses with rigid bodies.
Linear and angular simple harmonic motions.
Hooke’s law, Young’s modulus.
Pressure in a fluid; Pascal’s law; Buoyancy; Surface energy and surface tension, capillary rise; Viscosity (Poiseuille’s equation excluded), Stoke’s law; Terminal velocity, Streamline flow, equation of continuity, Bernoulli’s theorem and its applications.
Wave motion (plane waves only), longitudinal and transverse waves, superposition of waves; Progressive and stationary waves; Vibration of strings and air columns; Resonance; Beats; Speed of sound in gases; Doppler effect (in sound).

Thermal physics
Thermal expansion of solids, liquids and gases; Calorimetry, latent heat; Heat conduction in one dimension; Elementary concepts of convection and radiation; Newton’s law of cooling; Ideal gas laws; Specific heats (Cv and Cp for monoatomic and diatomic gases); Isothermal and adiabatic processes, bulk modulus of gases; Equivalence of heat and work; First law of thermodynamics and its applications (only for ideal gases); Blackbody radiation: absorptive and emissive powers; Kirchhoff’s law; Wien’s displacement law, Stefan’s law.

Electricity and magnetism
Coulomb’s law; Electric field and potential; Electrical potential energy of a system of point charges and of electrical dipoles in a uniform electrostatic field; Electric field lines; Flux of electric field; Gauss’s law and its application in simple cases, such as, to find field due to infinitely long straight wire, uniformly charged infinite plane sheet and uniformly charged thin spherical shell.
Capacitance; Parallel plate capacitor with and without dielectrics; Capacitors in series and parallel; Energy stored in a capacitor.
Electric current; Ohm’s law; Series and parallel arrangements of resistances and cells; Kirchhoff’s laws and simple applications; Heating effect of current.
Biot–Savart’s law and Ampere’s law; Magnetic field near a current-carrying straight wire, along the axis of a circular coil and inside a long straight solenoid; Force on a moving charge and on a current-carrying wire in a uniform magnetic field.
Magnetic moment of a current loop; Effect of a uniform magnetic field on a current loop; Moving coil galvanometer, voltmeter, ammeter and their conversions.
Electromagnetic induction: Faraday’s law, Lenz’s law; Self and mutual inductance; RC, LR and LC circuits with d.c. and a.c. sources.

Optics
Rectilinear propagation of light; Reflection and refraction at plane and spherical surfaces; Total internal reflection; Deviation and dispersion of light by a prism; Thin lenses; Combinations of mirrors and thin lenses; Magnification.
Wave nature of light: Huygen’s principle, interference limited to Young’s double-slit experiment.

Modern physics
Atomic nucleus; α, β and γ radiations; Law of radioactive decay;  Decay constant; Half-life and mean life; Binding energy and its calculation; Fission and fusion processes; Energy calculation in these processes.
Photoelectric effect; Bohr’s theory of hydrogen-like atoms; Characteristic and continuous X-rays, Moseley’s law; de Broglie wavelength of matter waves.

ARCHITECTURE APTITUDE TEST

Freehand drawing
This would comprise of simple drawing depicting the total object in its right form and proportion, surface texture, relative location and details of its component parts in appropriate scale.  Common domestic or day-to-day life usable objects like furniture, equipment, etc., from memory.

Geometrical drawing
Exercises in geometrical drawing containing lines, angles, triangles, quadrilaterals, polygons, circles, etc.  Study of plan (top view), elevation (front or side views) of simple solid objects like prisms, cones, cylinders, cubes, splayed surface holders, etc.

Three-dimensional perception
Understanding and appreciation of three-dimensional forms with building elements, colour, volume and orientation. Visualization through structuring objects in memory.

Imagination and aesthetic sensitivity
Composition exercise with given elements. Context mapping. Creativity check through innovative uncommon test with familiar objects. Sense of colour grouping or application.

Architectural awareness
General interest and awareness of famous architectural creations – both national and international, places and personalities (architects, designers, etc.) in the related domain.

 

Previous Year IIT JEE Question Papers and their answers

 

Year Paper 1 Paper 2
2007 Paper 1 Paper 2
2008 Paper 1 Paper 2
2009 Paper 1 Paper 2
2010 Paper 1 Paper 2
2011 Paper 1 Paper 2
2012 Paper 1 Paper 2
2013 Paper 1 Paper 2
2014 Paper 1 Paper 2
2015 Paper 1 Paper 2
2016 Paper 1 Paper 2
2017 Paper 1 Paper 2

 

List of College’s and seats available in these colleges

 

S.No. Name of IIT Number of seats
1 IIT Bhubaneswar 350
2 IIT Bombay 929
3 IIT Mandi 150
4 IIT Delhi 851
5 IIT Indore 260
6 IIT Kharagpur 1341
7 IIT Hyderabad 285
8 IIT Jodhpur 180
9 IIT Kanpur 827
10 IIT Madras 838
11 IIT Gandhinagar 180
12 IIT Patna 225
13 IIT Roorkee 975
14 IIT (ISM) Dhanbad 912
15 IIT Ropar 260
16 IIT (BHU) Varanasi 1090
17 IIT Guwahati 645
18 IIT Bhilai 120
19 IIT Goa 90
20 IIT Palakkad 120
21 IIT Tirupati 120
22 IIT Jammu 120
23 IIT Dharwad 120
Total All IITs 10988

Getting Started with Firebase for iOS Apps

Introduction To Firebase

A Mobile Application needs the backend services for performing various like data storage, caching, files hosting, data monitoring etc. Firebase is a cloud based service which helps the developers to focus on the Application architecture all the backend services are taken care by the Firebase cloud like Database, servers etc. Some useful services provided are as follows:

  1. Remote Database
  2. Remote Config
  3. Analytics
  4. Authentication
  5. Crash Reporting

In this article we will have a detailed go-through on  getting started with Firebase. So let’s get started.

Firebase Setup

In order to get started, first of all we need a Google Account. With your google account credentials please login to the Firebase Console, the link for the console is https://firebase.google.com.

Navigate to Firebase Console
Navigate to Firebase Console
  • We need to navigate to the console and Add a new project.
Firebase Console, Create a new project
Firebase Console, Create a new project
  • You will be asked to Enter a project name and well the Country/Region of yours. Enter the required details and click on “CREATE PROJECT”.
Firebase Create Project
Firebase Create Project
  • It will now ask on which platform do you want to add, Select iOS.
  • Now it’s time to provide some Xcode project details like bundle identifier, in my case it is “cr.kv.MyFirstProject”
Xcode Project Bundle Id
Xcode Project Bundle Id
  • Copy this bundle id and enter into the web console.
Provide Bundle ID
Provide Bundle ID
  • Click on Register App. We have just created a New project, we need to link it now to our Xcode Project.
  • It will provide us with a GoogleService-Info.plist file, we need to add this to our project.
GoogleService-Info.plist file for Xcode Project
GoogleService-Info.plist file for Xcode Project
  • Download the file and click on Continue.
  • We are all setup here at the console now we need to move to our Xcode project and add the FirebaseSDK.
Add Firebase to Xcode project
Add FirebaseSDK to Xcode project

Add FirebaseSDK to Xcode project

  • As we have already create a Xcode project named as “MyFirstProject”
  • We will add the SDK to that project.
  • Open Terminal App on Mac and move to the project directory, we will use cocoa pods for SDK installation.
Open terminal
Open terminal
  • Enter the below commands, one by one.
    • initialise pods

pod init

  • Open pod file

open -a textedit podfile

  • In the TextEdit app a podfile will be opened, we need to add following lines in the file.
pod 'Firebase'
pod 'Firebase/Core'
pod 'Firebase/Database'
pod 'Firebase/Auth'
Cocoa pods Installation
Cocoa pods Installation
  • Save the podfile and close the podfile.
  • Enter the next command to install the required pods.

pod install

This will be the desired output.

Pods Installed Successfully.
Pods Installed Successfully.
  • Open the <<projectname.xcworkspace>> file, we hope you have added the GoogleServices-Info.plist file as well.
Snapshot Xcode Project
Snapshot Xcode Project

Now we will add some code in AppDelegate.swift file, please navigate to the file.

This is a kind of final step, in this process.

//
//  AppDelegate.swift
//  MyFirstProject
//
//  Created by Chandra Rao on 25/03/18.
//  Copyright © 2018 Chandra Rao. All rights reserved.
//
import UIKit
import Firebase
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FirebaseApp.configure()
return true
}

And this is how we are set up for using Firebase into our iOS Application.

You can download the whole project from the link here, it can be used as a started project as well for our upcoming Firebase Tutorials.

In our next Tutorials, we will demonstrate how to use the Firebase Database. Please go through the article form the link here.