SQL Notes

CREATE TABLE `clients` (
  `id` int(4) NOT NULL AUTO_INCREMENT,
  `name` varchar(11) NOT NULL,
  `associate` varchar(100) NOT NULL,
  `revenue` int(12) NOT NULL,
  `profit` int(12) NOT NULL,
   PRIMARY KEY (`id`),
   FOREIGN key (`associate`) references `emp`(`emp_code`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

alter table `emp` add COLUMN `phone` int(12) not null after `name`
alter table `emp` add COLUMN `phone` int(12) null after `name`
alter table `emp` modify `phone` int(12) null
alter table `emp` drop column `phone`


ALTER TABLE `emp`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `emp_code` (`emp_code`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `emp`
--
ALTER TABLE `emp`
  MODIFY `id` int(4) NOT NULL AUTO_INCREMENT;
COMMIT;

SSL certification setup: Cloudflare.

This article will guide you to set your SSL certification using Cloudflare. Cloudflare is an internet security company which provides content delivery network service.

You can get free SSL certification as well as paid one from Cloudflare.

A breif discussion on SSL certification and https redirection.

So, Let’s start the process.

Steps:

Step1

Signup and Login to cloudflare. There you will get an option to add your site url. Do it and proceed.

Step2

Cloudflare will check your DNS records. You just click next and proceed.


Step3

Now choose your plan according to your needs. For this tutorial i preffered free plan. Paid plans will add some extra features and security to your site.

Step4

Now it will show you some details of your site to confirm. Just Click continue. And move on.

Step5

Cloudflare will give you two nameservers to replace with your default nameserver. Just login to your hosting provider and change it there. And then click continue.

If everything went good so far, cloudflare will activate security on your website. Click Re-check button to refresh cloudflare and it will show the status.

We are almost done. The last thing to do is – get your API key and paste it to wordpress plugin of cloudflare, and save API credentials.

That is it. Your site is now secured with a SSL certification from cloudflare. This certification is valid for 1 year.

https://www.cloudflare.com/

Magento File Directory

/app
The etc folder contains the di.xml configuration file
The di.xml file contains class mapping and interface preferences
Contains the design folder for themes.

/bin
The directory contains the magento file or a Command Line Interface script

/dev
Magento 2 testing and development tools are placed in this folder.

/lib
The internal and web subfolders are located here
The internal directory contains server-side libraries and several font files;
The web subfolder contains client-side libraries, jquery, modernizr, requirejs, prototype, scriptaculous

/pub
It should be set as your web root on the server
It contains all the publicly accessible files
index.php controller is also contained in the folder
pub also contains the error pages that will be displayed if your site is showing a 404 or 503 or another report page
Image uploads and imports will appear somewhere within pub/media.

/var
caches and generated classes are all located in the folder
the var folder includes cache, composer_home, generation, log, di, view_preprocessed, page_cache files

/vendor
the folder includes various packages that have been defined under composer.json
Marketplace modules and the core modules are all under vendor.
If you download something from the new Magento Marketplace.

Commands not to be used on terminal as a root user

First one on list is the infamous 8 characters in that particular order

rm -rf /

Sometimes we just want to remove the current directory for which the command is rm -rf ./ but you keyboard skips the dot and you end up in a deadzone.

Second one would be:

ifdown eth0

wow!!, you just disconnected your server from internet.

Basics about advertisements and Google Adsense

On 15th Year Anniversary of GOogle Adsense and their partnerships with Publishers, google published a youtube video briefly explaining all the basic keywords related to Adsense.

Transcript:
15 words to sum up 15 years?
That's easy! Okay, let's go.
Content
Content is at the heart of the web.
And publishers?
You power that web. Without you that place would be quite empty.
Ads? Ads bring the revenue that helps to fund it all while helping you reach your…
Goals! Goals like growing your business, doing something you love and sharing it with the world creating…
Memories? So many good memories!
You've told us that Adsense has funded your weddings,
helped you buy your homes or hire new teams. We feel part of your…
Community. A community that grows with you recommending us. Thank you!
Beginnings. It's been 15 years since we ran our first ads, they were text only back then.
Today? Today Adsense is truly global!
Urdu, Japanese or French – We speak 45 languages. And counting.
Changeā€¦is constant, especially on the web.
We've been evolving with you and your audience needs for the past 15 years,
to help you provide the best possible…
…Experiences. As the look and feel of websites have improved over the years
we built native ads to complement them,
while always giving you the…
Control. To decide what type of ads will show on your site.
Platforms? All of them. Mobile, Video and whatever will come next – we have you covered.
Time. Saved. With smart automated ad placements,
keeping things simple for you so that you can focus on creating great content.
Simplicity. Always. Our team's goal: making it easier to grow your business.
Okay and last but not least.
Happy Birthday! Absolutely. 15 years is a milestone we should all celebrate.
But the web doesn't wait so time to get back to work.
Can I finish my cake first?

Watch the video here

Receiving money in India | Why PayPal sucks and What are the charges?

So Why is Paypal bad? No, In theory It is not bad. It is an easy mode of payment transfer when comes to my international clients. But being an Indian citizen, why I never prefer Paypal as payment mode. Let us take a look.

So, I am going to explain it with an example of payment that I received from United Kingdom.
My client sent me 103.60 GBP which at the time of transaction was equivalent to 9334.35 INR.

Stage A

Initial Fee = (4.4% + Fixed fee) * taxes as per Indian Government (Currently 18% GST)

= (4.4% of 103.6 GBP + 0.2 GBP ) x 1.18
= (4.5584 + 0.2 ) x 1.18
= 4.7584 x 1.18
= 5.614912 GBP
= 5.62 GBP was charged

So, my Paypal amount is now 97.98 GBP (103.6 – 5.62 = 97.98)

Stage B

Now for some vague reason, Paypal India stores money in USD as base currency, so My Paypal balance showed 131.64 USD instead of 97.98 GBP. The important point to note here is that value of 131.64 USD at that moment was 95.22 GBP
When I argued Paypal support guys over this conversion, first of all they did not have an answer so they assumed some different question on their own. Later on they told me:

Thank you for your reply. I know that it can be confusing when you believe that you were charged more than you should have been in fees, but I am here to help!

PayPal uses the most up-to-date conversion rates at the time that a transaction is processed, however conversion rates are fluctuating constantly, which could explain why there is a difference in conversion rates that you are seeing.

I apologize for any frustrating this situation may have caused you. -Sarah

Somebody tell me when was the last time you saw a fluctuation of 2.812% in USD-GBP index in 24hr span?
So at present scenario I am left with 131.64 USD in my Paypal balance.

Stage 3

Now I wanted that money to sit in my bank account, so obviously I needed to withdraw in INR. I requested for a withdrawal and I was bound to acknowledge a sum credit of INR 8,242.53 (Of course 4% Fee is charged for Currency Conversion to INR)
so How much I got in Total – 8,242.53 INR!
We had started with 9,334.35 INR and I received 8,242.53 INR at the end which means a total of 1,091.82 INR (11.697% ) was somewhere lost in between in form of fees or taxes.

Summary of Fees and Charges vs Money lost in each stage using Paypal

Remark Amt. Amount of Money leaked
What client paid 103.60 GBP NIL
PayPal Fees -5.62 GBP 5.425%
What I received 97.98 GBP 5.425%
Paypal Balance 131.64 USD 8.088%
What I ultimately received 8,242.53 INR 11.697%

Here is the reference sheet –
https://www.paypal.com/in/webapps/mpp/ua/useragreement-full#exhibit_A